You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Composer will then suddenly try to patch phpunit/phpunit with the patches from https://github.com/yiisoft/phpunit-patches, but those patches are for phpunit 4.8, and I want to use phpunit 9.5.
This has been reported before here: yiisoft/phpunit-patches#9, but I didn't provide a reproducable test case. You can find one below now.
What steps will reproduce the problem?
$ git clone https://github.com/michaelarnauts/yii2-patch-issue
$ cd yii2-patch-issue
$ composer install
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Lock file operations: 40 installs, 0 updates, 0 removals
- Locking bower-asset/inputmask (3.3.11)
...
- Locking yiisoft/yii2 (2.0.47)
- Locking yiisoft/yii2-composer (2.0.10)
- Locking yiisoft/yii2-gii (2.2.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 40 installs, 0 updates, 0 removals
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' or '7z' (21.01+) may remediate them.
- Installing cweagans/composer-patches (1.7.2): Extracting archive
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
- Installing yiisoft/yii2-composer (2.0.10): Extracting archive
...
- Installing yiisoft/yii2-gii (2.2.5): Extracting archive
- Applying patches for phpunit/phpunit
https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch (Fix PHP 7 compatibility)
Could not apply patch! Skipping. The error was: Cannot apply patch https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch
In Patches.php line 326:
Cannot apply patch Fix PHP 7 compatibility (https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch)!
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
There are two workarounds, but both aren't really a good solution:
Set composer-exit-on-patch-failure to false, so it errors out on the phpunit patches, but continues with my patches. This works, but then I don't see if the codebase is changed and my patches don't apply anymore.
What is the expected result?
I only want my patch to apply.
What do you get instead?
- Applying patches for phpunit/phpunit
https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch (Fix PHP 7 compatibility)
Could not apply patch! Skipping. The error was: Cannot apply patch https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch
Additional info
Q
A
Yii version
2.0.47
PHP version
8.1, but it also happens on 7.4
Operating system
Ubuntu 22.04
The text was updated successfully, but these errors were encountered:
We may potentially switch from patching to https://github.com/Yoast/PHPUnit-Polyfills/ but that would require some work to ensure tests have all the traits and fixes needed.
I've found a 3th (more acceptable) workaround. Apparently, vaimo/composer-patches is compatible with the syntax of cweagans/composer-patches, but it also allows to exclude patches from dependencies, and only do patches from the project itself. So far, that gave good results.
I'm not sure if the behaviour explained in my post above is expected, or is a bug in cweagans/composer-patches, but using polyfils instead of patching does sound better (and then you also might not need to maintain these patches yourself?). Or maybe just switch to a phpunit version based on the php version used? Not sure of that's possible though.
We need to patch Yii2 for changes that we need, but isn't accepted upstream.
To do this, we use
cweagans/composer-patches
, and specify the patches that need to be done in ourcomposer.json
file. Nothing special here.Example:
This works fine, untill we add
yiisoft/yii2-gii ~2.2.0
andphpunit/phpunit ~9.5.0
to ourrequire-dev
section.Example:
Composer will then suddenly try to patch
phpunit/phpunit
with the patches from https://github.com/yiisoft/phpunit-patches, but those patches are for phpunit 4.8, and I want to use phpunit 9.5.This has been reported before here: yiisoft/phpunit-patches#9, but I didn't provide a reproducable test case. You can find one below now.
What steps will reproduce the problem?
There are two workarounds, but both aren't really a good solution:
patches-ignore
section as indicated here Why are we patching phpunit, since this makes it a lot harder to use a recent phpunit package? phpunit-patches#9. This is ugly and it seems that these patches are added to new yii2 packages, so I'll have to add them all.composer-exit-on-patch-failure
to false, so it errors out on the phpunit patches, but continues with my patches. This works, but then I don't see if the codebase is changed and my patches don't apply anymore.What is the expected result?
I only want my patch to apply.
What do you get instead?
Additional info
The text was updated successfully, but these errors were encountered: