From: Kunal Mehta Date: Sun, 16 Oct 2016 19:49:41 +0000 (-0700) Subject: checkComposerLockUpToDate: Always check dependencies X-Git-Tag: 1.31.0-rc.0~5093 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=75fefc066b892ef24aa99a2780fbbe21ba7a84da;p=lhc%2Fweb%2Fwiklou.git checkComposerLockUpToDate: Always check dependencies Upstream composer has replaced the 'hash' with a smarter 'content-hash', but instead of re-implementing (or copy-pasting) all of that in MediaWiki we can just compare the dependencies themselves, since that's all we care about. Bug: T147189 Change-Id: Ic2f22a82699e2b707b6ccb355605999a183a56a0 --- diff --git a/includes/libs/composer/ComposerJson.php b/includes/libs/composer/ComposerJson.php index 311508f7c0..62231a89b6 100644 --- a/includes/libs/composer/ComposerJson.php +++ b/includes/libs/composer/ComposerJson.php @@ -12,14 +12,9 @@ class ComposerJson { * @param string $location */ public function __construct( $location ) { - $this->hash = md5_file( $location ); $this->contents = json_decode( file_get_contents( $location ), true ); } - public function getHash() { - return $this->hash; - } - /** * Dependencies as specified by composer.json * diff --git a/includes/libs/composer/ComposerLock.php b/includes/libs/composer/ComposerLock.php index e93127c167..818ccdf3a2 100644 --- a/includes/libs/composer/ComposerLock.php +++ b/includes/libs/composer/ComposerLock.php @@ -15,10 +15,6 @@ class ComposerLock { $this->contents = json_decode( file_get_contents( $location ), true ); } - public function getHash() { - return $this->contents['hash']; - } - /** * Dependencies currently installed according to composer.lock * diff --git a/maintenance/checkComposerLockUpToDate.php b/maintenance/checkComposerLockUpToDate.php index 9ec61dc04f..3f0a83ddf2 100644 --- a/maintenance/checkComposerLockUpToDate.php +++ b/maintenance/checkComposerLockUpToDate.php @@ -34,11 +34,7 @@ class CheckComposerLockUpToDate extends Maintenance { $lock = new ComposerLock( $lockLocation ); $json = new ComposerJson( $jsonLocation ); - if ( $lock->getHash() === $json->getHash() ) { - $this->output( "Your composer.lock file is up to date with current dependencies!\n" ); - return; - } - // Out of date, lets figure out which dependencies are old + // Check all the dependencies to see if any are old $found = false; $installed = $lock->getInstalledDependencies(); foreach ( $json->getRequiredDependencies() as $name => $version ) { @@ -61,8 +57,6 @@ class CheckComposerLockUpToDate extends Maintenance { 1 ); } else { - // The hash is the entire composer.json file, - // so it can be updated without any of the dependencies changing // We couldn't find any out-of-date dependencies, so assume everything is ok! $this->output( "Your composer.lock file is up to date with current dependencies!\n" ); } diff --git a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php index 3cde3e2344..ded5f8fe09 100644 --- a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php @@ -11,22 +11,6 @@ class ComposerJsonTest extends MediaWikiTestCase { $this->json2 = "$IP/tests/phpunit/data/composer/new-composer.json"; } - public static function provideGetHash() { - return [ - [ 'json', 'cc6e7fc565b246cb30b0cac103a2b31e' ], - [ 'json2', '19921dd1fc457f1b00561da932432001' ], - ]; - } - - /** - * @dataProvider provideGetHash - * @covers ComposerJson::getHash - */ - public function testIsHashUpToDate( $file, $expected ) { - $json = new ComposerJson( $this->$file ); - $this->assertEquals( $expected, $json->getHash() ); - } - /** * @covers ComposerJson::__construct * @covers ComposerJson::getRequiredDependencies diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/includes/libs/composer/ComposerLockTest.php index 3d5e8d346e..eef7e274a2 100644 --- a/tests/phpunit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerLockTest.php @@ -10,14 +10,6 @@ class ComposerLockTest extends MediaWikiTestCase { $this->lock = "$IP/tests/phpunit/data/composer/composer.lock"; } - /** - * @covers ComposerLock::getHash - */ - public function testGetHash() { - $lock = new ComposerLock( $this->lock ); - $this->assertEquals( 'a3bb80b0ac4c4a31e52574d48c032923', $lock->getHash() ); - } - /** * @covers ComposerLock::__construct * @covers ComposerLock::getInstalledDependencies