Would a composer file with php requirement help prevent installing 4.x into an environment using <8.1 PHP version?
I accidentally installed the 4.x version into a environment that did not satisfy the requirements and experienced an error during site installation from existing configuration. Is this related to autowire functionality somehow?
[error] ParseError: syntax error, unexpected identifier "CdnSettings", expecting variable in Composer\Autoload\includeFile() (line 19 of /var/www/docroot/modules/contrib/cdn/src/EventSubscriber/HtmlResponseSubscriber.php) #0 phar:///usr/local/bin/drush/.box/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/var/www/docroo...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Drupal\\cdn\\Even...')
#2 /var/www/vendor/symfony/dependency-injection/ContainerBuilder.php(355): class_exists('Drupal\\cdn\\Even...')
#3 /var/www/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php(33): Symfony\Component\DependencyInjection\ContainerBuilder->getReflectionClass('Drupal\\cdn\\Even...', false)
#4 /var/www/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php(83): Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass->processValue(Object(Symfony\Component\DependencyInjection\Definition), true)
#5 /var/www/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php(28): Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue(Array, true)
#6 /var/www/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php(47): Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass->processValue(Array, true)
#7 /var/www/vendor/symfony/dependency-injection/Compiler/Compiler.php(94): Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->process(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#8 /var/www/vendor/symfony/dependency-injection/ContainerBuilder.php(762): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#9 /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php(1322): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#10 /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php(926): Drupal\Core\DrupalKernel->compileContainer()
#11 /var/www/docroot/core/lib/Drupal/Core/Installer/InstallerKernel.php(20): Drupal\Core\DrupalKernel->initializeContainer()
#12 /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php(819): Drupal\Core\Installer\InstallerKernel->initializeContainer()
#13 /var/www/docroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php(608): Drupal\Core\DrupalKernel->updateModules(Array, Array)
#14 /var/www/docroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php(244): Drupal\Core\Extension\ModuleInstaller->updateKernel(Array)
#15 /var/www/docroot/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install(Array, false)
#16 /var/www/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(817): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, false)
#17 /var/www/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(575): Drupal\Core\Config\ConfigImporter->processExtension('module', 'install', 'cdn')
#18 /var/www/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(512): Drupal\Core\Config\ConfigImporter->processExtensions(Array)
#19 /var/www/docroot/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php(31): Drupal\Core\Config\ConfigImporter->doSyncStep('processExtensio...', Array)
#20 /var/www/docroot/core/includes/batch.inc(295): Drupal\Core\Config\Importer\ConfigImporterBatch::process(Object(Drupal\Core\Config\ConfigImporter), 'processExtensio...', Array)
#21 /var/www/docroot/core/includes/form.inc(955): _batch_process()
#22 /var/www/docroot/core/includes/install.core.inc(653): batch_process(Object(Drupal\Core\Url), Object(Drupal\Core\Url))
#23 /var/www/docroot/core/includes/install.core.inc(571): install_run_task(Array, Array)
#24 /var/www/docroot/core/includes/install.core.inc(119): install_run_tasks(Array, Array)
#25 /var/www/vendor/drush/drush/includes/drush.inc(213): install_drupal(Object(Composer\Autoload\ClassLoader), Array, Array)
#26 /var/www/vendor/drush/drush/includes/drush.inc(197): drush_call_user_func_array('install_drupal', Array)
#27 /var/www/vendor/drush/drush/src/Commands/core/SiteInstallCommands.php(149): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array, Array)
#28 [internal function]: Drush\Commands\core\SiteInstallCommands->install('minimal', Array)
#29 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#30 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#31 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#32 /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#33 /var/www/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /var/www/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /var/www/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 /var/www/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#37 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#39 /var/www/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#40 /var/www/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/vendor...')
#41 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main()
#42 /usr/local/bin/drush(14): require('phar:///usr/loc...')
#43 {main}.
Comments
Comment #2
wim leershttps://git.drupalcode.org/project/cdn/-/blob/4.x/cdn.info.yml literally contains:
It seems that this is a problem with the d.o composer facade:
Comment #3
wim leersCouldn't find an issue in https://www.drupal.org/project/project_composer yet, and don't have the time to do a write-up right now.
Comment #4
jasonawantThank you for the response!
Hmm, I had missed the php version declared in the module's info file.
I started a support issue in project_composer queue, #3335347: Does packages.drupal.org evaluate php compatibility using a module's info.yml php key value?.
Marking as postponed until getting a response over there.
Comment #5
jasonawantIt looks like packages.drupal.org does not have support this right now, and recommends adding a composer.json file if necessary. See comment from #3335347-2: Does packages.drupal.org evaluate php compatibility using a module's info.yml php key value?.
Comment #6
wim leersUgh … I specifically don't have a
composer.jsonfile in this repo since #2711529: File upload widget broken when using CDN module, fixed in Drupal 8.1.4: require that version. Looks like this is forcing our hand…Will make this happen. Thank you very much for creating #3335347: Does packages.drupal.org evaluate php compatibility using a module's info.yml php key value? and getting clarity on this! 🙏🤩
Comment #7
wim leersComment #9
wim leersIf I'm doing this, I want to make sure this file stays consistent. So let's use https://github.com/ergebnis/composer-normalize.
EDIT: failure here is due to #3333022: Get tests passing on Drupal 10.1.x.
Comment #10
wim leersSince #9:
→ let's fix that:
and verify:
Great! Patch updated with that 👍g
Comment #11
wim leersWhile at it, let's make it easier to run
phpcstoo:is much nicer than:
because then you don't have to change paths all the time, plus it no longer depends on the
drupal/coderversion Drupal core happens to be using!Comment #12
wim leers😳 So:
composer.jsonfiles which match the root*.info.ymlfile, the recommendation is to specify a customcomposer.jsonfilecomposer.jsonfile… 😬
… and apparently nobody reported this: https://www.drupal.org/project/issues/project_issue_file_test?text=allow... 🤯
Time to look into #3261803: Using GitLab CI instead of Drupal CI …
Comment #13
wim leers… except that apparently there's been >11 months of silence over at #3265092: [META] Define a default .gitlab-ci.yml template that projects can inherit 😅
Comment #14
wim leersLet's try matching the one and only GitLab CI pipeline I could find that actually is working: https://git.drupalcode.org/project/keycdn/-/blob/8.x-1.x/.gitlab-ci.yml … if this works it'll be pure magic! 🪄
Comment #15
wim leersOh, patches get sent to DrupalCI, only merge requests can trigger CI on GitLab. So … converting #14 to a MR.
Comment #17
wim leersThat worked in part, but I think there was a 9.5-specific PHP 8.1 compatibility bug in core that prevented
phpunitfrom running. Let's see if testing Drupal 10.0 is more successful…Comment #18
wim leersThat … worked, partially! 🤩 Somehow tests verifying assertion errors seem to be failing though:
… but I was going to refactor those away in #3331104: Settings are validated with assert() which shouldn't be relied on anyway. So … this is now blocked on that issue … stay tuned!
Comment #19
berdirHonest opinion, you seem to make your life unnecessary complicated :) Just don't add that plugin, you don't actually need to use that?
Comment #20
wim leersYou're not wrong 🤣 But then again, there are legitimate uses of composer plugins… only if there's sufficient reports of a bug, it will ever get fixed, right? 🤓
But the irony is that I'm forced to add a
composer.jsonfile to work around another d.o bug, so I just wanted to actually get some value out of that. That turned up this other d.o bug 😬Still, let's be more pragmatic for now…
Comment #21
berdir> But then again, there are legitimate uses of composer plugins… only if there's sufficient reports of a bug, it will ever get fixed, right?
Yes, in simplesamlphp_auth for example I can't avoid it, it's not my plugin, it's from my dependency.
I created a merge request against DrupalCI in #3334914: Testing is broken because simplesamlphp/composer-module-installer contains a Composer plugin which is blocked that should allow any plugin, haven't been able to test it but it _should_work. reviews welcome ;)
> 1b238ea2 - @Berdir-inspired pragmatism 🤓
emojis in the commit message. Alfred was right, some people really just want to see the world burn ;)
Comment #22
wim leersSometimes an image/emoji is worth more than a hundred words (which would make for too long a commit message) 😄
Comment #23
ambient.impactWe recently went down this rabbit hole trying to get Config Enforce Devel just building successfully on DrupalCI (see #3307885-19: Customize DrupalCI config to allow running cweagans/composer-patches; fails otherwise) because we use a few Composer patches and so needed that plug-in to be added to the allow list. This was a real challenge because of the lack of documentation around this, and the lack of working examples. We got it working in the end by figuring out via the documentation in combination with one or two examples of where to run our custom commands, and then by accident discovered that there's a lag of up to a day for our changes to be used by DrupalCI even if committed to our default branch, which I think is vaguely mentioned in the documentation somewhere but not made entirely clear.
tl;dr Take a look at our working example if you want to save yourself some time and frustration.
Comment #24
wim leersThis module adopted GitLab CI in #3401760: Adopt GitLab CI: PHPStan compliance + test against 9.5/10.0/10.1/10.2/11.x + max PHP version. So let's redo this issue's MR.
Otherwise this same pain will transition to the upcoming
5.xversion, which will require PHP 8.3 but be installable on Drupal 10 (which only requires PHP 8.1). See #3421351-4: 5.x to require PHP 8.3 and >=10.3: bump requirements + fix deprecations.Comment #26
wim leersAs expected, this is no longer blocked on #3331104: Settings are validated with assert() which shouldn't be relied on, because d.o's GitLab CI infrastructure has matured: it now has PHP assertions enabled, allowing tests to pass without changes.
Let's finally land this! 🙈
Comment #29
wim leersComment #31
wim leersOops, I see the original MR's
composer.jsonwas slightly incomplete 😅Comment #32
wim leers