MediaWiki
REL1_39
addRFCandPMIDInterwiki.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\MainConfigNames
;
22
23
require_once __DIR__ .
'/Maintenance.php'
;
24
33
class
AddRFCandPMIDInterwiki
extends
LoggedUpdateMaintenance
{
34
public
function
__construct
() {
35
parent::__construct();
36
$this->
addDescription
(
'Add RFC and PMID to the interwiki database table'
);
37
}
38
39
protected
function
getUpdateKey
() {
40
return
__CLASS__;
41
}
42
43
protected
function
updateSkippedMessage
() {
44
return
'RFC and PMID already added to interwiki database table.'
;
45
}
46
47
protected
function
doDBUpdates
() {
48
$interwikiCache = $this->
getConfig
()->get( MainConfigNames::InterwikiCache );
49
// Using something other than the database,
50
if
( $interwikiCache !==
false
) {
51
return
true
;
52
}
53
$dbw = $this->
getDB
(
DB_PRIMARY
);
54
55
$rfc = $dbw->newSelectQueryBuilder()
56
->select(
'iw_url'
)
57
->from(
'interwiki'
)
58
->where( [
'iw_prefix'
=>
'rfc'
] )
59
->caller( __METHOD__ )
60
->fetchField();
61
62
// Old pre-1.28 default value, or not set at all
63
if
( $rfc ===
false
|| $rfc ===
'http://www.rfc-editor.org/rfc/rfc$1.txt'
) {
64
$dbw->replace(
65
'interwiki'
,
66
[ [
'iw_prefix'
] ],
67
[
68
'iw_prefix'
=>
'rfc'
,
69
'iw_url'
=>
'https://tools.ietf.org/html/rfc$1'
,
70
'iw_api'
=>
''
,
71
'iw_wikiid'
=>
''
,
72
'iw_local'
=> 0,
73
],
74
__METHOD__
75
);
76
}
77
78
$dbw->insert(
79
'interwiki'
,
80
[
81
'iw_prefix'
=>
'pmid'
,
82
'iw_url'
=>
'https://www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract'
,
83
'iw_api'
=>
''
,
84
'iw_wikiid'
=>
''
,
85
'iw_local'
=> 0,
86
],
87
__METHOD__,
88
// If there's already a pmid interwiki link, don't
89
// overwrite it
90
[
'IGNORE'
]
91
);
92
93
return
true
;
94
}
95
}
96
97
$maintClass
= AddRFCandPMIDInterwiki::class;
98
require_once RUN_MAINTENANCE_IF_MAIN;
getDB
getDB()
$maintClass
$maintClass
Definition
addRFCandPMIDInterwiki.php:97
AddRFCandPMIDInterwiki
Run automatically with update.php.
Definition
addRFCandPMIDInterwiki.php:33
AddRFCandPMIDInterwiki\doDBUpdates
doDBUpdates()
Do the actual work.
Definition
addRFCandPMIDInterwiki.php:47
AddRFCandPMIDInterwiki\getUpdateKey
getUpdateKey()
Get the update key name to go in the update log table.
Definition
addRFCandPMIDInterwiki.php:39
AddRFCandPMIDInterwiki\__construct
__construct()
Default constructor.
Definition
addRFCandPMIDInterwiki.php:34
AddRFCandPMIDInterwiki\updateSkippedMessage
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
Definition
addRFCandPMIDInterwiki.php:43
LoggedUpdateMaintenance
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Definition
LoggedUpdateMaintenance.php:26
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:319
Maintenance\getConfig
getConfig()
Definition
Maintenance.php:597
MediaWiki\MainConfigNames
A class containing constants representing the names of configuration variables.
Definition
MainConfigNames.php:23
DB_PRIMARY
const DB_PRIMARY
Definition
defines.php:28
maintenance
addRFCandPMIDInterwiki.php
Generated on Mon Dec 23 2024 06:25:30 for MediaWiki by
1.10.0