spatie / wordpress-ray

Debug with Ray to fix problems faster in WordPress apps
https://myray.app
MIT License
73 stars 14 forks source link

Conflict with other plugins using jean85/pretty-package-versions #45

Closed N-Molham closed 1 year ago

N-Molham commented 3 years ago

Describe the bug An OutOfBoundsException exception get throws while loading my WordPress plugin which has Sentry SDK which in turns has jean85/pretty-package-versions as dependency.

Versions Ray plugin version 1.3.2

PHP version: 7.4

To Reproduce Steps to reproduce the behavior:

  1. Create a dummy plugin with composer dependency of composer require sentry/sdk
  2. Make sure the dummy plugin initialize Sentry upon plugins_loaded action hook
    add_action('plugins_loaded', function() {
    Sentry\init(...)
    });
  3. Install and activate Ray's plugin
  4. Activate the dummy plugin
  5. You should see a OutOfBoundsException when Sentry trying to check the installed SDK version.

Expected behavior When a plugin has jean85/pretty-package-versions it should not conflict with Ray's plugin and cause an exception

Screenshots The screenshot is from Ray app which helped me debug the problem (well done) image

Desktop (please complete the following information):

freekmurze commented 3 years ago

I've not come across this one myself. I'd accept a PR that fixes this.

N-Molham commented 3 years ago

@freekmurze I am not sure what is the fix ... did you try to replicate it?

freekmurze commented 2 years ago

Unfortunately I don't know how to fix this. This has something to do in the exotic way Composer is being used in WordPress.

I welcome a PR that fixes this by someone who is more knowledgable than me about the Wordpress internals.

jmslbam commented 2 years ago

When multiple plugin include the same packages, with with different versions, then issues may arrise.

In theory, this could also happen to Drupal or whatever platform that doesn't have 1 central composer.json, but loads PHP package by them self, if I'm correct.

I know some projects that have a solution to wrap all third party packages in their own namespace to prevent conflicts like this. E.g https://github.com/coenjacobs/mozart or https://github.com/humbug/php-scoper (see https://github.com/Yoast/wordpress-seo/blob/trunk/composer.json#L109-L120)

So I think the conflict / solution lies in both plugins and it's more of an architectural thingy with composer and platforms like WordPress that don't have 1 central package manager for all the code.

Kind regards,

Jaime

jeffreyvr commented 2 years ago

@jmslbam That's exactly why this plugin uses PHP Scoper. I believe Yoast SEO uses this too.

jmslbam commented 2 years ago

@jmslbam That's exactly why this plugin uses PHP Scoper. I believe Yoast SEO uses this too.

Ah, oeps, sorry. I looked over that!

Maybe that @N-Molham could try and use PHP Scoper and see if it solves his issue.

N-Molham commented 2 years ago

@freekmurze @jmslbam @jeffreyvr PHP Scoper could be a good idea, but the thing is Sentry is a standalone SDK So, Maybe it would be ideal if the Ray's plugin implements it, so it would also avoid conflicts with other plugins using composer as well.

freekmurze commented 2 years ago

@N-Molham Probably we won't do this as we use a lot of vendor code. Not being able to composer would make development of all other Ray clients much harder. This is currently something I'm not willing to do, as most PHP projects do play nice with Composer.