Next Gen 3.55 problem on Windows Server
-
I recently updated NextGenGallery plugin to version 3.55 and started getting error messages in plugins/nextgen-gallery/src/Display/View.php indicating that the template could not be found. Basically the code was constructing an absolute pathname by prefixing the template name with a path that already existed in the template similar to this (D:\Home\ApacheRoot\workshop\httpdocs\wp-content\plugins\nextgen-gallery\templates\D:\Home\ApacheRoot\workshop\httpdocs\wp-content\plugins\nextgen-gallery…)
The error occurred in the find_template_abspath() function, but the root cause occurs in function get_template_abspath() on thw first line below:
if ( 0 === strpos( $template, DIRECTORY_SEPARATOR ) ) { // $value is an absolute path, but it must be validated first if ( ! $this->is_valid_template_filename( $template ) || ! @file_exists( $template ) ) { $display_name = esc_html( $template ); throw new \RuntimeException( esc_html( $display_name ) . ' is not a valid MVC template' ); } } else { $template = $this->find_template_abspath( $template, $legacy_template_path ); }
The assumption is that the first character being a DIRECTORY_SEPARATOR (ie. /) indicates an absolute path is only true for linux… on Windows the path could start with a driver letter and colon (e.g. D:) and so you should also test for either / first or : colon in the path.
The wrong assumption means the find_template_abspath() is called instead of is_valid_template_filename().
There is also a secondary isse in the find_template_abspath() function where .php is prefixed to the template/legacy template name, but there is no test to determine if the template already includes .php and so template names with .php.php can be created. The use of rtrim($legacy, ‘.php’) before adding the .php suffix would resolve this problem.
Please can you update the plugin to handle operation on Windows as these assumptions may cause other functionality to fail.
- The topic ‘Next Gen 3.55 problem on Windows Server’ is closed to new replies.