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

Dependency on Psr/log breaks sites using different versions #490

Closed
2 tasks done
rmilesson opened this issue Jun 14, 2022 · 7 comments · May be fixed by #541
Closed
2 tasks done

Dependency on Psr/log breaks sites using different versions #490

rmilesson opened this issue Jun 14, 2022 · 7 comments · May be fixed by #541
Labels

Comments

@rmilesson
Copy link

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the plugin and it is still present.

WordPress version

6.0

Cloudflare-WordPress version

4.10.1

PHP version

8

Expected result

A fatal error should not occur.

Actual result

A fatal error with the following message occurs.

Fatal error: Declaration of Psr\Log\NullLogger::log($level, Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::log($level, $message, array $context = []) in /app/public/wp-content/themes/site.tld/vendor/psr/log/src/NullLogger.php on line 26

Steps to reproduce

  1. Install 4.10.1 version of Cloudflare for WordPress.
  2. Create a theme which depends on and uses Psr/log 3.0.0

Additional factoids

No response

References

A similar issue has occured and has been dealt with in #445.

@jacobbednarz
Copy link
Member

duplicate of #470

@rmilesson
Copy link
Author

Altough I agree that it would fix this issue, I also think it's a short-sighted fix. Would it be possible to do some namespace scoping with Mozart or PHP-Scoper instead?

@jacobbednarz
Copy link
Member

I'm yet to find an example of either of these projects where it doesn't a) increase release/maintenance burden or b) impact local development/testing. right now, this isn't enough of an issue to warrant introducing a higher barrier to running and maintaining this plugin.

if we can find a solution to those, I'm open to the possibility.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@graham73may
Copy link

@jacobbednarz I've run in to exactly this dependency issue just now.

It seems Psr/Log can't be updated to maintain PHP 7 compatibility, so namespacing your use of it might be the only option left?

Would you accept a PR adding Mozart and adding a namespace?

@graham73may
Copy link

Just to add incase this is helpful for anyone else, check what versions your other packages accept, you might get lucky.

In my case, I'm installing chrome-php, this allows: "psr/log": "^1.1 || ^2.0 || ^3.0"

Before:

{
  "require": {
	"chrome-php/chrome": "^1.9"
  }
}

After:
Force it to use v1, to match the Cloudflare plugin:

{
  "require": {
	"chrome-php/chrome": "^1.9",
	"psr/log": "^1.0"
  }
}

@dalepgrant
Copy link

@jacobbednarz Hi 👋 , adding another voice here, we're experiencing this issue with all sites built using roots/acorn as they're requiring psr/log v3 (link to their docs on compatibility).

Totally understand the need to keep a WP plugin supporting 7.4 and you're not alone in this dependency conflict (same issue reported to WPML for example), however it seems this issue will grow the longer it's left. Is #541 an option? If not (or better: to prevent similar issues in future), is it time to reconsider namespacing?

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

Successfully merging a pull request may close this issue.

4 participants