The string replacement was based on a calculation of half of the URL's length. When that length is an odd number, the substr_replace function was getting a decimal instead of an integer, which throws a deprecation warning about "implicit float to int conversion" in PHP 8.2.
How to test the Change
The staging handling for autopost functionality should still work, and the warning about a site change being detected should be displayed in the dashboard while working on staging or development environments.
Changelog Entry
Fixed - minor deprecation warning about implicit float to int conversion
I was not able to get my tests to pass because of this error in the phpcs pre-commit process:
----------------------------------------------------------------------
1 | ERROR | An error occurred during processing; checking has been
| | aborted. The error message was: trim(): Passing null to
| | parameter #1 ($string) of type string is deprecated in
| | .../wp-content/plugins/autoshare-for-twitter/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php
| | on line 280 (Internal.Exception)
----------------------------------------------------------------------
Happy to help. Sorry I didn't catch those easy syntax issues. Not sure why PHPCS decided to error instead of tell me about them... Anyway, thanks for getting this merged, and for the new release!
Description of the Change
The string replacement was based on a calculation of half of the URL's length. When that length is an odd number, the
substr_replace
function was getting a decimal instead of an integer, which throws a deprecation warning about "implicit float to int conversion" in PHP 8.2.How to test the Change
The staging handling for autopost functionality should still work, and the warning about a site change being detected should be displayed in the dashboard while working on staging or development environments.
Changelog Entry
Credits
Props @justinmaurerdotdev
Checklist:
I was not able to get my tests to pass because of this error in the
phpcs
pre-commit process: