Title: PHP Warning: Undefined variable $num_pastdue_actions
Last modified: September 28, 2022

---

# PHP Warning: Undefined variable $num_pastdue_actions

 *  Resolved [WEBHAUS](https://wordpress.org/support/users/webhaus/)
 * (@webhaus)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/)
 * Hello,
 * I’ve noticed that the latest version of Rank Math produces these errors:
 *     ```
       Undefined variable $num_pastdue_actions
   
       wp-content/plugins/seo-by-rank-math/vendor/woocommerce/action-scheduler/classes/ActionScheduler_AdminView.php:191
       wp-content/plugins/seo-by-rank-math/vendor/woocommerce/action-scheduler/classes/ActionScheduler_AdminView.php:194
       ```
   
 * One specific thing that could trigger this – we use .htaccess password protection
   for the website (therefore it is not publicly accessible).
 * Could you please check and fix this on the next release? 🙂
 * Thanks,

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [tpmr](https://wordpress.org/support/users/tpmr/)
 * (@tpmr)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16051514)
 * Hey,
    We now get the same warnings. Although we don’t have installed WooCommerce.
   Best regards
 *  Thread Starter [WEBHAUS](https://wordpress.org/support/users/webhaus/)
 * (@webhaus)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16051994)
 * I also do not have woocommerce installed.
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16055088)
 * Hello [@webhaus](https://wordpress.org/support/users/webhaus/),
 * Thank you for contacting the support, and sorry for the inconvenience caused.
 * The notice is related to the updated ActionScheduler library that includes a 
   new view in the actions list.
 * Please add the filter given below to your site to remove the notice:
 * `add_filter( 'action_scheduler_pastdue_actions_check_pre', '__return_false' );`
 * Here is how to add a filter to your site: [https://rankmath.com/kb/wordpress-hooks-actions-filters/](https://rankmath.com/kb/wordpress-hooks-actions-filters/)
 * Hope that helps. Let us know if you need any other assistance.
 *  Thread Starter [WEBHAUS](https://wordpress.org/support/users/webhaus/)
 * (@webhaus)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16057310)
 * Ok, I understand that this filter is Rank Math specific and disables that particular
   functionality (those Action Scheduler warning notices) and that is the easy way
   out, but I’m talking about PHP warnings which are being generated, if we do not
   turn it off – and PHP warnings mean that the code has an unexpected scenario 
   which needs to be fixed.
 * Once again I’m talking about this file:
    `wp-content/plugins/seo-by-rank-math/
   vendor/woocommerce/action-scheduler/classes/ActionScheduler_AdminView.php`
 * The problem is that if the variable $num_pastdue_actions is only being set when
   the initial $check variable returns null, hovewer code in any case continues 
   its execution below this check (on line 161) and on lines 191 and 194 tries to
   output a variable which is not set, resulting with a PHP warning.
 * The most simple way how you could avoid this warning, is by adding this small
   fix to the plugin just before the line 184 (contains comment: #Print notice):
 *     ```
       if(!isset($num_pastdue_actions)) {
       	$num_pastdue_actions = 0;
       }
       ```
   
 * This will check if the variable is set or not, and will set it to 0, if it is
   not set. As without this fix the code returns 0 anyway in the notice, so the 
   fix will not change anything except removing those two PHP warnings. I like to
   keep my error logs clean and I don’t want to disable this functionality.
    -  This reply was modified 3 years, 8 months ago by [WEBHAUS](https://wordpress.org/support/users/webhaus/).
    -  This reply was modified 3 years, 8 months ago by [WEBHAUS](https://wordpress.org/support/users/webhaus/).
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16057563)
 * Hello [@webhaus](https://wordpress.org/support/users/webhaus/)
 * Thank you for your suggestion.
 * This is actually a bug in WooCommerce’s Action Scheduler package. We have opened
   an issue on their GH repo:
    [https://github.com/woocommerce/action-scheduler/issues/865](https://github.com/woocommerce/action-scheduler/issues/865)
 * As soon as they will fix it, it will be fixed in the plugin as well.
 * Hope that helps.
 *  [tpmr](https://wordpress.org/support/users/tpmr/)
 * (@tpmr)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16057694)
 * Hello support team,
    But why do we get this message, if we don’t have installed
   woocommerce? Best regards
 *  [Edgars](https://wordpress.org/support/users/itmedia24/)
 * (@itmedia24)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16057808)
 * > This is actually a bug in WooCommerce’s Action Scheduler package.
 * No, this is not, we’re facing a similar issue with our sites and they do not 
   have WooCommerce installed at all. Please fix the warnings with the fix mentioned
   above.
 * Thanks!
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16060286)
 * Hello [@tpmr](https://wordpress.org/support/users/tpmr/) and [@itmedia24](https://wordpress.org/support/users/itmedia24/),
 * The bug is not in the main WooCommerce plugin or related to it. We use the Action
   Scheduler package of WooCommerce to schedule actions, and the bug is in that 
   package. We have already opened an issue in their GH repo, which should be fixed
   soon.
 * We really appreciate your patience in the meantime.
 * Don’t hesitate to get in touch in case you need our assistance with anything 
   else.
 *  [sweetmariascom](https://wordpress.org/support/users/sweetmariascom/)
 * (@sweetmariascom)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16367324)
 * I have the same errors … even with Rank Math Pro. I see this thread was 3 months
   ago at this point. So you are saying this still has not been fixed in the action
   scheduler of woo commerce? Seeing rank Math PHP errors on every page is not a
   great confidence builder! [@rankmathteam](https://wordpress.org/support/users/rankmathteam/)
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16370462)
 * Hello [@sweetmariascom](https://wordpress.org/support/users/sweetmariascom/),
 * They haven’t yet fixed the issue, so the notices are visible on some setups. 
   Please follow the steps mentioned here to fix the issue on your site:
   [https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16055088](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16055088)
 * Hope that helps.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘PHP Warning: Undefined variable $num_pastdue_actions’ is closed to new
replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

 * 10 replies
 * 5 participants
 * Last reply from: [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/php-warning-undefined-variable-num_pastdue_actions/#post-16370462)
 * Status: resolved