Deprecation notices with SilverStripe 4.13 and PHP 8.2 on a dev environment

Silverstripe Version: 4.13.0

Question:

Hi,
I upgraded the version of PHP from 7.4 to 8.2 right after upgrading SilverStripe from recipe 4.12.0 to 4.13.0. I am having deprecation errors, which prevents me from accessing the CMS console. This is one such error:

# [Deprecated] Callables of the form [“Swift_MailTransport”, “Swift_Transport_MailTransport::__construct”] are deprecated

I haven’t been able to prevent deprecation notices from being displayed even when “display_errors” is off in the PHP settings or in the application configuration. I’m wondering if

This a dev environment so it’s not so dramatic, but it actually prevents me from working on my website.

Does anyone have an idea of how I could solve this knowing that the package at hand (Swiftmailer) is required by silverstripe/framework? Thanks.

Silverstripe CMS 4.x is not supported with PHP 8.2. If you want to use PHP 8.2 I recommend updating to Silverstripe CMS 5.x.

You can turn off PHP deprecation warnings via the php.ini configuration file, if you understand and accept the risk of using deprecated code.

Edit: See https://www.slingacademy.com/article/php-enable-disable-warnings-notices for some ways to disable PHP deprecation warnings.

Alright, understood. Two pieces of information though:

  1. The error reporting is enforced in silverstripe/framework, in BaseKernel.php, meaning that SilverStripe has the last word regarding the configuration of deprecation notices. One has to modify this.
  2. Once silverstripe/recipe-cms is upgraded to 4.13.0, composer threw a warning that one of my dependencies required a PHP version >=8 but didn’t say which.

I ended up reverting to SS 4.12.0 and PHP 7.4 due to the PHP 8 module not loading in Apache on my CentOS 7 server as I plan to have upgraded to SilverStripe 5.x in two months.

Many thanks for answering me.

The error reporting is enforced in silverstripe/framework, in BaseKernel.php, meaning that SilverStripe has the last word regarding the configuration of deprecation notices. One has to modify this.

In that case you will probably want to use something like this in your _config.php file:

// limited to fatal errors and warnings in live mode
error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT | E_NOTICE));

That’s what BaseKernel does for live mode, as well.

Once silverstripe/recipe-cms is upgraded to 4.13.0, composer threw a warning that one of my dependencies required a PHP version >=8 but didn’t say which.

>= 8 does not mean 8.2. You should be able to use PHP 8.0 and 8.1 without any deprecation warnings.

I ended up reverting to SS 4.12.0 and PHP 7.4 due to the PHP 8 module not loading in Apache on my CentOS 7 server as I plan to have upgraded to SilverStripe 5.x in two months.

If this is for local development, I highly recommend giving DDEV a try.