Hi all.
After I upgrade php5.6 to php7.0, an error occurred :
PHP Fatal error: Cannot use "self" when no class scope is active in /var/www/html/sites/all/modules/vars/vars.module on line 39
( I did not modify php.ini and php-fpm.conf) , WEB server is nginx + fastcgi.
How to fix it? thanks.

CommentFileSizeAuthor
#3 upgrade_to_php7_cannot-2668622-3.patch454 bytesheddn

Comments

iVanilla created an issue. See original summary.

giorgio79’s picture

Changing

   if ($default->flags & self::VARS_DYNAMIC) {

to

   if ($default->flags & Vars::VARS_DYNAMIC) {

seems to have worked.

heddn’s picture

Status: Active » Needs review
StatusFileSize
new454 bytes

I've also ran php7cc against the project to confirm there are no other php 7 bugs (or at least nothing discoverable via that method).

fonant’s picture

I can confirm that patch #3 fixes the problem with PHP 7 for me.

gaurav.kapoor’s picture

Issue tags: +Need tests
farnoosh’s picture

Changing self to Vars worked for me. Thanks

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Fixes the issues for me too, marking it RTBC.

FYI the branch tests are failing, once they're fixed it'll be easy to confirm if the fix changes anything by running the branch tests against PHP 5.6 and then again against PHP 7.x, in theory the branch should fail on PHP 7.x but work with the patch.

gaurav.kapoor’s picture

@DamienMcKenna didn't exactly get your suggestion.Should i commit this one or fix the test cases first?

damienmckenna’s picture

Sorry for being unclear. her'es what I'd suggest:

  • Fix the branch tests against PHP 5.6.
  • Run the branch tests against PHP 7.0 / PHP 7.1, which should confirm this bug exists.
  • Rerun the tests for this patch against PHP 5.6 (to ensure no regressions) and then against PHP 7 to confirm that it fixes the problem.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: upgrade_to_php7_cannot-2668622-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.