• Resolved camya

    (@ecc)


    Hi,

    I have our Live-Site hosted on a Litespeed-Server. My Dev enviroment is set up with “Local by Flywheel” (nginx, MySQL, PHP 7.4.1) on a Windows 10 machine.

    Unfortunately it’s not possible, to activate the LiteSpeed Cache plugin here.

    The installation works without a problem, but the activation ends with an fatal:

    PHP Fatal error: Maximum execution time of 1200 seconds exceeded in C:\Users\ecc\Local Sites\the-dev-site\app\public\wp-content\plugins\litespeed-cache\src\htaccess.cls.php on line 197

    The config of the LOCAL server:

    • nginx/1.16.0
    • PHP 7.4.1
    • SSL is enabled
    • Windows 10
    • Local 5.4.1
    • This topic was modified 4 years, 6 months ago by camya.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    The error occurs due to this line of code

    if ( $start_path === '/' || ! $start_path ) {

    as it was not meant/designed for Windows file system , so when activates , it stuck on loop for searching htaccess on a non-existing path for Windows system.

    not sure if there is a quick fix, but please try change that line to

    if ( $start_path === 'C:\' || ! $start_path ) {

    and see how it goes.

    Best regards,

    Thread Starter camya

    (@ecc)

    Hi qtwrk,

    I found a bug in the _htaccess_search() method which could be fixed using wp_normalize_path(). After this fix, the plugin works on Windows systems.

    The _htaccess_search() function in LiteSpeed Cache tests, if the $star_path equals the $_SERVER[ ‘DOCUMENT_ROOT’ ]. Unfortunately the path separators are different for both paths on Windows systems. (Backslashes vs Slashes). The fix is to use the WordPress function wp_normalize_path(). This will normalize the paths and the condition will match.

    Code on Github (_htaccess_search() – Line 194)

    wp_normalize_path() modification:

    
    // 2020-05-15 - CAMYA - Normalize start_path and DOCUMENT_ROOT (Windows fix)
    if ( ! empty( $_SERVER[ 'DOCUMENT_ROOT' ] ) && wp_normalize_path($start_path) === wp_normalize_path($_SERVER[ 'DOCUMENT_ROOT' ]) ) {
        return false ;
    }

    Another problem is the root folder, if $_SERVER[ ‘DOCUMENT_ROOT’ ] is not set. I guess, the function is also used from the WP-CLI. (Haven’t checked this by now).
    My fix is to store the previous folder into a variable and check, if we reached the root folder. (old folder === new folder)

    Here the complete modification:

    private function _htaccess_search( $start_path )
    {
    	while ( ! file_exists( $start_path . '/.htaccess' ) ) {
    
    		if ( $start_path === '/' || ! $start_path) {
    			return false ;
    		}
    
    		// 2020-05-15 - CAMYA - Normalize start_path and DOCUMENT_ROOT (Windows fix)
    		if ( ! empty( $_SERVER[ 'DOCUMENT_ROOT' ] ) && wp_normalize_path($start_path) === wp_normalize_path($_SERVER[ 'DOCUMENT_ROOT' ]) ) {
    			return false ;
    		}
    
    		// 2020-05-15 - CAMYA - Set filesystem root check helper variable (Windows fix)
    		if (!isset($start_path_before)) {
    			$start_path_before = $start_path;
    		}
    
    		$start_path = dirname( $start_path ) ;
    
    		// 2020-05-15 - CAMYA - Is this the filesystem root folder? (Windows fix)
    		if ($start_path_before === $start_path) {
    			return false;
    		}
    		// 2020-05-15 - CAMYA - Update path (Windows fix)
    		$start_path_before = $start_path;
    
    	}
    
    	return $start_path ;
    }

    I hope, it’s possible to add the wp_normalize_path() in the near future, because this will make the plugin work for many more people.

    Best,
    Andreas

    • This reply was modified 4 years, 6 months ago by camya.
    Plugin Support Hai Zheng?

    (@hailite)

    Fixed in 3.1-rc3.

    Great thanks!

    Thread Starter camya

    (@ecc)

    Hi Hai,

    Great that you fixed it so rapidly.

    I just tested it and the activation of the Plugin now works also on Windows 10 / nginx / Local By Flywheel. Nice work.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Plugin activation not possible on “Local by Flywheel” (nginx)’ is closed to new replies.