[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Communications protocol. 4 * This is used by dumpTextPass.php when the --spawn option is present. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, write to the Free Software Foundation, Inc., 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * http://www.gnu.org/copyleft/gpl.html 20 * 21 * @file 22 * @ingroup Maintenance 23 */ 24 25 require_once __DIR__ . '/Maintenance.php'; 26 27 /** 28 * Maintenance script used to fetch page text in a subprocess. 29 * 30 * @ingroup Maintenance 31 */ 32 class FetchText extends Maintenance { 33 public function __construct() { 34 parent::__construct(); 35 $this->mDescription = "Fetch the revision text from an old_id"; 36 } 37 38 /** 39 * returns a string containing the following in order: 40 * textid 41 * \n 42 * length of text (-1 on error = failure to retrieve/unserialize/gunzip/etc) 43 * \n 44 * text (may be empty) 45 * 46 * note that that the text string itself is *not* followed by newline 47 */ 48 public function execute() { 49 $db = wfGetDB( DB_SLAVE ); 50 $stdin = $this->getStdin(); 51 while ( !feof( $stdin ) ) { 52 $line = fgets( $stdin ); 53 if ( $line === false ) { 54 // We appear to have lost contact... 55 break; 56 } 57 $textId = intval( $line ); 58 $text = $this->doGetText( $db, $textId ); 59 if ( $text === false ) { 60 # actual error, not zero-length text 61 $textLen = "-1"; 62 } else { 63 $textLen = strlen( $text ); 64 } 65 $this->output( $textId . "\n" . $textLen . "\n" . $text ); 66 } 67 } 68 69 /** 70 * May throw a database error if, say, the server dies during query. 71 * @param DatabaseBase $db 72 * @param int $id The old_id 73 * @return string 74 */ 75 private function doGetText( $db, $id ) { 76 $id = intval( $id ); 77 $row = $db->selectRow( 'text', 78 array( 'old_text', 'old_flags' ), 79 array( 'old_id' => $id ), 80 __METHOD__ ); 81 $text = Revision::getRevisionText( $row ); 82 if ( $text === false ) { 83 return false; 84 } 85 86 return $text; 87 } 88 } 89 90 $maintClass = "FetchText"; 91 require_once RUN_MAINTENANCE_IF_MAIN;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |