2

I just transferred a Drupal 7 installation to Debian 9 and when I try to connect to the site I get the error PHP Fatal error: Cannot use "self" when no class scope is active in vars.module on line 39.

There is a Drupal issue on it Upgrade to PHP7: Cannot use "self" when no class scope is active [#2668622] , but it doesn't seem to be fully resolved and I am not sure which PHP7 version it works on.

The version of PHP currently on Debian 9 is PHP Version 7.0.27-0+deb9u1

The point is I am running the latest version (Drupal 7.59) on Ubuntu 16.04 whose PHP version is PHP Version 7.0.30-0ubuntu0.16.04.1 and it runs without that error.

Are there versions of PHP 7 running on Debian 9 which work with latest unpatched Drupal 7.59, perhaps later ones like PHP 7.1 or PHP 7.2?

Maybe the bug only manifests in early versions of PHP 7.

UPDATE: It turns out that vars.module is from the contrib module Variable API and not part of core, and was only enabled to support the Textile module. Disabling it solved the problem.

3

For the most part, Drupal 7 core is compatible with PHP 7, however in some cases you might run into issues, depending on your specific website's configuration.

There is a meta issue on drupal.org that you can follow at https://www.drupal.org/project/drupal/issues/2656548

In addition, although most of the widely used modules are, not all contributed modules are compatible yet. The issue you linked is for a contributed module, not Drupal core.

Your best bet is to test your site and its particular modules on a development PHP 7 environment and then resolve any issues you find. Once you're happy that the site is functioning as it should, update your PHP version on your production server.

In my personal experience, with at least a dozen Drupal 7 sites of varying sizes, I have had no issues with Drupal 7 on PHP 7.0 or 7.1 but I have had a few issues with 7.2 when it was new (which may have been resolved by now).

In some cases I have had to apply patches that were already available in issue queues, but generally I've only had to update modules to the latest versions.

3

I think what you see is exactly what the Drupal 7 php requirements warns about:

Because PHP 7 is the newest release, extra care should still be taken with it. See the Drupal 7.50 release notes and the PHP 7 discussion for more details. However anecdotal evidence from a variety of users suggests that Drupal 7 can be successfully used on PHP 7, both before and after the 7.50 release.

I personally have run Drupal sites that are currently live on php 7.0 and 7.1 latest versions and have never had a problem with server updating to newer php minor version at a later date.

Even though php 7 is not the latest (7.1 and 7.2 are out) you still have to be cautious running Drupal 7 with php 7.0 or 7.1 and extra care should be taken (from experience) at the contributed modules level as there is still lots of them not running properly on php 7. In most cases updating modules to latest releases is enough but in some cases compatibility patches can be found in the respective issue queues.

I believe Drupal 7 can't be run with php 7.2 as it has major changes from previous versions 7.0 and 7.1. At least I never succeeded in running it with 7.2 and I am not aware of any patches.

2

Drupal 7 development is about to reach PHP 7.2 compliance.

See this issue on drupal.org: Fully support PHP 7.2 in Drupal 7.

php 7.2 now passes all 7.x core tests

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.