WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Custom post type UI: New version causing lots of PHP notices (11 posts)

  1. tomsel
    Member
    Posted 1 year ago #

    Since upgrading to the new version of the plugin, it's causing a lot of errors (all of the below multiplied by the number of custom post types registered through the plugin) for every page load.

    [23-Jun-2013 01:12:36 UTC] PHP Notice: Undefined index: rewrite_withfront in /**webroot**/WordPress/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 94

    [23-Jun-2013 01:12:50 UTC] PHP Notice: Undefined index: menu_icon in /**webroot**/WordPress/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 637

    I know I could get rid of the menu icon one by just setting a menu icon, but I don't want to do that at the moment and this is clogging up the error log whilst I'm trying to debug a site.

    hoping you can get this fixed soon, otherwise this is a handy plugin. :)

    Tom

    http://wordpress.org/extend/plugins/custom-post-type-ui/

  2. tomsel
    Member
    Posted 1 year ago #

    ...Never mind.

    I just re-saved all of the posts (without changing anything) and this must have registered the new fields, so no more errors.

  3. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    Hi tomsel,

    Yeah, it's one of those php notices that isn't going to hinder the plugin's use, and is more a null value "issue" that, as you noticed, clears itself once some content/data is saved.

    It will be getting fixed next point release.

  4. hennell
    Member
    Posted 1 year ago #

    I'm also getting two copies of this error on every page - however I can't save the data as trying to save gets the following:

    (Paths trimmed for convenience - this is currently all being run locally)

    Notice: Undefined index: rewrite_withfront in [...]/custom-post-type-ui.php on line 94
    
    Warning: Cannot modify header information - headers already sent by (output started at [...]/custom-post-type-ui.php:94) in [...]/wordpress/wp-includes/pluggable.php on line 876

    I've re-installed base wordpress to no effect, and based on online advice for this error been checking for problem whitespace in my theme/config files, but haven't found anything, and given the mentioned files I'm wondering if this is a CPTui issue.

    Any advice?

  5. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    I know I've seen some other people with the undefined index bit, which is honestly, not going to be a hindrance to use. However, I haven't seen the header info part quite yet, and not sure exactly what may be causing it. It could be part of this plugin, it could be a combination of any other plugins you have as well.

  6. Christian Wach
    Member
    Posted 1 year ago #

    Michael, it's getting to be a bit of a chore to fix this with every upgrade. It's very simple to avoid the PHP Notice - line 94 should read:

    $cpt_rewrite_withfront = ( isset( $cpt_post_type["rewrite_withfront"] ) ) ? esc_html($cpt_post_type["rewrite_withfront"]) : true;

    Other than that, cheers for a neat plugin!

  7. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    needle, if you could do me a favor, since I can't seem to ever see it on my own, could you screenshot the error in the location it's showing up within the browser?

    Yes I know it's an "easy fix" but I still want to be as thorough as possible. I am still puzzled about why I can't see it either.

  8. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

  9. Christian Wach
    Member
    Posted 1 year ago #

    Hi Michael,

    This happens predictably on any admin page with WP_DEBUG = true. It happens before any markup is output, so there's little point in a screenshot.

    Your GitHub repo at least has the logic the right way round, but still doesn't check if the index exists - isset() is your friend and there's no shame in defensive programming.

    Anyway, it's an inherited project, so I'll just export the current CPTs to code and disable the plugin instead.

  10. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    needle, I assure you I have as much php error reporting set to true as I can and I still can't manage to get any errors on any WP install, localhost or remote server.

    That said, I've said "screw it" and "blindly" took a jab at it. Just to be sure, in brief retrospect, I'll probably switch to empty() instead of isset() :P

  11. Christian Wach
    Member
    Posted 1 year ago #

    Hi Michael, good to hear you're taking action on this. I'm sure devs who work on projects that use this plugin are going to be happy to hear that.

    However, I expect you're more interested in why rather than that it's happening. So, FWIW, below is the serialised content of cpt_custom_post_types from the database that used to cause the notice to appear. The notices are, of course, also generated when I clicked the Get Code (or whatever it's called) button. I guess the obvious thing is that only a few of the CPTs have rewrite_withfront set.

    a:5:{i:0;a:19:{s:4:"name";s:7:"country";s:5:"label";s:9:"Countries";s:14:"singular_label";s:7:"Country";s:11:"description";s:0:"";s:6:"public";s:1:"1";s:7:"show_ui";s:1:"1";s:11:"has_archive";s:1:"0";s:19:"exclude_from_search";s:1:"1";s:15:"capability_type";s:4:"post";s:12:"hierarchical";s:1:"0";s:7:"rewrite";s:1:"1";s:12:"rewrite_slug";s:0:"";s:9:"query_var";s:1:"1";s:13:"menu_position";s:0:"";s:12:"show_in_menu";s:1:"1";s:19:"show_in_menu_string";s:0:"";i:0;a:1:{i:0;s:5:"title";}i:1;N;i:2;a:12:{s:9:"menu_name";s:0:"";s:7:"add_new";s:0:"";s:12:"add_new_item";s:0:"";s:4:"edit";s:0:"";s:9:"edit_item";s:0:"";s:8:"new_item";s:0:"";s:4:"view";s:0:"";s:9:"view_item";s:0:"";s:12:"search_items";s:0:"";s:9:"not_found";s:0:"";s:18:"not_found_in_trash";s:0:"";s:6:"parent";s:0:"";}}i:1;a:19:{s:4:"name";s:8:"language";s:5:"label";s:9:"Languages";s:14:"singular_label";s:8:"Language";s:11:"description";s:0:"";s:6:"public";s:1:"1";s:7:"show_ui";s:1:"1";s:11:"has_archive";s:1:"0";s:19:"exclude_from_search";s:1:"1";s:15:"capability_type";s:4:"post";s:12:"hierarchical";s:1:"0";s:7:"rewrite";s:1:"1";s:12:"rewrite_slug";s:0:"";s:9:"query_var";s:1:"1";s:13:"menu_position";s:0:"";s:12:"show_in_menu";s:1:"1";s:19:"show_in_menu_string";s:0:"";i:0;a:1:{i:0;s:5:"title";}i:1;N;i:2;a:12:{s:9:"menu_name";s:0:"";s:7:"add_new";s:0:"";s:12:"add_new_item";s:0:"";s:4:"edit";s:0:"";s:9:"edit_item";s:0:"";s:8:"new_item";s:0:"";s:4:"view";s:0:"";s:9:"view_item";s:0:"";s:12:"search_items";s:0:"";s:9:"not_found";s:0:"";s:18:"not_found_in_trash";s:0:"";s:6:"parent";s:0:"";}}i:2;a:19:{s:4:"name";s:8:"gameplay";s:5:"label";s:9:"Game Play";s:14:"singular_label";s:9:"Game Play";s:11:"description";s:0:"";s:6:"public";s:1:"1";s:7:"show_ui";s:1:"1";s:11:"has_archive";s:1:"0";s:19:"exclude_from_search";s:1:"1";s:15:"capability_type";s:4:"post";s:12:"hierarchical";s:1:"0";s:7:"rewrite";s:1:"1";s:12:"rewrite_slug";s:0:"";s:9:"query_var";s:1:"1";s:13:"menu_position";s:0:"";s:12:"show_in_menu";s:1:"1";s:19:"show_in_menu_string";s:0:"";i:0;a:1:{i:0;s:5:"title";}i:1;N;i:2;a:12:{s:9:"menu_name";s:0:"";s:7:"add_new";s:0:"";s:12:"add_new_item";s:0:"";s:4:"edit";s:0:"";s:9:"edit_item";s:0:"";s:8:"new_item";s:0:"";s:4:"view";s:0:"";s:9:"view_item";s:0:"";s:12:"search_items";s:0:"";s:9:"not_found";s:0:"";s:18:"not_found_in_trash";s:0:"";s:6:"parent";s:0:"";}}i:3;a:21:{s:4:"name";s:4:"time";s:5:"label";s:5:"times";s:14:"singular_label";s:4:"time";s:11:"description";s:0:"";s:6:"public";s:1:"1";s:7:"show_ui";s:1:"1";s:11:"has_archive";s:1:"0";s:19:"exclude_from_search";s:1:"1";s:15:"capability_type";s:4:"post";s:12:"hierarchical";s:1:"0";s:7:"rewrite";s:1:"1";s:12:"rewrite_slug";s:0:"";s:17:"rewrite_withfront";s:1:"1";s:9:"query_var";s:1:"1";s:13:"menu_position";s:0:"";s:12:"show_in_menu";s:1:"1";s:19:"show_in_menu_string";s:0:"";s:9:"menu_icon";s:0:"";i:0;a:1:{i:0;s:5:"title";}i:1;N;i:2;a:12:{s:9:"menu_name";s:0:"";s:7:"add_new";s:0:"";s:12:"add_new_item";s:0:"";s:4:"edit";s:0:"";s:9:"edit_item";s:0:"";s:8:"new_item";s:0:"";s:4:"view";s:0:"";s:9:"view_item";s:0:"";s:12:"search_items";s:0:"";s:9:"not_found";s:0:"";s:18:"not_found_in_trash";s:0:"";s:6:"parent";s:0:"";}}i:4;a:21:{s:4:"name";s:4:"game";s:5:"label";s:5:"Games";s:14:"singular_label";s:4:"Game";s:11:"description";s:0:"";s:6:"public";s:1:"1";s:7:"show_ui";s:1:"1";s:11:"has_archive";s:1:"0";s:19:"exclude_from_search";s:1:"1";s:15:"capability_type";s:4:"post";s:12:"hierarchical";s:1:"0";s:7:"rewrite";s:1:"1";s:12:"rewrite_slug";s:0:"";s:17:"rewrite_withfront";s:1:"1";s:9:"query_var";s:1:"1";s:13:"menu_position";s:0:"";s:12:"show_in_menu";s:1:"1";s:19:"show_in_menu_string";s:0:"";s:9:"menu_icon";s:0:"";i:0;a:1:{i:0;s:5:"title";}i:1;N;i:2;a:12:{s:9:"menu_name";s:0:"";s:7:"add_new";s:0:"";s:12:"add_new_item";s:0:"";s:4:"edit";s:0:"";s:9:"edit_item";s:0:"";s:8:"new_item";s:0:"";s:4:"view";s:0:"";s:9:"view_item";s:0:"";s:12:"search_items";s:0:"";s:9:"not_found";s:0:"";s:18:"not_found_in_trash";s:0:"";s:6:"parent";s:0:"";}}}

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic