Wonolog icon indicating copy to clipboard operation
Wonolog copied to clipboard

[Bug]: PHP 8.1 PHP Deprecated: Constant Inpsyde\Wonolog\Data\FILTER_SANITIZE_STRING is deprecated

Open thefrosty opened this issue 2 years ago • 3 comments

Description of the bug

Using FILTER_SANITIZE_STRING is deprecated in PHP 8.1.

PHP Deprecated:  Constant Inpsyde\Wonolog\Data\FILTER_SANITIZE_STRING is deprecated in /usr/local/wordpress/vendor/inpsyde/wonolog/src/PhpErrorController.php on line 100

Reproduction instructions

Install PHP 8.1, and turn on WP_DEBUG, note logs after logging in a traversing the admin core pages.

Expected behavior

No deprecation notices.

Environment info

  • Wonolog ^1.0
  • WordPress 6.0
  • PHP 8.1

Relevant log output

No response

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

thefrosty avatar Jun 22 '22 14:06 thefrosty

@thefrosty we have a couple of lefotover instances of that string in v2, because PHP did not provide a replacement for it :(, and so we need to refactor https://github.com/inpsyde/Wonolog/blob/2.x/src/Data/Log.php

I will fix them in v2, but likely not in in v1

gmazzap avatar Jun 24 '22 10:06 gmazzap

That's fine, I wasn't aware of a v2, would love to see a beta or alpha tag to try out.

thefrosty avatar Jun 24 '22 15:06 thefrosty

@thefrosty The branch "2.x" is the alpha right now https://github.com/inpsyde/Wonolog/tree/2.x

And it needs testing :)

Docs: https://github.com/inpsyde/Wonolog/tree/2.x/docs are already updated

gmazzap avatar Jun 25 '22 14:06 gmazzap

Hello @gmazzap,

Any news regarding this issue ?

We are already using branch 2.x in production on a few projects, and it seems pretty much stable at this point, but we're still running them in PHP 8.0.

Now, with PHP 8.0 end of support coming before the end of the year, upgrade to 8.1 or 8.2 is becoming urgent.

I started to work on a PR a few weeks ago, but I didn't manage to have a strictly equivalent behavior with htmlspecialchars(), and I wasn't sure of the logic here, so I didn't achieve it..

Bests regards, Pierre

pierre-dargham avatar Feb 21 '23 13:02 pierre-dargham

Hi @pierre-dargham I should be able to fix this and release v2 in beta very soon.

gmazzap avatar Feb 28 '23 17:02 gmazzap

v2.0.0-beta.1 Should fix this already.

gmazzap avatar Mar 01 '23 01:03 gmazzap

v2 already tests in both unit and integration in all PHP version from 7.2 to 8.2. I'm closing this. If anyone has feedback, please share, thanks!

gmazzap avatar Mar 01 '23 01:03 gmazzap

@gmazzap We are looking to test Wonolog 2.x in order to fix these PHP 8 deprecations. I've looked through the docs, but cannot see any sort of upgrade guide. Does that mean Wonolog 2.x should be a drop-in replacement for Wonolog 1.x.

In other words - are there breaking changes we need to be aware of?

braders avatar Apr 20 '23 13:04 braders

@braders It's not a drop-in replacement.

As you know, Wonolog is very extensible and can do many things. The "basics" that you get out of the box are the same for v1 and v2.

But if you have extended v1 in some way, it might need adjustment to get the same extension work in v2, even if we tried to make it as much backward compatible as possible. But it is still a major version, so some breaking changes exist.

However, there're relevant changes in the configuration.

You right, we need to work on an upgrade guide, in the meantime if you tell me how you're configuring your v1 I can tell you the way to obtain same things in v2.

gmazzap avatar Apr 20 '23 19:04 gmazzap