autoptimize
autoptimize copied to clipboard
Deprecation warning in jsmin.php
PHP Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /var/www/naturfuehrer/wordpress/wp-content/plugins/autoptimize/classes/external/php/jsmin.php on line 390
The reason seems to be that JSMin::get()
method despite having @return string
signature...
https://github.com/futtta/autoptimize/blob/67c3e531ab3c3aeebb62e6ac0fd42665bceadf28/classes/external/php/jsmin.php#L319-L325
...can actually return null
as well:
https://github.com/futtta/autoptimize/blob/67c3e531ab3c3aeebb62e6ac0fd42665bceadf28/classes/external/php/jsmin.php#L338-L340
EDIT: I was too quick... There is another path that returns null
in this method (and triggers the warning above):
https://github.com/futtta/autoptimize/blob/67c3e531ab3c3aeebb62e6ac0fd42665bceadf28/classes/external/php/jsmin.php#L329-L337
can you confirm this fixes the deprecation warning @chesio ?
can you confirm this fixes the deprecation warning @chesio ?
@futtta Unfortunately, it does not. This fix is incomplete, it has been reported in upstream repo as well: https://github.com/mrclay/jsmin-php/issues/16
Would it make sense to update the whole library? It seems Autoptimize bundles version 2.3.2, while upstream has 2.4.3 as most recent: https://github.com/mrclay/jsmin-php/blob/master/CHANGELOG.md
made a small tweak to the current version, can you re-test @chesio
some of the changes in 2.4.3 are already in "my" version (which is different from the original 2.3.2), but it might indeed be time to go to the latest JSmin version. :-)
@futtta I apologize, I should have been more explicit in my previous comments.
While the patch prevents one possible source of the deprecation message it does not fix the problem I reported, because JSMin::get()
can still return null
. The deprecation notice I am seeing is triggered here:
https://github.com/futtta/autoptimize/blob/67c3e531ab3c3aeebb62e6ac0fd42665bceadf28/classes/external/php/jsmin.php#L388-L390
On line 388 JSMin::get()
returns null
, on line 390 this null
value is passed to ord()
.
As far as I can tell, this has been fixed upstream in https://github.com/mrclay/jsmin-php/commit/a688631f0595ef66436060f545cd13f1a04e674a The fix does not prevent null
being returned from JSMin::get()
, but fixes all code handling the returned value to expect null
as well.
arghhhh ... no use in trying put band-aids on the old code, I'll have to bite the bullet. more soon :)
reopening so we can test ;-)
@chesio had to make some small tweaks, but this is 99% of jsmin.php, can you test to confirm this fixes the issues you were facing?
@futtta Sorry for keeping you waiting so long. I have now tested the beta branch and I don't get the deprecation warnings anymore! 👍