MediaWiki REL1_30
checkComposerLockUpToDate.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/Maintenance.php';
4
13 public function __construct() {
14 parent::__construct();
15 $this->addDescription(
16 'Checks whether your composer.lock file is up to date with the current composer.json' );
17 }
18
19 public function execute() {
20 global $IP;
21 $lockLocation = "$IP/composer.lock";
22 $jsonLocation = "$IP/composer.json";
23 if ( !file_exists( $lockLocation ) ) {
24 // Maybe they're using mediawiki/vendor?
25 $lockLocation = "$IP/vendor/composer.lock";
26 if ( !file_exists( $lockLocation ) ) {
27 $this->error(
28 'Could not find composer.lock file. Have you run "composer install --no-dev"?',
29 1
30 );
31 }
32 }
33
34 $lock = new ComposerLock( $lockLocation );
35 $json = new ComposerJson( $jsonLocation );
36
37 // Check all the dependencies to see if any are old
38 $found = false;
39 $installed = $lock->getInstalledDependencies();
40 foreach ( $json->getRequiredDependencies() as $name => $version ) {
41 if ( isset( $installed[$name] ) ) {
42 if ( $installed[$name]['version'] !== $version ) {
43 $this->output(
44 "$name: {$installed[$name]['version']} installed, $version required.\n"
45 );
46 $found = true;
47 }
48 } else {
49 $this->output( "$name: not installed, $version required.\n" );
50 $found = true;
51 }
52 }
53 if ( $found ) {
54 $this->error(
55 'Error: your composer.lock file is not up to date. ' .
56 'Run "composer update --no-dev" to install newer dependencies',
57 1
58 );
59 } else {
60 // We couldn't find any out-of-date dependencies, so assume everything is ok!
61 $this->output( "Your composer.lock file is up to date with current dependencies!\n" );
62 }
63 }
64}
65
66$maintClass = 'CheckComposerLockUpToDate';
67require_once RUN_MAINTENANCE_IF_MAIN;
Checks whether your composer-installed dependencies are up to date.
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
Reads a composer.lock file and provides accessors to get its hash and what is installed.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addDescription( $text)
Set the description text.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2581
$IP
Definition update.php:3
require_once RUN_MAINTENANCE_IF_MAIN