UPSTREAM FIX

magento2-39345: TypeError from sampledata:deploy and remove with --no-update

Community fix magento2-39345 merged into magento/magento2 on 2024-12-21, released in 2.4.8; applies cleanly to 27 releases from 2.4.6 to 2.4.7-p10.

Fixes the TypeError from sampledata:deploy and remove with --no-update edited

Pull request title
bin/magento sampledata:deploy --no-update throws an exception
Pull request
magento/magento2#39345
Issues
#39344 human
Author
@JeroenBoersma
Merged
2024-12-21
Fixed in
2.4.8
Reported on
2.4.7-p3
Categories
—
Components
magento/module-sample-data

Labels

Area
Catalog
Component
SampleData
Priority
P2
Severity
—
Reported on (labels)
2.4.7-p3

Issue

Title and steps come from the upstream issue and pull request.

Description

$ bin/magento sampledata:deploy --no-update
                                                                                                         
In PackageDiscoveryTrait.php line 90:                                                                                                                                                                              
                                                                                                                                                                                                                  
  [TypeError]                                                                                                                                                                                                     
  Composer\Command\RequireCommand::determineRequirements(): Argument #6 ($useBestVersionConstraint) must be of type bool, int given, called in /project/vendor/composer/composer/src/Composer/Command/RequireCom  
  mand.php on line 213                                                                                                                                                                                            
                                                                                                                                                                                                                  

Exception trace:
  at /project/vendor/composer/composer/src/Composer/Command/PackageDiscoveryTrait.php:90
 Composer\Command\RequireCommand->determineRequirements() at /project/vendor/composer/composer/src/Composer/Command/RequireCommand.php:213
 Composer\Command\RequireCommand->execute() at /project/vendor/symfony/console/Command/Command.php:326
 Symfony\Component\Console\Command\Command->run() at /project/vendor/symfony/console/Application.php:1078
 Symfony\Component\Console\Application->doRunCommand() at /project/vendor/symfony/console/Application.php:324
 Symfony\Component\Console\Application->doRun() at /project/vendor/composer/composer/src/Composer/Console/Application.php:394
 Composer\Console\Application->doRun() at /project/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /project/vendor/composer/composer/src/Composer/Console/Application.php:148
 Composer\Console\Application->run() at /project/vendor/magento/module-sample-data/Console/Command/SampleDataDeployCommand.php:106
 Magento\SampleData\Console\Command\SampleDataDeployCommand->execute() at /project/vendor/symfony/console/Command/Command.php:326
 Symfony\Component\Console\Command\Command->run() at /project/vendor/symfony/console/Application.php:1078
 Symfony\Component\Console\Application->doRunCommand() at /project/vendor/symfony/console/Application.php:324
 Symfony\Component\Console\Application->doRun() at /project/vendor/magento/framework/Console/Cli.php:118
 Magento\Framework\Console\Cli->doRun() at /project/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /project/bin/magento:23

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [-
-update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-
stable] [--prefer-lowest] [-m|--minimal-changes] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>.
..]                                                 

There is an error during sample data deployment. Composer file will be reverted.

Steps to reproduce

- Install a clean version of Magento
- In the console try to run bin/magento sampledata:deploy --no-update

Expected result

./composer.json has been updated                                                                                                                                                                                   
Sample data modules have been added via composer. Please run bin/magento setup:upgrade      

Actual result

$ bin/magento sampledata:deploy --no-update
                                                                                                         
In PackageDiscoveryTrait.php line 90:                                                                                                                                                                              
                                                                                                                                                                                                                  
  [TypeError]                                                                                                                                                                                                     
  Composer\Command\RequireCommand::determineRequirements(): Argument #6 ($useBestVersionConstraint) must be of type bool, int given, called in /project/vendor/composer/composer/src/Composer/Command/RequireCom  
  mand.php on line 213                                                                                                                                                                                            
                                                                                                                                                                                                                  

Exception trace:
  at /project/vendor/composer/composer/src/Composer/Command/PackageDiscoveryTrait.php:90
 Composer\Command\RequireCommand->determineRequirements() at /project/vendor/composer/composer/src/Composer/Command/RequireCommand.php:213
 Composer\Command\RequireCommand->execute() at /project/vendor/symfony/console/Command/Command.php:326
 Symfony\Component\Console\Command\Command->run() at /project/vendor/symfony/console/Application.php:1078
 Symfony\Component\Console\Application->doRunCommand() at /project/vendor/symfony/console/Application.php:324
 Symfony\Component\Console\Application->doRun() at /project/vendor/composer/composer/src/Composer/Console/Application.php:394
 Composer\Console\Application->doRun() at /project/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /project/vendor/composer/composer/src/Composer/Console/Application.php:148
 Composer\Console\Application->run() at /project/vendor/magento/module-sample-data/Console/Command/SampleDataDeployCommand.php:106
 Magento\SampleData\Console\Command\SampleDataDeployCommand->execute() at /project/vendor/symfony/console/Command/Command.php:326
 Symfony\Component\Console\Command\Command->run() at /project/vendor/symfony/console/Application.php:1078
 Symfony\Component\Console\Application->doRunCommand() at /project/vendor/symfony/console/Application.php:324
 Symfony\Component\Console\Application->doRun() at /project/vendor/magento/framework/Console/Cli.php:118
 Magento\Framework\Console\Cli->doRun() at /project/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /project/bin/magento:23

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [-
-update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-
stable] [--prefer-lowest] [-m|--minimal-changes] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>.
..]                                                 

There is an error during sample data deployment. Composer file will be reverted.

Taken from the upstream issue.

Error signatures

Code match per tag

Each tag was checked with git apply --check against that tag's files. A clean match means the change applies; it is not a test result. Tags that already contain the fix are marked.

LineCode match per tagTests
2.4.6
2.4.6 clean 2.4.6-p1 clean 2.4.6-p2 clean 2.4.6-p3 clean 2.4.6-p4 clean 2.4.6-p5 clean 2.4.6-p6 clean 2.4.6-p7 clean 2.4.6-p8 clean 2.4.6-p9 clean 2.4.6-p10 clean 2.4.6-p11 clean 2.4.6-p12 clean 2.4.6-p13 clean 2.4.6-p14 clean 2.4.6-p15 clean
2.4.6: no test data 2.4.6-p1: no test data 2.4.6-p2: no test data 2.4.6-p3: no test data 2.4.6-p4: no test data 2.4.6-p5: no test data 2.4.6-p6: no test data 2.4.6-p7: no test data 2.4.6-p8: no test data 2.4.6-p9: no test data 2.4.6-p10: no test data 2.4.6-p11: no test data 2.4.6-p12: no test data 2.4.6-p13: no test data 2.4.6-p14: no test data 2.4.6-p15: no test data
2.4.7
2.4.7 clean 2.4.7-p1 clean 2.4.7-p2 clean 2.4.7-p3 clean 2.4.7-p4 clean 2.4.7-p5 clean 2.4.7-p6 clean 2.4.7-p7 clean 2.4.7-p8 clean 2.4.7-p9 clean 2.4.7-p10 clean
2.4.7: no test data 2.4.7-p1: no test data 2.4.7-p2: no test data 2.4.7-p3: no test data 2.4.7-p4: no test data 2.4.7-p5: no test data 2.4.7-p6: no test data 2.4.7-p7: no test data 2.4.7-p8: no test data 2.4.7-p9: no test data 2.4.7-p10: no test data
2.4.8
2.4.8 conflictcontains the fix 2.4.8-p1 conflictcontains the fix 2.4.8-p2 conflictcontains the fix 2.4.8-p3 conflictcontains the fix 2.4.8-p4 conflictcontains the fix 2.4.8-p5 conflictcontains the fix
2.4.8: no test data 2.4.8-p1: no test data 2.4.8-p2: no test data 2.4.8-p3: no test data 2.4.8-p4: no test data 2.4.8-p5: no test data
2.4.9
2.4.9 conflictcontains the fix
2.4.9: no test data

Triage

Model @cf/cloudflare/clef. Probability this is a bug fix: 97.4%. Probability it is security relevant: 0.5%.

Show the model's answers and probabilities
QuestionAnswerProbabilitiesConfidence
Change kindbugfixbugfix 96.1%, refactor 1.2%, dependency 1.0%, tests_only 0.7%, feature 0.5%, docs_only 0.5%91.0%
Areaframeworkframework 47.4%, other 31.4%, catalog 9.1%24.3%
Reported version2.4.7-p32.4.7-p3 60.5%, 2.4.7-p4 3.1%, 2.4.7 2.8%36.1%
Scope0.56 of 20 49.8%, 1 44.1%, 2 6.1%16.9%
Risk0.05 of 20 95.9%, 1 2.7%, 2 1.4%88.2%
Worth backporting1.52 of 22 63.2%, 1 25.9%, 0 10.9%21.8%

Download

For cweagans/composer-patches, choose a version below and download the bundle. Copy its magento2-39345/ folder into patches/composer/, merge composer.patches.json into composer.json, then run composer install. Test files are always removed; paths are relative to each package root, using the default -p1 level.

Packages (1): magento/module-sample-data
Bundle README (what the ZIP ships)
# magento2-39345

Community fix merged upstream into magento/magento2, adapted by magento.watch.
This is not a patch published by Adobe.

Pull request: https://github.com/magento/magento2/pull/39345
Issue: https://github.com/magento/magento2/issues/39344
Author: @JeroenBoersma
Source commit: 7a64a95cb3c00562b8abc1a2362e6e2d7e57e535
Modifications: test files and documentation removed, paths rewritten relative to each Composer package.
Licence: OSL-3.0 / AFL-3.0, as the original Magento Open Source code.
Maintainer: Łukasz Bajsarowicz (@lbajsarowicz)

Licence: Magento Open Source code under OSL-3.0 and AFL-3.0. The bundle carries the original author, source commit and the list of modifications.

Sources

Łukasz Bajsarowicz
Built by

Łukasz Bajsarowicz, e-commerce architect

Magento and Adobe Commerce architecture, upgrades, performance and audits for merchants and agencies since 2015; magento.watch is the tooling I use on those projects.

Open source, maintained on weekends.