wpengine / phpcompat

WordPress Plugin: PHP Compatibility Checker
https://wordpress.org/plugins/php-compatibility-checker/
121 stars 38 forks source link

Directory path is missing slashes, causing uncaught exception and scan failure. #201

Open johnalarcon opened 6 years ago

johnalarcon commented 6 years ago

Works on live HTTP, but not on my localhost; missing slashes are causing an uncaught exception. The plugin skipped everything as too large to be scanned, even a 10 line dummy plugin. WP-cron is working fine. PHP ini values are more than generous. Error log shows the following (et al) for each plugin scanned. Never got around to doing the themes; killed the process after about a half hour and getting through less than 10 plugins. See the error at the end below... all the slashes are missing from the plugin path. I'm on Windows 10, XAMPP, PHP 7.2.3, Compatibility Checker 1.4.6.

[php7:notice] WPE PHP Compatibility: startScan: , referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: timeout: 60, referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: lock: 1, referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: scan status: , referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: Generating directory list., referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: 15 plugins left to process., referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: Processing: AAA Master, referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:notice] WPE PHP Compatibility: Attempted scan count: 1, referer: https://localhost/wp/wp-admin/admin-ajax.php?action=wpephpcompat_start_test [php7:error] Uncaught PHP_CodeSniffer_Exception: Source file C:xampphtdocswpwp-contentpluginsaaa-master/ does not exist in.....

nuessgens commented 6 years ago

Having exact the same issue. Ironically I created a local WAMP installation because of the following recommendation (from the Plugin-Site)

The best way around this timeout issue is to run this plugin on a local copy of your site

Is this still the same issue as #128 reported over one and a half years ago?

nuessgens commented 6 years ago

Almost forgot: I fixed it locally by modifiying the method that inserts the plugin-paths (that will be analyzed) into the database. I simply replaced the windows path-seperator (backslashes) with unix (slash)

If anyone is interested Replace this block: https://github.com/wpengine/phpcompat/blob/dc72e59f71e9bcc272b64cd874647243fa2bbd1d/src/wpephpcompat.php#L464-L474 by

    private function add_directory( $name, $path ) {
        $tpath = str_replace("\\","/", $path);
        $dir = array(
            'post_title'   => $name,
            'post_content' => $tpath,
            'post_status'  => 'publish',
            'post_author'  => 1,
            'post_type'    => 'wpephpcompat_jobs',
        );

        return wp_insert_post( $dir );
    }

The file is located ${wp_dir}\wp-content\plugins\php-compatibility-checker\src\wpephpcompat.php

bobbingwide commented 5 years ago

Same problem. Will try the recommended fix.