Support » Plugin: Abandoned Cart Lite for WooCommerce » Plugin creates lots of PHP error log messages for cron job

  • Resolved lvl99

    (@lvl99)


    I’m having issues with lots of error messages being generated by this plugin:

    [16-Feb-2018 18:18:21 UTC] PHP Fatal error: require_once(): Failed opening required '/home/wp-load.php' (include_path='.:') in /home/exampleuser/example.com/web/app/plugins/woocommerce-abandoned-cart/cron/wcal_send_email.php on line 13

    It’s causing errors when performing actions in the back-office as well.

    I’d recommend trying file_exists( $wp_load = "{$ABSPATH}/wp-load.php" ); before doing the recursive directory search (as an important note I use Roots’ Bedrock for my WordPress set up which changes some of the core folder structure).

    • This topic was modified 4 years, 3 months ago by lvl99.
    • This topic was modified 4 years, 3 months ago by lvl99. Reason: Code update
    • This topic was modified 4 years, 3 months ago by lvl99.
    • This topic was modified 4 years, 3 months ago by lvl99. Reason: Another code update
    • This topic was modified 4 years, 3 months ago by lvl99.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor chetnapatel

    (@chetnapatel)

    Hi,

    Thank you for sharing error message of your debug file and the solution of the issue.

    We have looped into the directory for finding the wp-load.php file, as some of the clients had renamed the default directory name using one of the plugins. So the current code was meant to find the wp-load.php file and include it, so we can use the WordPress functions.

    The solution which you shared with me was the original code for including the wp-load.php file in our plugin. But for above issue which I have explained, we have changed the code.

    Can you please let me know where is the “wp-load.php” file present in your directory as you have changed it using Roots’ Bedrock for WordPress?

    So, yes I will look for another solution which will work on all scenario.

    [ Signature deleted ]

    • This reply was modified 4 years, 3 months ago by Jan Dembowski.
    Thread Starter lvl99

    (@lvl99)

    Hiya Chetna,

    Here’s the full code, in which I have modified only the first line:

    if ( ! file_exists( $wp_load = untrailingslashit( ABSPATH ) . "/wp-load.php" ) ) {
        $wp_load = false;
        $dir     = __FILE__;
        while( '/' != ( $dir = dirname( $dir ) ) ) {
            if( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
                break;
            }
        }
    }
    require_once $wp_load;

    It should check for the ABSPATH location first, and if it returns false, it then checks in other folders.

    With Roots’ Bedrock, they put WP files in a /path/to/website/web/wp/ folder (all other files like uploads, themes and plugins are in the /path/to/website/web/app/ folder), however I’ve modified mine to have WP files in the /path/to/website/web/cms/ folder. Either way, for Root’s Bedrock the ABSPATH points to the folder which contains all the WP CMS files.

    For my server, the wp-load.php file is within the WP CMS folder located at /home/exampleuser/example.com/web/cms/wp-load.php. This means that when your original cron script runs, it can’t find the wp-load.php file because it’s going up from a directory that is separate to the WP CMS files, i.e. /home/exampleuser/example.com/web/app/plugins/woocommerce-abandoned-cart/. The cron script produces errors with a path that specifies /home/wp-load.php.

    Plugin Contributor chetnapatel

    (@chetnapatel)

    Hi,

    Thank you for sharing such a valuable information and sharing the solution with us.

    Yes, you are right. The cron script could not find out “wp-load.php” file as the path has been changed for WordPress core files.

    I will look into it and include this solution which can work on all setup in our plugin.

    Thank you for your co-operation.

    Regards,
    Chetna Bhutka

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin creates lots of PHP error log messages for cron job’ is closed to new replies.