PHP 8.5 Switched display_errors Back On. Here's Why

A PHP version bump in cPanel quietly switched display_errors back on for a live Joomla site, even though every config file I could see said it was off. Here's what happened and how to stop it happening to you.

The symptom

After moving the site to PHP 8.5 in cPanel's PHP Selector, PHP warnings and deprecation notices started appearing in the browser. That's bad: it leaks file paths and internals to visitors, and it looks awful.

The odd part was that nothing had been changed to turn errors on. The .user.ini and php.ini in the web root both contained display_errors = Off, and Joomla's own Error Reporting setting was set to None.

The gotcha

On CloudLinux hosting, PHP Selector doesn't use the php.ini or .user.ini in your web root at all. Each PHP version loads its own global php.ini plus a small per-account options file, and that's it.

The 8.5 build on my host has no display_errors line in its global php.ini. When the directive is missing, PHP falls back to its compiled-in default, which is On. Any override you had set in the Options tab for the previous version doesn't carry across, because those options are stored per version. So the moment the version changed, errors went live.

<?php
header('Content-Type: text/plain');
echo 'display_errors=', var_export(ini_get('display_errors'), true), "\n";
echo 'loaded=', php_ini_loaded_file(), "\n";
echo 'scanned=', php_ini_scanned_files(), "\n";

Drop that in the web root, load it in a browser, then delete it. The loaded and scanned lines tell you which ini files are really in play. In my case neither was in the web root.

The fix

Two places, and I'd suggest you do both.

  1. PHP Selector, Options tab. Set display_errors to Off and log_errors to On for the version you're running. Remember to do it again whenever you change version.
  2. .htaccess in the web root. LiteSpeed honours php_flag and php_value, and this survives a version switch:
php_flag display_errors Off
php_flag display_startup_errors Off
php_flag log_errors On
php_value error_log /home/youraccount/public_html/error_log

Re-run the probe afterwards to confirm, then remove it.

Takeaway

Changing PHP version on a PHP Selector host resets more than you'd expect. After any switch, check the effective values rather than the config files, and keep a belt-and-braces override in .htaccess so the next upgrade can't surprise you.