- December 5, 2017 at 12:24 PM #55309
After updating Store Locator Plus to the latest version (4.9.1) it’s displaying a fatal error on my site.
Fatal error: Class 'SLP_REST_Handler' not found in /var/www/vhosts/domain.com/wp-content/plugins/store-locator-le/include/SLPlus.php on line 401
I actually found a fix to this, which involves adding the following to line 5 of
require_once( SLPLUS_PLUGINDIR . 'include/module/REST/SLP_REST_Handler.php' );
Still, each update re-breaks this, and means I need to re-patch. Can we expect this to be resolved in the next release to prevent this cycle?December 5, 2017 at 4:37 PM #55324
Holly, Are you using Windows?
And which versions of WP?December 6, 2017 at 3:38 PM #55361
No, we’re not running Windows. Our server is CentOS 6.5.
Wordpress 4.9December 6, 2017 at 3:51 PM #55362
CiciKeymasterDecember 6, 2017 at 4:32 PM #55368
The require is no longer be necessary at SLP 4.9 uses PHP’s autoload.
1) Check your install
Can you verify that in your plugins directory the path under store-locator-le is /include/module/rest/ (lowercase) if not then something is not allowing your normal plugin install to execute normally.
The CORRECT path is a lowercase REST. If it is uppercase then autoload will not work.
A normal plugin install should be clearing the entire store-locator-le (Store Locator Plus) plugin directory on an update so any uppercase REST directory should no longer exist.
2) If the path is correct you can help me by adding some debugging on your install
Since you know how to edit code can you enable the WP_DEBUG log in your wp-config.php file and on line 100 add these 2 things and let me know what shows up in your log file:
error_log( ‘SLP->dir: ‘ . $this->dir );
error_log( ‘SLPLUS_PLUGINDIR: ‘ . SLPLUS_PLUGINDIR );
They SHOULD output the same thing. If it does then something special is going on with your server to prevent autoload in SLP 4.9 from working properly.
PHP’s autload will load the file from the correct directory UNLESS something else , another plugin or your theme is break PHP’s autoload functionality. Something that is easy to do if a plugin author does not check that the autoloaded object belongs to them BEFORE executing their own autload function. WordPress Core uses autoload , with the proper control structure, as do several other major plugins so the methodology is sound as long as every piece of your installation does it properly.
3) If all these things check out the only thing I can think of is you have opCache (or another PHP object cache) running on your site, but given the line number of your error message that doesn’t appear to be the case.December 6, 2017 at 6:05 PM #55383
The rest directory is indeed lowercase, so no issues with install / update.
I added the two debug lines to wp-config.php, but that produces another fatal error:
Fatal error: Using $this when not in object context in /Users/username/Sites/venv/project/wp-config.php on line 96
As far as I know, we’re not using opCache (I inherited this codebase). Knowing about autoload is useful for debugging – I can take a look to see if that leads me to any clues – but let me know if you have any other advice on how to approach.
Also attaching the plugin environment.
- This reply was modified 7 months, 2 weeks ago by Holly.
Attachments:You must be logged in to view attached files.December 8, 2017 at 2:16 PM #55449
Sorry – those debugging lines do not go in wp-config.php – that was not clear.
Add these 2 lines right above the line that originally caused the error: store-locator-le/include/SLPlus.php on line 401
If you are not using opCache and it is a lowercase directory (Linux/Unix doesn’t care about file/directory case sensitivity but our autoload does which is why lowercase is important) then I’m guessing something is causing $this->dir and SLPLUS_PLUGINDIR to not be set the same way.
If you can add those lines and let me know when the debug.log is on your site (or you can attach it again here) it will tell me if that theory is correct.
Something on your specific configuration or server setup is messing with how our autoload works, but it is odd it is only affecting the REST file. A LOT of things in the SLP 4.9 release use autoload now as it is cleaner, faster, and easier to maintain over item (less security holes and breaking things between releases, which I’m sure everyone will like). Why it only seems to impact the REST file on your setup is odd. 😕
You must be logged in to reply to this topic.