Latest update crashes the site

After updating to the latest s2member version (170524) my site crashed leaving only the following message:

Notice: Use of undefined constant DIR - assumed ‘DIR’ in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

Fatal error: require_once() [function.require]: Failed opening required ‘DIR/composer/autoload_real.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

The server is using php version 7.1.8. I flushed the OPCache, and found this in the debug.log file:

[29-May-2017 20:12:22] PHP Notice: Trying to get property of non-object in /home/fairfa9/public_html/wp-content/plugins/hide-title/dojo-digital-hide-title.php on line 127

[29-May-2017 20:17:39] PHP Notice: Use of undefined constant DIR - assumed ‘DIR’ in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:39] PHP Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:39] PHP Fatal error: require_once() [function.require]: Failed opening required ‘DIR/composer/autoload_real.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:45] PHP Notice: Trying to get property of non-object in /home/fairfa9/public_html/wp-content/plugins/hide-title/dojo-digital-hide-title.php on line 127

[29-May-2017 20:17:45] PHP Notice: Use of undefined constant DIR - assumed ‘DIR’ in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:45] PHP Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:45] PHP Fatal error: require_once() [function.require]: Failed opening required ‘DIR/composer/autoload_real.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:47] PHP Notice: Use of undefined constant DIR - assumed ‘DIR’ in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

[29-May-2017 20:17:47] PHP Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

I would appreciate any help. Thank you.

Bob

@connave I haven’t been able to reproduce this issue at all. Are you sure that error says DIR and not __DIR__? I just checked and there is no DIR in s2member/src/vendor/autoload.php on line 5. Here’s what that line looks like:

require_once __DIR__ . '/composer' . '/autoload_real.php';

__DIR__ is a predefined PHP constant, something that’s part of the PHP language itself.

Can you tell me which version of PHP you’re using?

Also, have you tried manually uninstalling and reinstalling s2Member? (You shouldn’t lose any configuration doing this, as the configuration data is safeguarded as long as you have s2Member → General Options → Plugin Deletion Safeguards enabled—it’s enabled by default, so unless you specifically disabled that, you should be safe to manually uninstall and reinstall s2Member). See also: https://s2member.com/updating/

I copied and pasted the error message but somehow all the underscores didn’t come through. I’ve pasted it again below and now it says DIR

The PHP version is 7.1.8

Yes, I’ve uninstalled and re-installed s2Member from a backup twice now. Still crashes.

Notice: Use of undefined constant DIR - assumed ‘DIR’ in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

Fatal error: require_once() [function.require]: Failed opening required ‘DIR/composer/autoload_real.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

For some reason the underscores are not traveling well, but rest assured they are all there in the error message I’m getting.

@connave writes…

The PHP version is 7.1.8

@connave reports…

Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /home/fairfa9/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

I suspect the PHP version is not 7.1.8 on the site running s2Member because the error about __DIR__ being an undefined constant should only occur on installations of PHP prior to PHP v5.3.2 where __DIR__ was in fact an undefined constant and '__DIR__' would be assumed.

See this article: http://php.net/manual/en/language.constants.predefined.php

5.3.0 Added __DIR__ and __NAMESPACE__ constants

@connave My suggestion is that you open a test file on the site where this occurs to verify the version of PHP being used for that specific site. If the PHP version is < 5.3.2, you can check with your hosting company about upgrading to a newer version and that should resolve this for you.

<?php
echo PHP_VERSION;

Thank you for the advice, it turns out the hosting service is running PHP
version 5.2.17. I’ll try to contact them to suggest they update.

Thank you
Bob

My installation of S2Member pro plugin disappeared and I cannot even run the framework

I am getting this error: Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home1/myinsus1/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

Fatal error: require_once() [function.require]: Failed opening required ‘DIR/composer/autoload_real.php’ (include_path=’.:/usr/share/pear:/usr/share/php’) in /home1/myinsus1/public_html/wp-content/plugins/s2member/src/vendor/autoload.php on line 5

Is this the same issue with the php version which according to the server scan it is telling me
Pass[PASS] PHP Version
You are currently running PHP 5.2.17 (which is fine). Minimum required version is: 5.2.

Is the server scan out of date?

@mpowered Yes, same issue. And yes, the scanner is outdated and needs improvement at the moment. The __DIR__ constant was generated automatically by Composer (a dependency and build tool we use). I was not aware that it was injecting __DIR__ instead of __FILE__ until this issue was raised. Since it is, we will need to raise the minimum requirement for s2Member to PHP 5.3.2 and update the scanner as well.

Referencing: https://github.com/websharks/s2member/issues/1102

Thank you for your help on this issue and bringing clarity to it… if I understand it correctly then, because the scanner told me that “You are currently running PHP 5.2.17 (which is fine). Minimum required version is: 5.2.” I should contact my hosting company and see about at least updating it to PHP 5.3.2 as the minimum instead. Correct?

Absolutely correct, yes. If you can get PHP 7+ I recommend it. In addition to resolving this problem, PHP 7 is way, way, way, faster. Which will make your entire site a little speedier for everyone that uses it.

Just got off the phone and they updated me to 5.4 and I just activated the plugin with no errors. Thank goodness, and of course thank YOU :slight_smile:

They told me that next year everything will be updated to 7 fyi…

Just my 2 cents, but I’d start looking for another hosting provider. They “updated” you from one unsupported version of PHP to another…

2 Likes

My site crashed when I tried to update and it has been determined that it is due to PHP version. Until that gets resolved. My question is: Will data be safe if I copy over the new files in the S2Member and S2Member Pro will earlier version that worked? Thanks is advance.

Overwriting the files will not touch your data. That said, you should delete the files and then re-upload rather than just copying over (just in case).

Thank you!

Kind regards,

Rose Caplan
404-435-0888

…let us work together to make that future a place we want to visit. Be
brave, be determined, overcome the odds. It can be done. ~Stephen Hawking