Joomla will not work on PHP v8

Joomla PHP Fix

With the release of PHP v8, we are aware of an issue with Joomla sites that make use of this newer version.

All of our servers have certain PHP functions disabled as they pose a security issue in a shared hosting environment. One of these is a function called ini_set which is used to override PHP core settings. This function would allow a user to change security restrictions, allocate more memory to their hosting account, etc and so for that reason we obviously have this disabled.

PHP v8 has some changes in how it handles any functions that are specifically disabled. In PHP prior to v8, it would log an error in your PHP error log and still proceed with running the script, therefore an instruction to raise the memory limit would just be ignored and it would carry onto the next step. In PHP v8 however, disabling a function actually removes it from the function table so the command no longer exists, therefore if a script tries to use it then instead of producing an error because it is blocked, the script stops because the command does not exist any more.

There is however a potential workaround for this issue in Joomla by adding a small piece of code to two of your index.php files. What this code does is define a new command (function) called ini_set which actually does nothing. This means that when Joomla calls the command ini_set to try and raise the memory limit, it instead runs your new empty function and carries on.

The code you require is as follows:

#PHP8 fix for ini_set being disabled
function ini_set() {
return;
}

Just add the above to the index.php in the public_html directory of your Joomla install, and again to the index.php within the /administrator folder.

The first ensures that visitors to your site can browse as normal.
The second ensures that you can reach the admin area of your site without error.

Please note: We have tested this on a fresh installation of Joomla 3.10.11, and 4.2.5.
This may not work in all cases as there may be additional elements of your specific website that conflict or otherwise cause errors.

 

NB: Our newer servers now have a workaround that does not require this customisation. We will happily migrate your account to a newer server on request - just open a support ticket requesting this.

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Moving your WordPress website to another folder

One of the common issues we see when customers install WordPress via Softaculous is that they...

WordPress will not work on PHP v8

With the release of PHP v8, we are aware of an issue with WordPress sites that make use this...