Skip to content
Snippets Groups Projects
Commit e22bcf1f authored by catch's avatar catch
Browse files

Issue #3280589 by Spokje, longwave, Mile23: Deprecate Composer Vendor Cleanup Scripts

(cherry picked from commit a9c1a681)
parent 9d6aed91
No related branches found
No related tags found
24 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!4350Issue #3307718: Implement xxHash for non-cryptographic use-cases,!3603#ISSUE 3346218 Add a different message on edit comment,!3555Issue #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons,!3494Issue #3327018 by Spokje, longwave, xjm, mondrake: Update PHPStan to 1.9.3 and...,!3410Issue #3340128: UserLoginForm::submitForm has some dead code,!3389Issue #3325184 by Spokje, andypost, xjm, smustgrave: $this->configFactory is...,!3381Issue #3332363: Refactor Claro's menus-and-lists stylesheet,!3307Issue #3326193: CKEditor 5 can grow past the viewport when there is a lot of content,!3236Issue #3332419: Refactor Claro's messages stylesheet,!3231Draft: Issue #3049525 by longwave, fougere, larowlan, kim.pepper, AaronBauman, Wim...,!3212Issue #3294003: Refactor Claro's entity-meta stylesheet,!3194Issue #3330981: Fix PHPStan L1 error "Relying on entity queries to check access by default is deprecated...",!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!3024Issue #3307509: Empty option for views bulk form,!2972Issue #1845004: Replace custom password hashing library with PHP 5.5 password_hash(),!2719Issue #3110137: Remove Classy from core.,!2688Issue #3261452: [PP-1] Remove tracker module from core,!2437Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to <textarea>...,!2296Issue #3100732: Allow specifying `meta` data on JSON:API objects,!1626Issue #3256642: Make life better for database drivers that extend another database driver
......@@ -227,9 +227,6 @@
}
},
"scripts": {
"pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
"post-autoload-dump": [
"Drupal\\Core\\Composer\\Composer::ensureHtaccess"
]
"pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump"
}
}
......@@ -154,8 +154,15 @@ public static function preAutoloadDump(Event $event) {
*
* @param \Composer\Script\Event $event
* The event.
*
* @deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. Any
* "scripts" section mentioning this in composer.json can be removed and
* replaced with the drupal/core-vendor-hardening Composer plugin, as needed.
*
* @see https://www.drupal.org/node/3260624
*/
public static function ensureHtaccess(Event $event) {
trigger_error('Calling ' . __METHOD__ . ' from composer.json is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. Any "scripts" section mentioning this in composer.json can be removed and replaced with the drupal/core-vendor-hardening Composer plugin, as needed. See https://www.drupal.org/node/3260624', E_USER_DEPRECATED);
// The current working directory for composer scripts is where you run
// composer from.
......@@ -174,8 +181,16 @@ public static function ensureHtaccess(Event $event) {
* @param \Composer\Installer\PackageEvent $event
* A PackageEvent object to get the configured composer vendor directories
* from.
*
* @deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. Any
* "scripts" section mentioning this in composer.json can be removed and
* replaced with the drupal/core-vendor-hardening Composer plugin, as needed.
*
* @see https://www.drupal.org/node/3260624
*/
public static function vendorTestCodeCleanup(PackageEvent $event) {
trigger_error('Calling ' . __METHOD__ . ' from composer.json is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. Any "scripts" section mentioning this in composer.json can be removed and replaced with the drupal/core-vendor-hardening Composer plugin, as needed. See https://www.drupal.org/node/3260624', E_USER_DEPRECATED);
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
$io = $event->getIO();
$op = $event->getOperation();
......@@ -231,6 +246,8 @@ public static function vendorTestCodeCleanup(PackageEvent $event) {
*
* @return string|null
* The string key, or NULL if none was found.
*
* @internal
*/
protected static function findPackageKey($package_name) {
$package_key = NULL;
......@@ -254,8 +271,15 @@ protected static function findPackageKey($package_name) {
/**
* Removes Composer's timeout so that scripts can run indefinitely.
*
* @deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. There is no
* replacement.
*
* @see https://www.drupal.org/node/3260624
*/
public static function removeTimeout() {
trigger_error('Calling ' . __METHOD__ . ' from composer.json is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3260624', E_USER_DEPRECATED);
ProcessExecutor::setTimeout(0);
}
......@@ -267,6 +291,8 @@ public static function removeTimeout() {
*
* @return bool
* TRUE on success or FALSE on failure.
*
* @internal
*/
protected static function deleteRecursive($path) {
if (is_file($path) || is_link($path)) {
......@@ -291,6 +317,8 @@ protected static function deleteRecursive($path) {
*
* @param \Composer\Script\Event $event
* The event.
*
* @internal
*/
public static function upgradePHPUnit(Event $event) {
$repository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
......@@ -324,6 +352,8 @@ public static function upgradePHPUnit(Event $event) {
*
* @return bool
* TRUE if the PHPUnit needs to be upgraded, FALSE if not.
*
* @internal
*/
public static function upgradePHPUnitCheck($phpunit_version) {
return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.4') >= 0 && version_compare($phpunit_version, '9.0') < 0);
......
......@@ -8,6 +8,7 @@
/**
* @group Composer
* @group legacy
* @requires externalCommand composer
* @coversDefaultClass \Drupal\Core\Composer\Composer
*/
......
<?php
namespace Drupal\Tests\Core\Composer;
use Composer\Config;
use Composer\Composer as ComposerClass;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\Installer\PackageEvent;
use Composer\IO\IOInterface;
use Composer\Package\Package;
use Composer\Script\Event;
use Drupal\Core\Composer\Composer;
use Drupal\Tests\UnitTestCase;
/**
* Tests the deprecations in the Drupal\Core\Composer\Composer class.
*
* @group Composer
* @coversDefaultClass \Drupal\Core\Composer\Composer
*/
class ComposerDeprecationTest extends UnitTestCase {
/**
* @covers ::ensureHtaccess
* @group legacy
*/
public function testEnsureHtaccess() {
$event = $this->prophesize(Event::class);
$composer = $this->prophesize(ComposerClass::class);
$event->getComposer()->willReturn($composer->reveal());
$config = $this->prophesize(Config::class);
$composer->getConfig()->willReturn($config->reveal());
$this->expectDeprecation('Unsilenced deprecation: Calling Drupal\Core\Composer\Composer::ensureHtaccess from composer.json is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. Any "scripts" section mentioning this in composer.json can be removed and replaced with the drupal/core-vendor-hardening Composer plugin, as needed. See https://www.drupal.org/node/3260624');
Composer::ensureHtaccess($event->reveal());
}
/**
* @covers ::vendorTestCodeCleanup
* @group legacy
*/
public function testVendorTestCodeCleanup() {
$event = $this->prophesize(PackageEvent::class);
$composer = $this->prophesize(ComposerClass::class);
$event->getComposer()->willReturn($composer->reveal());
$config = $this->prophesize(Config::class);
$composer->getConfig()->willReturn($config->reveal());
$operation = $this->prophesize(UpdateOperation::class);
$event->getOperation()->willReturn($operation->reveal());
$package = $this->prophesize(Package::class);
$operation->getTargetPackage()->willReturn($package->reveal());
$io = $this->prophesize(IOInterface::class);
$event->getIO()->willReturn($io->reveal());
$this->expectDeprecation('Unsilenced deprecation: Calling Drupal\Core\Composer\Composer::vendorTestCodeCleanup from composer.json is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. Any "scripts" section mentioning this in composer.json can be removed and replaced with the drupal/core-vendor-hardening Composer plugin, as needed. See https://www.drupal.org/node/3260624');
Composer::vendorTestCodeCleanup($event->reveal());
}
/**
* @covers ::removeTimeout
* @group legacy
*/
public function testRemoveTimeout() {
$this->expectDeprecation('Unsilenced deprecation: Calling Drupal\Core\Composer\Composer::removeTimeout from composer.json is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3260624');
Composer::removeTimeout();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment