MediaWiki  REL1_31
addRFCandPMIDInterwiki.php
Go to the documentation of this file.
1 <?php
21 require_once __DIR__ . '/Maintenance.php';
22 
32  public function __construct() {
33  parent::__construct();
34  $this->addDescription( 'Add RFC and PMID to the interwiki database table' );
35  }
36 
37  protected function getUpdateKey() {
38  return __CLASS__;
39  }
40 
41  protected function updateSkippedMessage() {
42  return 'RFC and PMID already added to interwiki database table.';
43  }
44 
45  protected function doDBUpdates() {
46  $interwikiCache = $this->getConfig()->get( 'InterwikiCache' );
47  // Using something other than the database,
48  if ( $interwikiCache !== false ) {
49  return true;
50  }
51  $dbw = $this->getDB( DB_MASTER );
52  $rfc = $dbw->selectField(
53  'interwiki',
54  'iw_url',
55  [ 'iw_prefix' => 'rfc' ],
56  __METHOD__
57  );
58 
59  // Old pre-1.28 default value, or not set at all
60  if ( $rfc === false || $rfc === 'http://www.rfc-editor.org/rfc/rfc$1.txt' ) {
61  $dbw->replace(
62  'interwiki',
63  [ 'iw_prefix' ],
64  [
65  'iw_prefix' => 'rfc',
66  'iw_url' => 'https://tools.ietf.org/html/rfc$1',
67  'iw_api' => '',
68  'iw_wikiid' => '',
69  'iw_local' => 0,
70  ],
71  __METHOD__
72  );
73  }
74 
75  $dbw->insert(
76  'interwiki',
77  [
78  'iw_prefix' => 'pmid',
79  'iw_url' => 'https://www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract',
80  'iw_api' => '',
81  'iw_wikiid' => '',
82  'iw_local' => 0,
83  ],
84  __METHOD__,
85  // If there's already a pmid interwiki link, don't
86  // overwrite it
87  [ 'IGNORE' ]
88  );
89 
90  return true;
91  }
92 }
93 
95 require_once RUN_MAINTENANCE_IF_MAIN;
$maintClass
$maintClass
Definition: addRFCandPMIDInterwiki.php:94
AddRFCAndPMIDInterwiki\getUpdateKey
getUpdateKey()
Get the update key name to go in the update log table.
Definition: addRFCandPMIDInterwiki.php:37
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:291
AddRFCAndPMIDInterwiki\doDBUpdates
doDBUpdates()
Do the actual work.
Definition: addRFCandPMIDInterwiki.php:45
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
AddRFCAndPMIDInterwiki\updateSkippedMessage
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
Definition: addRFCandPMIDInterwiki.php:41
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:37
Maintenance\getConfig
getConfig()
Definition: Maintenance.php:547
LoggedUpdateMaintenance
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Definition: Maintenance.php:1640
AddRFCAndPMIDInterwiki\__construct
__construct()
Default constructor.
Definition: addRFCandPMIDInterwiki.php:32
DB_MASTER
const DB_MASTER
Definition: defines.php:29
AddRFCAndPMIDInterwiki
Run automatically with update.php.
Definition: addRFCandPMIDInterwiki.php:31
Maintenance\getDB
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
Definition: Maintenance.php:1309
class
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