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

Is the php-psr extension installed by default (or by mistake) #799

Closed
2 of 5 tasks
stronk7 opened this issue Dec 6, 2023 · 21 comments
Closed
2 of 5 tasks

Is the php-psr extension installed by default (or by mistake) #799

stronk7 opened this issue Dec 6, 2023 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@stronk7
Copy link

stronk7 commented Dec 6, 2023

Describe the bug
Recently we have bumped requirements for a project and it has started to use Symfony 7.x, more exactly the Cache component. And, while phplint is passing perfectly with PHP 7.x, for any run with PHP >= 8.0, we get the following error:

PHP Fatal error:  Declaration of Symfony\Component\Cache\CacheItem::expiresAt(?DateTimeInterface $expiration): static must be compatible with PsrExt\Cache\CacheItemInterface::expiresAt($expiration) in /home/runner/work/moodle-cs/moodle-cs/vendor/symfony/cache/CacheItem.php on line 77

Example run: https://github.com/stronk7/moodle-cs/actions/runs/7118709260

Then, looking to the list of installed extensions (wiki), I cannot see the php-psr extension there.

But, if I disable it in the workflow (workaround) using extensions: :php-psr, then the tests pass ok.

Example run: https://github.com/stronk7/moodle-cs/actions/runs/7118979626

So, apart from the apparent incompatibility between Symfony Cache 7.x and the PSR extension... and why we are (or not) linting the vendor directory... this issue is more about to clarify if the extension is correctly installed (and should be listed in the docs). Or if it's installed "by mistake", and it shouldn't.

Version

  • I have checked releases, and the bug exists in the latest patch version of v1 or v2.
  • v2
  • v1

Runners

  • GitHub Hosted
  • Self Hosted

Operating systems
ubuntu-latest (22.04)

PHP versions
8.0 to 8.2 (probably also 8.3)

To Reproduce
Install Symfony Cache 7.x and try PHP-linting.
Get the linting problem detailed in the description.

Expected behavior
Linting should end ok

Screenshots/Logs

Additional context

Are you willing to submit a PR?
I'm afraid, I don't know enough :-)

@stronk7 stronk7 added the bug Something isn't working label Dec 6, 2023
@iBotPeaches
Copy link

Guess we submitted around same time - yeah I found it was added about an hour ago, with same stack as you.

#798

See here for add of -psr: shivammathur/php-ubuntu@83d1155

@caendesilva
Copy link

Confirmed, tests running within the last hour are mass failing due to a conflict with the Symfony service-contracts extension.

Error: ] Your system is not ready to run the application.                       
                                                                                

Fix the following mandatory requirements:
=========================================

 * The package "symfony/service-contracts" conflicts with the extension "psr".
   You need to disable it in order to run this application.

@jhoff
Copy link

jhoff commented Dec 6, 2023

I think this probably breaking a lot of CI builds right now 😬

Impacting our builds because of the Maatwebsite\Excel package:

PHP Fatal error:  Declaration of Maatwebsite\Excel\Cache\MemoryCache::get(string $key, mixed $default = null): mixed must be compatible with PsrExt\SimpleCache\CacheInterface::get($key, $default = <default>) in /home/runner/work/code/vendor/maatwebsite/excel/src/Cache/MemoryCache.php on line 62
PHP Fatal error:  Declaration of Monolog\Logger::emergency(Stringable|string $message, array $context = []): void must be compatible with PsrExt\Log\LoggerInterface::emergency($message, array $context = []) in /home/runner/work/code/vendor/monolog/monolog/src/Monolog/Logger.php on line 669
Error: Process completed with exit code 255.

@lal65
Copy link

lal65 commented Dec 6, 2023

I can confirm here from Drupal unit test builds as well.

PHP Fatal error:  Declaration of Drupal\Core\Logger\LoggerChannel::log($level, Stringable|string $message, array $context = []): void must be compatible with PsrExt\Log\LoggerTrait::log($level, $message, array $context = []) in /home/runner/work/xxx/xxx/docroot/core/lib/Drupal/Core/Logger/LoggerChannel.php on line 94

@edwinvdpol
Copy link

Same here; Laravel 10 with PHP 8.2 failing...

PHP Fatal error:  Declaration of Monolog\Logger::emergency(Stringable|string $message, array $context = []): void must be compatible with PsrExt\Log\LoggerInterface::emergency($message, array $context = []) in /home/runner/work/dir/dir/vendor/monolog/monolog/src/Monolog/Logger.php on line 681

@felipeelia
Copy link

felipeelia commented Dec 6, 2023

Confirming that adding extensions: :php-psr fixes the problem for now:

    - name: Set PHP version
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.2'
        extensions: :php-psr <-- this line here
        tools: cs2pr
        coverage: none

caendesilva added a commit to hydephp/cli that referenced this issue Dec 6, 2023
@lal65
Copy link

lal65 commented Dec 6, 2023

Confirming that adding extensions: :php-psr fixes the problem for now:

    - name: Set PHP version
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.2'
        extensions: :php-psr <-- this line here
        tools: cs2pr
        coverage: none

Confirmed 2x FOSS 💪. I also want to call out how long this project has worked without fail so far -- almost forgot it was even there!
image

caendesilva added a commit to hydephp/cli that referenced this issue Dec 6, 2023
@jhoff
Copy link

jhoff commented Dec 6, 2023

If you have extensions specified, you can append :php-psr to the existing list:

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.2'
          extensions: foo, bar, :php-psr

caendesilva added a commit to hydephp/cli that referenced this issue Dec 6, 2023
@therobfonz
Copy link

@jhoff you just saved us a bunch of time. Solution worked for me. Thanks for posting!

@georgique
Copy link

Confirmed it broke our CI too
Hopefully it will be fixed soon, don't want to do new version of our CI framework just to handle this

@robHigginsPerf
Copy link

Broken on our builds as well, workaround works for emergencies, but a fix that avoids us having to touch every single build file across projects would be ideal.

@bralandealmeida
Copy link

bralandealmeida commented Dec 6, 2023

It happened to me too and it broke all of our builds. I couldn't solve it with the suggestions above.

PHP Fatal error: Declaration of Symfony\Component\Cache\CacheItem::expiresAt(?DateTimeInterface $expiration): PHP_CodeSniffer\Autoload must be compatible with PsrExt\Cache\CacheItemInterface::expiresAt($expiration) in /vendor/symfony/cache/CacheItem.php on line 65

Edit: In fact, the suggestions above corrected the problem.

@phadaphunk
Copy link

Broke our CI as well

@danielsballes

This comment was marked as resolved.

@acelaya
Copy link
Sponsor

acelaya commented Dec 6, 2023

I don't think it's helpful to anyone who has subscribed to this issue to keep seeing messages from people saying how much this broke their CI.

This got enough visibility already and I'm sure it'll get a fix in a reasonable amount of time after the 0$ we pay for it. Let's give maintainer(s) some time.

@danielsballes
Copy link

My bad, adding :php-psr to my extensions fixed my issue

@caendesilva
Copy link

I don't think it's helpful to anyone who has subscribed to this issue to keep seeing messages from people saying how much this broke their CI.

This got enough visibility already and I'm sure it'll get a fix in a reasonable amount of time after the 0$ we pay for it. Let's give maintainer(s) some time.

Agreed. Initially it's useful to know that an issue is not an isolated event, but it quickly hits a point of diminishing returns. A rollback PR (shivammathur/php-ubuntu#3) is made and is awaiting review from the maintainer, hopefully it is merged soon. Until then, we have a patch that works for now.

@shivammathur
Copy link
Owner

It has been reverted.

Apologies for this, The change was a bug fix for #796, but I guess I created a bigger issue.

image

@therobfonz
Copy link

@shivammathur thanks for reverting and maintaining the package! It's a thankless job but makes a whole lot of peoples lives way easier and much appreciated.

@davereid
Copy link
Contributor

davereid commented Dec 7, 2023

Thank you for resolving this so quickly! Would it be safe to assume that we won't be seeing any re-introduction of the PECL PSR extension anytime? IJust want to know for confidence going forward.

@shivammathur
Copy link
Owner

@davereid Yes, no new extensions that are enabled by default will be added to the cache moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests