Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made an implicit float to integer conversion explicit to fix PHP 8.2 deprecation warning #301

Merged

Conversation

justinmaurerdotdev
Copy link
Contributor

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

Fixed - minor deprecation warning about implicit float to int conversion

Credits

Props @justinmaurerdotdev

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

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)
----------------------------------------------------------------------

@jeffpaul jeffpaul added this to the 2.2.0 milestone Jan 2, 2024
@jeffpaul jeffpaul mentioned this pull request Jan 2, 2024
4 tasks
Copy link
Member

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @justinmaurerdotdev. LGTM 🚀

@iamdharmesh iamdharmesh merged commit 2c8b9e4 into 10up:develop Jan 3, 2024
12 checks passed
@justinmaurerdotdev
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants