Skip to content

Conversation

@iquito
Copy link
Contributor

@iquito iquito commented Dec 14, 2025

Change the one usage of ord() in Twig where a multibyte character can trigger the new deprecation in PHP 8.5, which is in the html_attr escape functionality in EscaperRuntime, currently leading to:

ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead"

This small change fixes it. There are no other usages of ord() in Twig which lead to this deprecation notice.

Change the one usage of ord() in Twig where a multibyte character can trigger the new deprecation in PHP 8.5, which is in the `html_attr` escape functionality, previously leading to:

ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead"
@iquito iquito changed the title Avoid ord deprecation in PHP 8.5 Avoid ord deprecation notice in PHP 8.5 Dec 14, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a PHP 8.5 deprecation warning by updating the ord() function call in the html_attr escaping strategy to explicitly access the first byte of the string using array notation.

  • Fixes PHP 8.5 deprecation warning when ord() receives multibyte characters
  • Changes \ord($chr) to \ord($chr[0]) in the html_attr escaper callback
  • Maintains backward compatibility while preparing for PHP 8.5+

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fabpot
Copy link
Contributor

fabpot commented Dec 14, 2025

Thank you @iquito.

@fabpot fabpot merged commit cf87925 into twigphp:3.x Dec 14, 2025
43 of 47 checks passed
@iquito
Copy link
Contributor Author

iquito commented Dec 15, 2025

@fabpot I saw you released a new version, but only twig/extra-bundle is available as a new version on packagist. Maybe because some of the Github workflows didn't succeed?

@iquito iquito deleted the patch-1 branch December 15, 2025 08:51
@stof
Copy link
Member

stof commented Dec 15, 2025

@iquito for patch releases, the splitter creates tags only for subtree repos that have changed since the previous release. That's expected.

@xabbuh
Copy link
Contributor

xabbuh commented Dec 15, 2025

@stof The issue is that this PR touched a file from the twig/twig package, the tag was also created (see https://github.com/twigphp/Twig/releases/tag/v3.22.2) but it is not listed on Packagist: https://packagist.org/packages/twig/twig

@iquito
Copy link
Contributor Author

iquito commented Dec 15, 2025

It might also be a Packagist issue, I am not sure, but I thought it might be worth it to find out why there is no new release.

@stof
Copy link
Member

stof commented Dec 15, 2025

@fabpot could you check the github webhook setup ?

packagist.org was showing the last update date of twig/twig on November 30th until I clicked the "Update now" button (which made the 3.22.2 tag appear)

@fabpot
Copy link
Contributor

fabpot commented Dec 15, 2025

Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants