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

BC breaking changes in 2.3.0 cause silverstripe/recipe-plugin to break. #10679

Closed
GuySartorelli opened this issue Mar 31, 2022 · 1 comment
Closed

Comments

@GuySartorelli
Copy link
Contributor

GuySartorelli commented Mar 31, 2022

My composer.json (generated using the latest stable release of silverstripe/silverstripe-installer:

{
    "name": "silverstripe/installer",
    "type": "silverstripe-recipe",
    "description": "The SilverStripe Framework Installer",
    "require": {
        "php": "^7.3 || ^8.0",
        "silverstripe/recipe-plugin": "^1.2",
        "silverstripe/recipe-cms": "~4.10.0@stable",
        "silverstripe-themes/simple": "~3.2.0",
        "silverstripe/login-forms": "~4.6.0@stable",
        "silverstripe/contentreview": "^4.4",
        "symbiote/silverstripe-queuedjobs": "^4.9",
        "bringyourownideas/silverstripe-maintenance": "^2.5"
    },
    "require-dev": {
        "phpunit/phpunit": "^9.5"
    },
    "extra": {
        "resources-dir": "_resources",
        "project-files-installed": [
            "app/.htaccess",
            "app/_config.php",
            "app/_config/mimevalidator.yml",
            "app/_config/mysite.yml",
            "app/src/Page.php",
            "app/src/PageController.php"
        ],
        "public-files-installed": [
            ".htaccess",
            "index.php",
            "web.config"
        ]
    },
    "config": {
        "process-timeout": 600,
        "allow-plugins": {
            "composer/installers": true,
            "silverstripe/recipe-plugin": true,
            "silverstripe/vendor-plugin": true
        }
    },
    "prefer-stable": true,
    "minimum-stability": "dev"
}

Output of composer diagnose:

Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.3.2
PHP version: 8.0.17
PHP binary path: /usr/bin/php8.0
OpenSSL version: OpenSSL 1.1.1k  25 Mar 2021
cURL version: 7.74.0 libz 1.2.11 ssl OpenSSL/1.1.1k
zip: extension present, unzip present, 7-Zip not available

When I run this command:

composer update-recipe silverstripe/recipe-cms -vvv

I get the following output:

Reading ./composer.json (/srv/www/scratch-1.local/htdocs/composer.json)
Loading config file ./composer.json (/srv/www/scratch-1.local/htdocs/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/srv/www/scratch-1.local/htdocs): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/srv/www/scratch-1.local/htdocs): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/srv/www/scratch-1.local/htdocs): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/srv/www/scratch-1.local/htdocs): hg branch
Executing command (/srv/www/scratch-1.local/htdocs): fossil branch list
Executing command (/srv/www/scratch-1.local/htdocs): fossil tag list
Executing command (/srv/www/scratch-1.local/htdocs): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /home/gsartorelli/.config/composer/composer.json

Reading /srv/www/scratch-1.local/htdocs/vendor/composer/installed.json
Loading plugin Composer\Installers\Plugin (from composer/installers)
Loading plugin SilverStripe\VendorPlugin\VendorPlugin (from silverstripe/vendor-plugin)
Loading plugin SilverStripe\RecipePlugin\RecipePlugin (from silverstripe/recipe-plugin)
PHP Fatal error:  Declaration of Composer\Command\BaseCommand::getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null) must be compatible with SilverStripe\RecipePlugin\RecipeCommandBehaviour::getComposer($required = true, $disablePlugins = null) in /srv/www/scratch-1.local/htdocs/vendor/silverstripe/recipe-plugin/src/RequireRecipeCommand.php on line 73

Fatal error: Declaration of Composer\Command\BaseCommand::getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null) must be compatible with SilverStripe\RecipePlugin\RecipeCommandBehaviour::getComposer($required = true, $disablePlugins = null) in /srv/www/scratch-1.local/htdocs/vendor/silverstripe/recipe-plugin/src/RequireRecipeCommand.php on line 73

And I expected this to happen:
There should be no fatal error - instead, the output should indicate the changes made to composer.json, and which packages were added or removed as a result of the command.

Related issues:

This has been caused by the addition of typehints to the $required and $disabledPlugins parameters in Composer\Command\BaseCommand::getComposer() in #10561

public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)

This is noted as a BC breaking change in the release notes for 2.3.0:

BC Break: added native parameter & return types to many internal APIs, we explicitly left the most extended/implemented symbols untouched but if this causes problems nonetheless please report it ASAP (#10547, #10561)

@GuySartorelli GuySartorelli changed the title BC breaking changes in 2.3.0 cause silverstripe/vendor-plugin to break. BC breaking changes in 2.3.0 cause silverstripe/recipe-plugin to break. Mar 31, 2022
@Seldaek
Copy link
Member

Seldaek commented Mar 31, 2022

Closing here as silverstripe/recipe-plugin#19 should fix it.

Note that I did not add return types here explicitly to avoid breaking extensions/overrides of those methods. But the way you redefined them in the trait here creates an incompatibility. That's something I did not think of tbh, but it also wasn't very needed in the first place.

I guess in "modern" static analyzed PHP one would use @psalm-require-extends \Composer\Command\BaseCommand on the trait to ensure the methods are there.

@Seldaek Seldaek closed this as completed Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants