Support » Plugin: UpdraftPlus: WordPress Backup & Migration Plugin » Error after upgrade to php 8.1 – PHP event: code E_DEPRECATED: DateTime:

  • Resolved sajtfokus

    (@sajtfokus)


    I’m getting this error after upgrade to PHP 8.1 version:

    PHP event: code E_DEPRECATED: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated (line 316, wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/functions.php) (Mar 10 21:19:53)

    Anyone knows what this is?

    • This topic was modified 2 years ago by sajtfokus.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author David Anderson

    (@davidanderson)

    You should report it to the support channel for that plugin, wp-mail-smtp . (N.B. WordPress doesn’t officially support PHP 8.1 yet, but plugin authors may still be grateful for information helping them to be ready).

    David

    Joe

    (@joewa1980)

    To fix this error before a new release addresses the issue in wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/functions.php change null to '' in line 310 as below. Removing the function entirely will cause a fatal error, so keep the function.

    Original line 310:
    function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) {

    New line 310:
    function as_get_datetime_object( $date_string = '', $timezone = 'UTC' ) {

    Plugin Author David Anderson

    (@davidanderson)

    A deprecation notice is not an error; deprecation is advance notice of something that will change in a future release of PHP, telling a programmer that he’ll need to make a change in order to be compatible with that future release. So the only thing you need to do is inform the programmer of that plugin and then you can forget about it. New PHP releases happen at the end of the year, and some deprecated items aren’t removed until new major versions (i.e. 9.0) which may be years away.

    Joe

    (@joewa1980)

    Yes indeed, a depreciation notice but if the user wishes to not have it trigger the notice in their error log they can fix it as above until a new release is presented, as mentioned. Hope it helps!

    Joe

    (@joewa1980)

    PS: I should add that this code change was given to the developer of the plugin prior to posting in this thread. Just hoping to help out @sajtfokus.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error after upgrade to php 8.1 – PHP event: code E_DEPRECATED: DateTime:’ is closed to new replies.