by David Snopek on October 8, 2018 - 4:45pm

If you haven't heard yet, PHP 5 will reach the end of its security support (from the upstream project) in December of this year.

During DrupalCon Baltimore we announced that we'd be updating Drupal 6 to work with PHP 7.2, and, in September, we announced that we'd be making a big push to get that live with a couple of our customers.

Finally, we have something to show for it! :-)

So far, we've only tested with a few sites, so I'm sure there's some additional issues and bugs we haven't encountered yet. But we have an initial release of Drupal core and some selected contrib modules that work with PHP 7.2 in our testing.

And all our work so far has been released back to the community!

Read more for the details :-)

Drupal core

The short version: We've released Drupal 6.45 with support for PHP 7.2

We've taken a particular approach with this:

  • We included a shim for the ereg() family of functions that were removed, rather than converting core to using preg_*() functions. This was done because contrib also uses those removed functions and this saves us from having to update many contrib modules.
  • In one or two cases, we modified Drupal core to maintain the PHP 5 behavior of its APIs if that behavior was depended on by "a lot" (subjective judgement) of contrib modules, again in order to have to update fewer contrib.
  • We made most of the updates recommended by the PHPCompatibility standard for phpcs
  • We tried to retain (and tested for) PHP 5.2+ compatibility, so that our Drupal core fork would continue to work for people who haven't updated yet. (If you're not aware of it, is a great tool for trying PHP snippets in lots of versions of PHP at once, and, well, we have a bunch of different PHP versions via Docker too.)
  • But otherwise, we've based our changes on actual manual testing and confirmed bugs, and tried to make the smallest possible change to fix each problem.

Important security note!

Drupal adds a .htaccess file to the public (ie. sites/default/files/) and temporary files directory to prevent PHP files that somehow end up there from being executable when using Apache.

However, this .htaccess file won't work with PHP 7 unless modified!

One way to do this, is to delete the .htaccess files and then visit the "Status report" on your site, which will re-create the file with the changes necessary for PHP 7.

We've considered adding an update hook to do this, but we're worried about wiping out any added changes - see the issue on GitHub and leave your thoughts.


You need a patched Drush 8 in order to work with PHP 7. See drush-ops/drush#3706 and you can grab the patch here.

The Drush maintainers seem open to committing this patch, so hopefully, this will make it into a Drush 8 release at some point. :-)

Selected contrib modules

Of course, the true power of Drupal is in it's contributed modules!

We're committed to updating the contrib modules used by our D6LTS customer to work with PHP 7.2.

That said, updating contrib (especially complex contrib) is a lot harder than Drupal core, so we expect this process to take us all the way to the end of the year.

Here's the contrib releases we've made so far:

There's also a number of contrib modules (generally the simpler ones) that work fine without any changes.

How to get involved!

If you're also working on getting your Drupal 6 site working on PHP 7, and you find any issues or bugs, you can write an issue on the project on GitHub or in the D6LTS queue on We appreciate the help and a number of people have contributed already - thanks! :-)

Or if you're interested in us doing this for you...

Sign up for Drupal 6 Long-Term Support!

Have you updated your Drupal site to PHP 7 already? How'd that go? Please leave a comment below!

Want to read more articles like this? blog Subscribe to the blog and recieve e-mail updates when new articles are published!


Hello guys,

Thank you for your work!

Here is patch for RealName module:

diff --git a/sites/all/modules/realname/ b/sites/all/modules/realname/
index 11db73e..db84028 100644
--- a/sites/all/modules/realname/
+++ b/sites/all/modules/realname/
@@ -10,7 +10,7 @@
* Field handler for realnames
class realname_handler_field_user_name_override extends views_handler_field_user_name {
- function init(&$view, &$data) {
+ function init(&$view, $data) {
parent::init($view, $data);
$this->additional_fields['uid'] = 'uid';

Thanks for sharing!

PHP 7.2 doesn't like the &= syntax - it's used somewhat rarely, but in particular the nusoap library uses it. grep for &= in all libraries/* and replace &= with =
Works great.

Hm, that isn't exactly right.

$a &= $b isn't the same as $a = $b, it's equivalent to $a = $a & $b. Although, perhaps that's what you meant?

I'm also not sure that it's accurate that PHP 7.2 doesn't like that syntax. I tested with numerous PHP versions via and got no complaints:

Hi, Views original latest version is 3.10. Will there be a PHP 7 version for Views 3.10 also be made? On this page I only see views 3.9. Thanks for this great work in advance!
greetings, Martijn

Both Views 6.x-3.9 and 6.x-3.10 are compatible with PHP 7! The PHP 7 support was originally added in 3.9, but those changes are still present in 3.10. Going forward we'll maintain PHP 7 compatibiliy for Views, so you can expect that future versions will be too (and if they're not it's a bug, which we'll fix if reported :-))

Add comment