• Resolved decisiveliberty

    (@decisiveliberty)


    After updating to the latest WP version, the following is appearing in the error log…

    PHP Warning: Invalid argument supplied for foreach() in …/wp-includes/class-wp-post-type.php on line 526

    It cycles by repeating every few seconds then calms down for about 3 minutes, then repeating every few seconds then calms down for about another 3 minutes.

    As this is a core php file in WP, are we looking at waiting for an update for this to be corrected? Or is there something we can do in the interim until this is corrected (fully realizing this will be overwritten – or should be – by the next update)? I’m not a programmer, more of a tinkerer.

    Thanks in advance.

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

Viewing 15 replies - 1 through 15 (of 16 total)
  • autotutorial

    (@autotutorial)

    https://www.ads-software.com/support/topic/warning-message-115/#post-12134170
    are you two to receive the same error, have you installed wordpress via some loader?

    Thread Starter decisiveliberty

    (@decisiveliberty)

    Updated WP via the update notice on the dashboard…
    Will perform tests tonight w deactivating plugins and using 2020 WP theme.
    Either way, going to roll back one version of WP until this is resolved by WP and/or any conflicting plugins we discover.

    autotutorial

    (@autotutorial)

    can you temporarily add this code before of foreach? Add post
    I would like to analyze the output

    if(!function_exists('var_x_error_log')) {
    if(!is_array($this->supports) && !is_object($this->supports)){
    function var_x_error_log( $objectauto=null){
    ob_start(); // start buffer capture
    var_dump($objectauto); // dump the value
    $contentsauto = ob_get_contents(); // put the buffer into a variable
    ob_end_clean(); // end capture
    error_log( $contentsauto."\n",3,dirname(__FILE__).'/test.log'); // log contents of the result of var_dump( $objectauto)
    }
    var_x_error_log($this->supports);
    }
    }

    This script create https://yourdomain.com/wp-includes/test.log
    it is enough for me to post only the first incorrect result, then delete test.log and this script.

    Hey, i will do as much of the same as i can. Mine was a notification in my dashboard by the host service. I diskike roklbacks in the middle of a hosyo ng transfer, but ya gotta do what ya gotta do. Apologies for the delayed reply, lors going on. Thanks!

    Oh hell, i thinkni actually might be seeing what is going on. Lemme see if i am right or if i need more class time at Help Menu U….

    workad

    (@workad)

    I am having the same issue with my site and my WP was updated through my hosting company. Is there a solution for this?

    I have been unsuccessful as of yet at uploading my website to the new host. I cannot test out. I have to get the site up.

    neocraft

    (@neocraft)

    Hello, all same issue since update via dashboard !

    PHP Warning: Invalid argument supplied for foreach() in …/wp-includes/class-wp-post-type.php on line 526

    Problem is from WP_PAYPAL plugin !!

    Just update and it will be fixed :

    https://www.ads-software.com/support/topic/plugin-issue-with-latest-wp-update/

    • This reply was modified 5 years ago by neocraft.
    will83

    (@will83)

    If you have a custom post type registred with register_post_type(), the “supports” argument must be an array, if not it generate this error.

    Thread Starter decisiveliberty

    (@decisiveliberty)

    @will83 – this is in the core WP php file, not a custom file.

    @neocraft’s experience was with WP_PAYPAL, which we have. The PayPal plugin would not have let us update it while in 5.2.4 so we updated WP to 5.3, resulting in the PHP Warnings starting immediately. Updated the PayPal plugin and the PHP warnings stopped immediately.

    Chock one up for doing the basic of basic moves – check your plugins. At least one of us has learned a few things from the threads, hope others did as well.

    Thanks everyone.

    autotutorial

    (@autotutorial)

    WordPress 5.3 add supports array for register_post_type() https://make.www.ads-software.com/core/2019/10/15/miscellaneous-developer-focused-changes-in-5-3/
    Add args before wordpress 5.3 supports had no arguments, mistakenly you could use supports with a string value, from WordPress 5.3 must be Array.
    Compatibility php 7.4, it is required that the variable is initialized in the type of final data.
    This generates a warning

    $val = false;
    $val[0];

    So for theme and plugin make sure they are tested with the current version Tested up to: WordPress version https://make.www.ads-software.com/plugins/2017/08/29/minimum-php-version-requirement/
    WordPress 5.3 core supports php 7.4

    WordPress and PHP 7.4

    Nice! If only i can resolve my nameserver, host, as and site i can fix!

    @autotutorial do you know anyone who has updated their request_post_type() with array options and fixed this error? Just wondering what their process was.

    We’re seeing this on a new site too.

    Ok, figured it out from the details on this page… https://www.ads-software.com/support/topic/plugin-issue-with-latest-wp-update/

    Search for any references to…'supports' =>

    And make sure it if it looks like this… 'supports' => 'title' …that you change it to this 'supports' => array('title')

    I hope that helps.

    Yes martinmillerco is correct, and ensuring there is an array sorted the issue to me:

    Make sure it if it looks like this… ‘supports’ => ‘title’ …that you change it to this ‘supports’ => array(‘title’)

    • This reply was modified 4 years, 10 months ago by kierancalv.
Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Invalid argument supplied for foreach() in class-wp-post-type.php’ is closed to new replies.