MediaWiki  REL1_31
Go to the documentation of this file.
1 <?php
3 require_once __DIR__ . '/Maintenance.php';
5 use Composer\Semver\Semver;
15  public function __construct() {
16  parent::__construct();
17  $this->addDescription(
18  'Checks whether your composer.lock file is up to date with the current composer.json' );
19  }
21  public function execute() {
22  global $IP;
23  $lockLocation = "$IP/composer.lock";
24  $jsonLocation = "$IP/composer.json";
25  if ( !file_exists( $lockLocation ) ) {
26  // Maybe they're using mediawiki/vendor?
27  $lockLocation = "$IP/vendor/composer.lock";
28  if ( !file_exists( $lockLocation ) ) {
29  $this->fatalError(
30  'Could not find composer.lock file. Have you run "composer install --no-dev"?'
31  );
32  }
33  }
35  $lock = new ComposerLock( $lockLocation );
36  $json = new ComposerJson( $jsonLocation );
38  // Check all the dependencies to see if any are old
39  $found = false;
40  $installed = $lock->getInstalledDependencies();
41  foreach ( $json->getRequiredDependencies() as $name => $version ) {
42  if ( isset( $installed[$name] ) ) {
43  if ( !SemVer::satisfies( $installed[$name]['version'], $version ) ) {
44  $this->output(
45  "$name: {$installed[$name]['version']} installed, $version required.\n"
46  );
47  $found = true;
48  }
49  } else {
50  $this->output( "$name: not installed, $version required.\n" );
51  $found = true;
52  }
53  }
54  if ( $found ) {
55  $this->fatalError(
56  'Error: your composer.lock file is not up to date. ' .
57  'Run "composer update --no-dev" to install newer dependencies'
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 }
67 require_once RUN_MAINTENANCE_IF_MAIN;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
Definition: ComposerJson.php:9
Do the actual work.
Definition: checkComposerLockUpToDate.php:21
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Definition: Maintenance.php:439
addDescription( $text)
Set the description text.
Definition: Maintenance.php:291
Checks whether your composer-installed dependencies are up to date.
Definition: checkComposerLockUpToDate.php:14
Definition: maintenance.txt:50
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
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:37
Reads a composer.lock file and provides accessors to get its hash and what is installed.
Definition: ComposerLock.php:9
Default constructor.
Definition: checkComposerLockUpToDate.php:15
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
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:22
Definition: checkComposerLockUpToDate.php:66
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:388
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:56
Definition: WebStart.php:52