Using WP-Cron PHP CLI generated Fetal error: Uncaught Error: Call to undefined function

Hello:

In order to alleviate work on my Websites, I use the crontab to run wp-cron.php user www. Using PHP 7.4.20 (cli). The following error is generated:
PHP Fatal error:  Uncaught Error: Call to undefined function MainWP\Dashboard\session_write_close() in /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-utility.php:242
Stack trace:
#0 /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-sync.php(65): MainWP\Dashboard\MainWP_Utility::end_session()
#1 /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-system-cron-jobs.php(574): MainWP\Dashboard\MainWP_Sync::sync_site()
#2 /usr/local/www/support.in-design.com/wp-includes/class-wp-hook.php(292): MainWP\Dashboard\MainWP_System_Cron_Jobs->cron_updates_check()
#3 /usr/local/www/support.in-design.com/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
#4 /usr/local/www/support.in-design.com/wp-includes/plugin.php(551): WP_Hook->do_action()
#5 /usr/local/www/support.in-design.com/wp-cron.php(138): do_action_ref_array()
#6 {main}
  thrown in /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-utility.php on line 242

Has anyone seen this error and have an idea on how to fix it?

Thanks,
T

Could you do a crontab -l and post the output here?

Can you please try this version and see if it works better:

Hello @rhoekman I am running this from the system crontab /etc/crontab. So,

root@dev:~ # crontab -l
crontab: no crontab for root

but here is the crontab entry:

*/10 * * * * www /usr/local/bin/php /usr/local/www/support.in-design.com/wp-cron.php

@bogdan Uploaded. Removed all sites and added a single site to test. Will report back in a few when cron runs naturally…

T

1 Like

Thanks, let us know how it goes.

Hello:

Sorry for the delay on response. But the same error occurred. Please see the output email error:

PHP Fatal error:  Uncaught Error: Call to undefined function MainWP\Dashboard\session_write_close() in /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-utility.php:247
Stack trace:
#0 /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-sync.php(65): MainWP\Dashboard\MainWP_Utility::end_session()
#1 /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-system-cron-jobs.php(603): MainWP\Dashboard\MainWP_Sync::sync_site()
#2 /usr/local/www/support.in-design.com/wp-includes/class-wp-hook.php(292): MainWP\Dashboard\MainWP_System_Cron_Jobs->cron_updates_check()
#3 /usr/local/www/support.in-design.com/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
#4 /usr/local/www/support.in-design.com/wp-includes/plugin.php(551): WP_Hook->do_action()
#5 /usr/local/www/support.in-design.com/wp-cron.php(138): do_action_ref_array()
#6 {main}
  thrown in /usr/local/www/support.in-design.com/wp-content/plugins/mainwp/class/class-mainwp-utility.php on line 247
<!DOCTYPE html>
<html lang="en-US">
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width">
                <meta name='robots' content='max-image-preview:large, noindex, follow' />
        <title>WordPress &rsaquo; Error</title>
        <style type="text/css">
                html {
                        background: #f1f1f1;
                }
                body {
                        background: #fff;
                        border: 1px solid #ccd0d4;
                        color: #444;
                        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
                        margin: 2em auto;
                        padding: 1em 2em;
                        max-width: 700px;
                        -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
                        box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
                }
                h1 {
                        border-bottom: 1px solid #dadada;
                        clear: both;
                        color: #666;
                        font-size: 24px;
                        margin: 30px 0 0 0;
                        padding: 0;
                        padding-bottom: 7px;
                }
                #error-page {
                        margin-top: 50px;
                }
                #error-page p,
                #error-page .wp-die-message {
                        font-size: 14px;
                        line-height: 1.5;
                        margin: 25px 0 20px;
                }
                #error-page code {
                        font-family: Consolas, Monaco, monospace;
                }
                ul li {
                        margin-bottom: 10px;
                        font-size: 14px ;
                }
                a {
                        color: #0073aa;
                }
                a:hover,
                a:active {
                        color: #006799;
                }
                a:focus {
                        color: #124964;
                        -webkit-box-shadow:
                                0 0 0 1px #5b9dd9,
                                0 0 2px 1px rgba(30, 140, 190, 0.8);
                        box-shadow:
                                0 0 0 1px #5b9dd9,
                                0 0 2px 1px rgba(30, 140, 190, 0.8);
                        outline: none;
                }
                .button {
                        background: #f3f5f6;
                        border: 1px solid #016087;
                        color: #016087;
                        display: inline-block;
                        text-decoration: none;
                        font-size: 13px;
                        line-height: 2;
                        height: 28px;
                        margin: 0;
                        padding: 0 10px 1px;
                        cursor: pointer;
                        -webkit-border-radius: 3px;
                        -webkit-appearance: none;
                        border-radius: 3px;
                        white-space: nowrap;
                        -webkit-box-sizing: border-box;
                        -moz-box-sizing:    border-box;
                        box-sizing:         border-box;

                        vertical-align: top;
                }

                .button.button-large {
                        line-height: 2.30769231;
                        min-height: 32px;
                        padding: 0 12px;
                }

                .button:hover,
                .button:focus {
                        background: #f1f1f1;
                }

                .button:focus {
                        background: #f3f5f6;
                        border-color: #007cba;
                        -webkit-box-shadow: 0 0 0 1px #007cba;
                        box-shadow: 0 0 0 1px #007cba;
                        color: #016087;
                        outline: 2px solid transparent;
                        outline-offset: 0;
                }

                .button:active {
                        background: #f3f5f6;
                        border-color: #7e8993;
                        -webkit-box-shadow: none;
                        box-shadow: none;
                }

                        </style>
</head>
<body id="error-page">
        <div class="wp-die-message"><p>There has been a critical error on this website.</p><p><a href="https://wordpress.org/support/article/faq-troubleshooting/">Learn more about troubleshooting WordPress.</a></p></div></body>
</html>

thanks, we will check this again

I just got a new update, please try this version:

Downloaded and installed. Will report back. Also, just for additional info, I am attaching system report and leaving info.php up in case anyone wants to check it @ INFO.PHP

Also, now I am having an issue connecting to the sites. Tried to remove them and put them back in; but they will not remove. How to force/manually remove child sites? Without Dashboard trying to uninstall Mainwp on the child sites; because it obviously cannot.

Thanks,
T


### Server Info                    Required                                               Detected                                     Status   ###

MainWP Dashboard                   
MainWP Dashboard Version           4.1.6                                                  4.1.7-beta2                                  Warning     
MainWP Upload Directory            Writable                                               Writable                                     Pass        
MainWP Extensions                  
No installed extensions            
WordPress                          
WordPress Version                  >=3.6                                                  5.7.2                                        Pass        
WordPress Memory Limit             >=64M                                                  256M                                         Pass        
MultiSite Disabled                 =true                                                  true                                         Pass        
FileSystem Method                  = direct                                               direct                                       Pass        
PHP                                
PHP Version                        >=5.6                                                  7.4.20                                       Pass        
PHP Safe Mode Disabled             =true                                                  true                                         Pass        
PHP Max Execution Time             >=30 seconds                                           180                                          Pass        
PHP Max Input Time                 >=30 seconds                                           600                                          Pass        
PHP Memory Limit                   >=128M                                                 1024M                                        Pass        
PCRE Backtracking Limit            >=10000                                                1000000                                      Pass        
PHP Upload Max Filesize            >=2M                                                   256M                                         Pass        
PHP Post Max Size                  >=2M                                                   512M                                         Pass        
SSL Extension Enabled              =true                                                  true                                         Pass        
SSL Warnings                       = empty                                                                                             Pass        
cURL Extension Enabled             =true                                                  true                                         Pass        
cURL Timeout                       >=300 seconds                                          600                                          Pass        
cURL Version                       >=7.18.1                                               7.76.0                                       Pass        
cURL SSL Version                   >=OpenSSL/0.9.8l                                       OpenSSL/1.1.1h                               Pass        
PHP Allow URL fopen                YES                                                    
PHP Exif Support                   YES ( V7.4.)                                           
PHP IPTC Support                   YES                                                    
PHP XML Support                    YES                                                    
PHP Disabled Functions             No functions disabled.                                 
PHP Loaded Extensions              Core, Phar, Reflection, SPL, SimpleXML, bcmath, bz2, cgi-fcgi, ctype, curl, date, dom, exif, fileinfo, filter, gd, gettext, gmp, hash, ice, iconv, imagick, intl, json, libxml, mbstring, mysqli, mysqlnd, openssl, pcre, soap, standard, xml, xmlreader, xmlrpc, xmlwriter, zlib
MySQL                              
MySQL Version                      >=5.0                                                  10.5.10-MariaDB                              Pass        
MySQL Mode                         ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
MySQL Client Encoding              utf8                                                   
Server Info                        
WordPress Root Directory           /usr/local/www/support.in-design.com/                  
Server Name                        support.in-design.com                                  
Server Software                    Apache/2.4.48 (FreeBSD) OpenSSL/1.1.1h-freebsd         
Operating System                   FreeBSD                                                
Architecture                       64		 bit                                               
Server IP                          50.248.75.74                                           
Server Protocol                    HTTP/1.1                                               
HTTP Host                          support.in-design.com                                  
HTTPS                              ON                                                     
Server self connect                The HTTP response test get an error "cURL error 60: SSL certificate problem: unable to get local issuer certificate"Not expected HTTP response body:
User Agent                         Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Server Port                        443                                                    
Gateway Interface                  CGI/1.1                                                
Memory Usage                       82.45 MB                                               
Complete URL                       https://support.in-design.com/wp-admin/admin.php?page=managesites&id=18
Request Time                       1624478349                                             
Accept Content                     text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Charset Content             N/A                                                    
Currently Executing Script Pathname//usr/local/www/support.in-design.com/wp-admin/admin.php
Current Page URI                   /wp-admin/admin.php?page=ServerInformation             
Remote Address                     50.248.75.77                                           
Remote Host                        N/A                                                    
Remote Port                        1026                                                   
MainWP Settings                    
Number Of Child Sites              4                                                      
Use WP-Cron                        Yes                                                    
Optimize for Shared Hosting or Big NetworksYes                                                    
Automatic Daily Update             Install trusted updates                                
Abandoned Plugins/Themes Tolerance 730                                                    
Maximum number of posts to return                                                         
Maximum number of pages to return                                                         
Primary Backup System              Default MainWP Backups                                 
Maximum simultaneous requests      4                                                      
Minimum delay between requests     200                                                    
Maximum simultaneous requests per ip1                                                      
Minimum delay between requests to the same ip1000                                                   
Maximum simultaneous sync requests 8                                                      
Minimum simultaneous install/update requests3                                                      
Active Plugins                     
Braintree for WooCommerce Payment Gateway2.6.1                                                  Active                                       
Facebook for WooCommerce           2.6.0                                                  Active                                       
Facebook for WordPress             3.0.5                                                  Inactive                                     
Health Check & Troubleshooting     1.4.5                                                  Active                                       
Mailchimp for WooCommerce          2.5.1                                                  Inactive                                     
MainWP Dashboard                   4.1.7-beta2                                            Active                                       
Post SMTP                          2.0.23                                                 Active                                       
Reseller Store                     2.2.6                                                  Active                                       
Site Kit by Google                 1.35.0                                                 Inactive                                     
WebP Express                       0.20.1                                                 Active                                       
WooCommerce                        5.4.1                                                  Active                                       
WooCommerce PayPal Checkout Gateway2.1.1                                                  Active                                       
WooCommerce Subscriptions          3.1.3                                                  Active                                       

Hi @tziady,

Thanks. Let me know how it goes.

Could you try to call it with curl instead? This is how I do it and it works fine…

For testing on the commandline and see if you get any errors you could issue this:

curl https://support.in-design.com/wp-cron.php?doing_wp_cron

Your crontab would be:

*/10 * * * * curl https://support.in-design.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

We skipped a bit over that first error message though:

root@dev:~ # crontab -l
crontab: no crontab for root

I used FreeBSD alot back in the day. And that system can be a bit more explicit with permissions. This message tells me that there is no crontab at all. If all the suggestions mentioned above fail. Try this:

crontab -e -u root

And then add:

*/10 * * * * curl https://support.in-design.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

Let us know if it works! :slight_smile:

2 Likes

Will do and report back.

With the current incarnations of FreeBSD (and am a returning operator from way way back in the day (read early 90s); there is both a root crontab and a system /etc/crontab that I have always used without too many errors.

However, I will try and use the actual root user’s tab and see if that helps.

The other thing that is odd; is that this machine has 3 virtual sites on it. The other 2 (granted do not have Main WP) appear to not have any issues whatsoever.

Anyway, I will definitely try these and let you know.

Thanks for the help.

Cheers,
T

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.