MediaWiki  1.30.0
checkComposerLockUpToDate.php
Go to the documentation of this file.
1 <?php
2 
3 require_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';
67 require_once RUN_MAINTENANCE_IF_MAIN;
ComposerJson
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
Definition: ComposerJson.php:9
CheckComposerLockUpToDate\execute
execute()
Do the actual work.
Definition: checkComposerLockUpToDate.php:19
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:287
CheckComposerLockUpToDate
Checks whether your composer-installed dependencies are up to date.
Definition: checkComposerLockUpToDate.php:12
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ComposerLock
Reads a composer.lock file and provides accessors to get its hash and what is installed.
Definition: ComposerLock.php:9
$IP
$IP
Definition: update.php:3
CheckComposerLockUpToDate\__construct
__construct()
Default constructor.
Definition: checkComposerLockUpToDate.php:13
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$maintClass
$maintClass
Definition: checkComposerLockUpToDate.php:66
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:392
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:373