3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 require_once __DIR__
. '/Maintenance.php';
24 * Run automatically with update.php
26 * - Changes "rfc" URL to use tools.ietf.org domain
27 * - Adds "pmid" interwiki
31 class AddRFCAndPMIDInterwiki
extends LoggedUpdateMaintenance
{
32 public function __construct() {
33 parent
::__construct();
34 $this->addDescription( 'Add RFC and PMID to the interwiki database table' );
37 protected function getUpdateKey() {
41 protected function updateSkippedMessage() {
42 return 'RFC and PMID already added to interwiki database table';
45 protected function doDBUpdates() {
46 $interwikiCache = $this->getConfig()->get( 'InterwikiCache' );
47 // Using something other than the database,
48 if ( $interwikiCache !== false ) {
51 $dbw = $this->getDB( DB_MASTER
);
52 $rfc = $dbw->selectField(
55 [ 'iw_prefix' => 'rfc' ],
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' ) {
66 'iw_url' => 'https://tools.ietf.org/html/rfc$1',
78 'iw_prefix' => 'pmid',
79 'iw_url' => 'https://www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract',
85 // If there's already a pmid interwiki link, don't
94 $maintClass = 'AddRFCAndPMIDInterwiki';
95 require_once RUN_MAINTENANCE_IF_MAIN
;