MediaWiki  master
manageForeignResources.php
Go to the documentation of this file.
1 <?php
22 require_once __DIR__ . '/Maintenance.php';
23 
31  public function __construct() {
32  parent::__construct();
33  $this->addDescription( <<<TEXT
34 Manage foreign resources registered with ResourceLoader.
35 
36 This helps developers with downloading, verifying, and updating local copies of upstream
37 libraries registered as ResourceLoader modules. See resources/lib/foreign-resources.yaml.
38 
39 Use the "update" action to download urls specified in foreign-resources.yaml, and unpack
40 them to the resources directory. This will also verify them against the integrity hashes.
41 
42 Use the "verify" action to verify the files currently in the resources directory match
43 what "update" would replace them with. This is effectively a dry-run and will not change
44 any module resources on disk.
45 
46 Use the "make-sri" action to compute an integrity hash for upstreams that do not publish
47 one themselves. Add or update the urls foreign-resources.yaml as needed, but omit (or
48 leave empty) the "integrity" key. Then, run the "make-sri" action for the module and
49 copy the integrity into the file. Then, you can use "verify" or "update" normally.
50 TEXT
51  );
52  $this->addArg( 'action', 'One of "update", "verify" or "make-sri"', true );
53  $this->addArg( 'module', 'Name of a single module (Default: all)', false );
54  $this->addOption( 'verbose', 'Be verbose', false, false, 'v' );
55  }
56 
61  public function execute() {
62  global $IP;
63  $frm = new ForeignResourceManager(
64  "{$IP}/resources/lib/foreign-resources.yaml",
65  "{$IP}/resources/lib",
66  function ( $text ) {
67  $this->output( $text );
68  },
69  function ( $text ) {
70  $this->error( $text );
71  },
72  function ( $text ) {
73  if ( $this->hasOption( 'verbose' ) ) {
74  $this->output( $text );
75  }
76  }
77  );
78 
79  $action = $this->getArg( 0 );
80  $module = $this->getArg( 1, 'all' );
81  return $frm->run( $action, $module );
82  }
83 }
84 
86 require_once RUN_MAINTENANCE_IF_MAIN;
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Definition: LICENSE.txt:10
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' null for the local wiki Added in
Definition: hooks.txt:1535
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition: deferred.txt:11
getArg( $argId=0, $default=null)
Get an argument.
error( $err, $die=0)
Throw an error to the user.
$IP
Definition: WebStart.php:41
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition: globals.txt:10
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
def download(url, dest)
Definition: Makefile.py:47
The most up to date schema for the tables in the database will always be tables sql in the maintenance directory
Definition: schema.txt:2
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
Definition: hooks.txt:2145
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place replace
Definition: hooks.txt:2211
Manage foreign resources registered with ResourceLoader.
hasOption( $name)
Checks to see if a particular option exists.
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to publish
Definition: LICENSE.txt:10
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing them
Definition: hooks.txt:966
This document provides an overview of the usage of PageUpdater and that is
Definition: pageupdater.txt:3
Manage foreign resources registered with ResourceLoader.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:91
addDescription( $text)
Set the description text.
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
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
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
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 change
Definition: distributors.txt:9
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:52
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
Definition: hooks.txt:77
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
</td >< td > &</td >< td > t want your writing to be edited mercilessly and redistributed at will
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation files(the "Software")