• Resolved liamc

    (@liamc)


    Hello first of all thanks for the awesome Plugin:)

    I have a Problem with my CPT UI installation. i Honestly dont know what happend, but i think the error accoured when i created a new post type a while ago. I tried to fix it the last 4 days but with no luck

    I Recieve the following error message from my Logs:

    /public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 611PHP message: PHP Warning: Invalid argument supplied for foreach()

    im not very familiar with coding but i looked up the costum-post-type-ui.php file and on the line 611 following code is shown (with the few following lines):

    	foreach ( $taxonomy['labels'] as $key => $label ) {
    
    		if ( ! empty( $label ) ) {
    			$labels[ $key ] = $label;
    		} elseif ( empty( $label ) && in_array( $key, $preserved, true ) ) {
    			$singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['taxonomies']['plural'] ) ) ) ? 'plural' : 'singular';
    			$label_plurality    = ( 'plural' === $singular_or_plural ) ? $taxonomy['label'] : $taxonomy['singular_label'];
    			$labels[ $key ]     = sprintf( $preserved_labels['taxonomies'][ $singular_or_plural ][ $key ], $label_plurality );
    		}

    The following Line is also mentioned in the error log:
    /public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 381PHP message: PHP Warning: Invalid argument supplied for foreach()

    Wich calls another thing:

    	foreach ( $post_type['labels'] as $key => $label ) {
    
    		if ( ! empty( $label ) ) {
    			if ( 'parent' === $key ) {
    				$labels['parent_item_colon'] = $label;
    			} else {
    				$labels[ $key ] = $label;
    			}
    		} elseif ( empty( $label ) && in_array( $key, $preserved, true ) ) {
    			$singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['post_types']['plural'] ) ) ) ? 'plural' : 'singular';
    			$label_plurality    = ( 'plural' === $singular_or_plural ) ? $post_type['label'] : $post_type['singular_label'];
    			$labels[ $key ]     = sprintf( $preserved_labels['post_types'][ $singular_or_plural ][ $key ], $label_plurality );
    		}

    it seems like something went wrong with a argument “foreach” but i dont know what caused it… there was nothing changed with other post types and i am not really sure what caused it. i did not do any updates recently.
    i have searched this forum trought and tried some things wich where similar i have tried the following things in the following order:

    -Deactivating all other plugins (It seems CPTUI is causing it)

    -Deactivating and reactivating CPTUI (Still no change)

    -Updated the settings for permalinks (Did not work tried multiple times)

    -imported the post type code blob ( Was suggested in another post in this forum)

    -Deleted the new created post types (After that didnt work i restored to a backup i did before deleting the new post types)

    -Reinstalled CPTUI

    Here is a code blob from the cptui settings:
    {"dj_portfolios":{"name":"dj_portfolios","label":"Dj Portfolios","singular_label":"Dj Portfolio","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","comments","revisions","author","page-attributes","post-formats"],"taxonomies":["artist_type"],"labels":{"menu_name":"Dj Portfolios","all_items":"All Dj Portfolios","add_new":"Add new","add_new_item":"Add new Dj Portfolio","edit_item":"Edit Dj Portfolio","new_item":"New Dj Portfolio","view_item":"View Dj Portfolio","view_items":"View Dj Portfolios","search_items":"Search Dj Portfolios","not_found":"No Dj Portfolios found","not_found_in_trash":"No Dj Portfolios found in trash","parent":"Parent Dj Portfolio:","featured_image":"Featured image for this Dj Portfolio","set_featured_image":"Set featured image for this Dj Portfolio","remove_featured_image":"Remove featured image for this Dj Portfolio","use_featured_image":"Use as featured image for this Dj Portfolio","archives":"Dj Portfolio archives","insert_into_item":"Insert into Dj Portfolio","uploaded_to_this_item":"Upload to this Dj Portfolio","filter_items_list":"Filter Dj Portfolios list","items_list_navigation":"Dj Portfolios list navigation","items_list":"Dj Portfolios list","attributes":"Dj Portfolios attributes","name_admin_bar":"Dj Portfolio","item_published":"Dj Portfolio published","item_published_privately":"Dj Portfolio published privately.","item_reverted_to_draft":"Dj Portfolio reverted to draft.","item_scheduled":"Dj Portfolio scheduled","item_updated":"Dj Portfolio updated.","parent_item_colon":"Parent Dj Portfolio:"},"custom_supports":""},"dj_service":{"name":"dj_service","label":"Dj Services","singular_label":"Dj Service","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","comments","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":null,"custom_supports":""},"foto_portfolio":{"name":"foto_portfolio","label":"Foto Portfolios","singular_label":"Foto Portfolio","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-camera-alt","supports":["title","editor","thumbnail","excerpt","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":["all_artists_types"],"labels":{"menu_name":"My Foto Portfolios","all_items":"All Foto Portfolios","add_new":"Add new","add_new_item":"Add new Foto Portfolio","edit_item":"Edit Foto Portfolio","new_item":"New Foto Portfolio","view_item":"View Foto Portfolio","view_items":"View Foto Portfolios","search_items":"Search Foto Portfolios","not_found":"No Foto Portfolios found","not_found_in_trash":"No Foto Portfolios found in trash","parent":"Parent Foto Portfolio:","featured_image":"Featured image for this Foto Portfolio","set_featured_image":"Set featured image for this Foto Portfolio","remove_featured_image":"Remove featured image for this Foto Portfolio","use_featured_image":"Use as featured image for this Foto Portfolio","archives":"Foto Portfolio archives","insert_into_item":"Insert into Foto Portfolio","uploaded_to_this_item":"Upload to this Foto Portfolio","filter_items_list":"Filter Foto Portfolios list","items_list_navigation":"Foto Portfolios list navigation","items_list":"Foto Portfolios list","attributes":"Foto Portfolios attributes","name_admin_bar":"Foto Portfolio","item_published":"Foto Portfolio published","item_published_privately":"Foto Portfolio published privately.","item_reverted_to_draft":"Foto Portfolio reverted to draft.","item_scheduled":"Foto Portfolio scheduled","item_updated":"Foto Portfolio updated.","parent_item_colon":"Parent Foto Portfolio:"},"custom_supports":""},"video_portfolios":{"name":"video_portfolios","label":"Video Portfolios","singular_label":"Video Portfolio","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-video-alt2","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":{"menu_name":"My Video Portfolios","all_items":"All Video Portfolios","add_new":"Add new","add_new_item":"Add new Video Portfolio","edit_item":"Edit Video Portfolio","new_item":"New Video Portfolio","view_item":"View Video Portfolio","view_items":"View Video Portfolios","search_items":"Search Video Portfolios","not_found":"No Video Portfolios found","not_found_in_trash":"No Video Portfolios found in trash","parent":"Parent Video Portfolio:","featured_image":"Featured image for this Video Portfolio","set_featured_image":"Set featured image for this Video Portfolio","remove_featured_image":"Remove featured image for this Video Portfolio","use_featured_image":"Use as featured image for this Video Portfolio","archives":"Video Portfolio archives","insert_into_item":"Insert into Video Portfolio","uploaded_to_this_item":"Upload to this Video Portfolio","filter_items_list":"Filter Video Portfolios list","items_list_navigation":"Video Portfolios list navigation","items_list":"Video Portfolios list","attributes":"Video Portfolios attributes","name_admin_bar":"Video Portfolio","item_published":"Video Portfolio published","item_published_privately":"Video Portfolio published privately.","item_reverted_to_draft":"Video Portfolio reverted to draft.","item_scheduled":"Video Portfolio scheduled","item_updated":"Video Portfolio updated.","parent_item_colon":"Parent Video Portfolio:"},"custom_supports":""},"graphic_portfolios":{"name":"graphic_portfolios","label":"Graphic Portfolios","singular_label":"Graphic Portfolio","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-edit","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":null,"custom_supports":""},"graphic_services":{"name":"graphic_services","label":"Graphic Services","singular_label":"Graphic Service","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-edit","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":null,"custom_supports":""},"katalog":{"name":"katalog","label":"Katalog","singular_label":"Katalog","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail"],"taxonomies":["kleidung"],"labels":null,"custom_supports":""},"foto_services":{"name":"foto_services","label":"Foto Services","singular_label":"Foto Service","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-camera-alt","supports":["title","editor","thumbnail","excerpt","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":null,"custom_supports":""},"video_service":{"name":"video_service","label":"Video Services","singular_label":"Video Service","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-video-alt2","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":null,"custom_supports":""},"grafik-showroom":{"name":"grafik-showroom","label":"Grafik Design Showrooms","singular_label":"Grafik Design Showroom","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","none"],"taxonomies":[],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"grafik-content":{"name":"grafik-content","label":"grafik design content","singular_label":"grafik designs content","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail"],"taxonomies":[],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"video_showroom":{"name":"video_showroom","label":"Video Showrooms","singular_label":"Video Showroom","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","none"],"taxonomies":[],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"video_content":{"name":"video_content","label":"Video Content","singular_label":"Videos Content","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","none"],"taxonomies":[],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"costum_services":{"name":"costum_services","label":"Costum Services","singular_label":"Costum Service","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","excerpt","trackbacks","custom-fields","revisions","author","page-attributes","post-formats"],"taxonomies":[],"labels":null,"custom_supports":""}}

    i hope you can help me out i tired to fix this for the last seven days:(

    Kind regards
    Liam

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi there @liamc

    I’m curious if this install in question is one that’s had CPTUI installed for a long while and is getting a due upgrade. From the looks of your output above, there’s about 7 post types that have a value of null for the labels array. I have listed them below.

    To resolve the warnings, you can simply just click to edit each, and click save without changing anything. This will get those labels values filled in with a non-null value and clear up those warnings.

    costum_services
    video_service
    foto_services
    katalog
    graphic_services
    graphic_portfolios
    dj_service

    You’ll want to do the same for the taxonomies, where you just click to edit and save without changes. However I don’t have a specific list of those to do so to, as I was only provided the post type settings above. Hopefully there’s not too many taxonomies in this case.

    Thread Starter liamc

    (@liamc)

    Hello Micheal Thanks for the quick awnser and awesome support.
    yes it is a older installation about one year old.
    I have tried to update every post type and the error messages with the cptui line 611 and 381 are now gone. But now every few times i want to update posts some fatal error occours mentioning the wp-db.php and meta.php.

    Here are the lines of codes mentioned in the error log
    META-PHP:

    	foreach ( $meta_list as $metarow ) {
    			$mpid = (int) $metarow[ $column ];
    			$mkey = $metarow['meta_key'];
    			$mval = $metarow['meta_value'];
    
    			// Force subkeys to be array type.

    WP-DB.PHP:

    while ( $row = mysqli_fetch_object( $this->result ) ) {
    					$this->last_result[ $num_rows ] = $row;
    					$num_rows++;
    				}

    When CPTUI is deactivated the error seems to disapear (Tried to reload page and update posts many times with no problems).

    whats also strange is that the error message dissapears when refreshing the page a couple of times. also if i update it with elementor 9/10 Times it tells me Server Error.

    I use a powerfull cloud solution wich i contacted beacause i thought maybe i have setup things to low. there where no problems with memory size since i have 8gb ram 160gb memory and the memory limit + upload limit is set to 300M. i also made sure the wp-config.php file has also a memory limit set to 300. I know this is not in your Department but i wanted to paint a full picture because my first idea was that it would be a memory or power problem.

    Any other ideas what i could do to fix this? Im scared that something withing my cptui database is corruptet buts thats just a random guess im not really into programming. i am really happy about your help.

    Kind regards Liam

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I would need to see actual error messages, locations and lines to know what may or may not be going on still and if it’s for sure something coming from CPTUI itself.

    Thread Starter liamc

    (@liamc)

    Hello Michael rhanks again for the quick awnser awesome support!:)

    So the error message i recieve the most is:
    “Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 131072 bytes) in /home/348354.cloudwaysapps.com/nxuwbmyafh/public_html/wp-includes/wp-db.php on line 2022”

    The second one after some refreshing the page is:
    “Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /home/348354.cloudwaysapps.com/nxuwbmyafh/public_html/wp-includes/meta.php on line 1064”

    the page works but i have to constantly refresh the page and 9/10 updating posts do not work.

    the error disapears if cptui is deactivated. And also appears if only cptui is active. but it only appear on some sites i updated recently. None of them is a post made by cptui wich is really strange. The files that caused the error are mentioned above:

    META PHP:

    foreach ( $meta_list as $metarow ) {
    			$mpid = (int) $metarow[ $column ];
    			$mkey = $metarow['meta_key'];
    			$mval = $metarow['meta_value'];
    
    			// Force subkeys to be array type.

    WP-DB PHP:

    while ( $row = mysqli_fetch_object( $this->result ) ) {
    					$this->last_result[ $num_rows ] = $row;
    					$num_rows++;
    				}

    those are the two lines mentioned in the error message. Hope this helps to find something out. Thank you very much for the help kind regards.
    Liam

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    All in all, it sounds like the site is using up a lot of memory, and actually exhausting all available memory at times. Not something that can be specifically directed at CPTUI, though we obviously contribute some memory usage.

    I would check your WP Health Check areas to see what your current server memory levels are at, and what could be potentially done to increase those limits.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘CPTUI Causes critical error messages: PHP Warning: Invalid argument supplied’ is closed to new replies.