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

PHP 8.1 Deprecated messages #466

Open
aglipanci opened this issue Dec 6, 2021 · 7 comments
Open

PHP 8.1 Deprecated messages #466

aglipanci opened this issue Dec 6, 2021 · 7 comments
Labels
backlog We hope to fix this feature/bug in the future bug Confirmed bug

Comments

@aglipanci
Copy link

PHP 8.1 Deprecated messages

PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /var/www/html/vendor/bugsnag/bugsnag/src/Configuration.php on line 362

Steps to reproduce

  1. Install latest version of Laravel using PHP 8.1
  2. Install the latest version of Bugsnag for Laravel
  3. Enable error logs

Environment

  • Bugsnag version: 2.22.2
  • PHP version: 8.1
  • Composer version: 2.1.9
  • Laravel version: 8.74.0
  • Lumen version (if any):
@mattdyoung
Copy link

Thanks! We'll take a look.

@mattdyoung mattdyoung added backlog We hope to fix this feature/bug in the future bug Confirmed bug labels Dec 6, 2021
@niladam
Copy link

niladam commented Dec 20, 2021

I did some investigations and it appears the issue appears on line #362 (where @aglipanci also said) but after fixing that, it appears again on line #320.

So the issue appears to be something that's PHP 8.1 related as the $subject no longer accepts null as a parameter.

So the quickfix would be to just replace null with '' or "" (empty string); This should work on PHP < 8.1 as well :)

So basically just replace (line 362):

if ($stripPathRegex && @preg_match($stripPathRegex, null) === false) {

with

if ($stripPathRegex && @preg_match($stripPathRegex, '') === false) {

AND (line 320)

if ($projectRootRegex && @preg_match($projectRootRegex, null) === false) {

with

if ($projectRootRegex && @preg_match($projectRootRegex, '') === false) {

@indigoram89
Copy link

Any ideas??

@indigoram89
Copy link

Thanks! We'll take a look.

Can you fix it at last?

@GrahamCampbell
Copy link
Contributor

I'll take a look. I think this should be an easy fix.

@imjoehaines
Copy link
Contributor

I haven't been able to reproduce this in a new Laravel project, other than in the artisan tinker REPL. This is caused by PsySH (the library used to provide the REPL) not respecting the error suppression operator, which is used in both lines highlighted in this issue. I've opened an issue there to track this, but it's a tricky problem to solve: bobthecow/psysh#702

We will fix this specific deprecation, but that doesn't solve the whole issue. The reason we're using the error suppression operator is to suppress warnings that may be raised when passing an invalid regex to preg_match: https://3v4l.org/ZGeLF. Therefore even after the deprecation is fixed, you could still see warnings coming from that line, but they should never be visible because of the @ operator

Can you confirm if the Tinker REPL where you're seeing these deprecations? If not, it'd be useful to know what is logging them because it will be caused by a bug in an error handler. Laravel's error handler does handle this correctly, so it's likely to be a third party package rather than Laravel directly

@GrahamCampbell
Copy link
Contributor

It depends on your default error level. In any case, we should not calling code in a deprecated way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog We hope to fix this feature/bug in the future bug Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants