Littera Nova

I write things sometimes.

phpBB 3.0 and PHP 7 Compatability

Word count: 324 (~2 minutes), Last modified: Sun, 29 Dec 2019 01:05:05 GMT

So, your webhost finally upgraded to PHP 7. Your site might runs faster (and more securely), but your ├╝ber-customized phpBB 3.0 forum which has served you and your pals so well all these years is complaining about preg_replace_callback. What 's up with that? As it turns out, the method that phpBB used to implement BBCode for a long time required a language feature called eval. eval lets a program inject additional code at runtime, which while powerful, is slow and often causes security vulnerabilities. After nine whole years of having the particular eval technique used in phpBB deprecated, PHP 7 finally lowered the /e flag on preg_replace function, to the consternation of upgrade-averse forum owners everywhere: this broke BBcode and links for your forum, rendering history unreachable!. So, how do you fix your broken forum? I can't say that this is the safest option, nor the cleanest, but it's one that worked for me.

Let's go!

  1. Whenever you're editing a piece of software, you should make backups. While this should be nondestructive, make copies of files that you edit before saving over them.
  2. Head on over to the phpBB GitHub. On this page, you'll see several sets of changes to files listed. Apply these changes to the files on your system, adding the lines with the "+" before them and removing the ones with the "-" (this is a "patch").
  3. Most likely, you'll also need a patch for includes/functions_content.php. I've written a straightforward one available for download on my patch download server. You should replace the entire make_clickable (not make_clickable_callable) function (probably lines 634-688 of functions_content.php) with the new one. Replace lines up until
    * Censoring
    : if you've gone past this, you've deleted too much.

That's it! If you had to do something else to fix your site, shoot me an email and I'll update this post. Good luck, and consider upgrading to a newer phpBB!