Deprecated function
Deprecated function
dg_datatables
Posts: 56Questions: 11Answers: 1
A customer has been using Datatables 1.10 with the editor for almost 10 years. The PHP version has now been upgraded to PHP 8.2. I now receive a message about an outdated function in the "Format.php" file on line 66:
$date = \DateTime ($val);
Is there a workaround for this?
Thank you for your help.
This question has an accepted answers - jump to answer
Answers
Can you show me the error message please? I don't appear to be getting a warning about that call with PHP 8.2.
What version of the Editor PHP libraries are you using?
Allan
edit: I should say that old versions of the libraries do have some compatibility issues with PHP 8+, but the current release shouldn't have any issues.
The editor is 1.7.2 and this is the message:
'''PHP Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in \wwwroot\abw\libs\datatables\php\Editor\Format.php on line 68'''
Gosh yes, that's an old one (Jan 2018). The current version of the libraries don't have the issue you are seeing there - they specifically have a
null
check to address that.You could perhaps include that
null
check in the code you have, but I'd recommend updating the libraries to the latest version since 1.7 (or indeed all of 1.x) was never tested for PHP 8.x.Allan
Thanks for your help, this works!
But now i got the next error (as expected):
PHP Deprecated: DataTables\Vendor\Htmlaw::filter(): Implicitly marking parameter $config as nullable is deprecated, the explicit nullable type must be used instead in \wwwroot\abw\libs\datatables\php\Vendor\Htmlaw.php on line 69
Where can i found the updated libraries. I looked at "downloads" but i found only the new version, which needs a new licence.
Yup, I suspect there will be a number of errors that would need to be worked through to get the old libraries to work on PHP 8.x. You could can get the latest libraries from the github repo as they are open source. I haven't tested them with Editor 1.x at all though - that series is no longer supported.
Allan