Merge "Remove not used private member variable mParserWarnings from OutputPage"
[mediawiki.git] / maintenance / dumpLinks.php
blob74b500a1c49136c5fc21d7a3de42170c6197a2dc
1 <?php
2 /**
3 * Quick demo hack to generate a plaintext link dump,
4 * per the proposed wiki link database standard:
5 * http://www.usemod.com/cgi-bin/mb.pl?LinkDatabase
7 * Includes all (live and broken) intra-wiki links.
8 * Does not include interwiki or URL links.
9 * Dumps ASCII text to stdout; command-line.
11 * Copyright © 2005 Brion Vibber <brion@pobox.com>
12 * https://www.mediawiki.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 * http://www.gnu.org/copyleft/gpl.html
29 * @file
30 * @ingroup Maintenance
33 require_once __DIR__ . '/Maintenance.php';
35 /**
36 * Maintenance script that generates a plaintext link dump.
38 * @ingroup Maintenance
40 class DumpLinks extends Maintenance {
41 public function __construct() {
42 parent::__construct();
43 $this->mDescription = "Quick demo hack to generate a plaintext link dump";
46 public function execute() {
47 $dbr = $this->getDB( DB_SLAVE );
48 $result = $dbr->select( array( 'pagelinks', 'page' ),
49 array(
50 'page_id',
51 'page_namespace',
52 'page_title',
53 'pl_namespace',
54 'pl_title' ),
55 array( 'page_id=pl_from' ),
56 __METHOD__,
57 array( 'ORDER BY' => 'page_id' ) );
59 $lastPage = null;
60 foreach ( $result as $row ) {
61 if ( $lastPage != $row->page_id ) {
62 if ( $lastPage !== null ) {
63 $this->output( "\n" );
65 $page = Title::makeTitle( $row->page_namespace, $row->page_title );
66 $this->output( $page->getPrefixedURL() );
67 $lastPage = $row->page_id;
69 $link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
70 $this->output( " " . $link->getPrefixedURL() );
72 if ( $lastPage !== null ) {
73 $this->output( "\n" );
78 $maintClass = "DumpLinks";
79 require_once RUN_MAINTENANCE_IF_MAIN;