2007-11-20 12:58:34 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2012-07-10 16:50:19 +00:00
|
|
|
* Communications protocol.
|
2011-06-04 09:22:24 +00:00
|
|
|
* This is used by dumpTextPass.php when the --spawn option is present.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
*
|
2009-08-02 19:35:17 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-07-10 16:50:19 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
2007-11-20 12:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2007-11-20 12:58:34 +00:00
|
|
|
|
2018-07-03 12:39:22 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
use MediaWiki\Storage\BlobAccessException;
|
2021-08-26 23:38:48 +00:00
|
|
|
use MediaWiki\Storage\BlobStore;
|
2018-07-03 12:39:22 +00:00
|
|
|
use MediaWiki\Storage\SqlBlobStore;
|
2017-03-30 20:46:06 +00:00
|
|
|
|
2012-07-10 16:50:19 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script used to fetch page text in a subprocess.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
class FetchText extends Maintenance {
|
2018-07-03 12:39:22 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2018-07-03 12:39:22 +00:00
|
|
|
$this->addDescription( "Fetch the raw revision blob from a blob address.\n" .
|
|
|
|
|
"Integer IDs are interpreted as referring to text.old_id for backwards compatibility.\n" .
|
2015-09-27 07:41:06 +00:00
|
|
|
"NOTE: Export transformations are NOT applied. " .
|
2018-07-03 12:39:22 +00:00
|
|
|
"This is left to dumpTextPass.php"
|
2016-01-30 02:48:47 +00:00
|
|
|
);
|
2008-05-19 15:49:05 +00:00
|
|
|
}
|
2007-11-20 12:58:34 +00:00
|
|
|
|
2022-01-26 17:24:31 +00:00
|
|
|
public function finalSetup() {
|
2021-12-15 08:07:53 +00:00
|
|
|
// This script should always try to run all db queries in the 'dump' group if such
|
|
|
|
|
// a group exists, just like the BackupDumper and TextPassDumper modules.
|
|
|
|
|
// To account for parts of MediaWiki that get their own db connection outside of
|
|
|
|
|
// Maintenance::getDB(), we set this global variable so that they will attempt
|
|
|
|
|
// to use this group.
|
2022-01-26 17:24:31 +00:00
|
|
|
global $wgDBDefaultGroup;
|
2022-01-14 16:40:52 +00:00
|
|
|
|
2022-01-26 17:24:31 +00:00
|
|
|
$wgDBDefaultGroup = "dump";
|
|
|
|
|
// do this last so that options can override
|
|
|
|
|
parent::finalSetup();
|
2021-12-15 08:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-03 12:39:22 +00:00
|
|
|
/**
|
2021-08-26 23:38:48 +00:00
|
|
|
* @return BlobStore
|
2018-07-03 12:39:22 +00:00
|
|
|
*/
|
|
|
|
|
private function getBlobStore() {
|
|
|
|
|
return MediaWikiServices::getInstance()->getBlobStore();
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:45:13 +00:00
|
|
|
/**
|
2010-07-19 18:36:52 +00:00
|
|
|
* returns a string containing the following in order:
|
2014-04-23 18:08:42 +00:00
|
|
|
* textid
|
|
|
|
|
* \n
|
|
|
|
|
* length of text (-1 on error = failure to retrieve/unserialize/gunzip/etc)
|
|
|
|
|
* \n
|
|
|
|
|
* text (may be empty)
|
2010-06-16 20:12:29 +00:00
|
|
|
*
|
2014-12-16 00:41:45 +00:00
|
|
|
* note that the text string itself is *not* followed by newline
|
2010-06-16 20:12:29 +00:00
|
|
|
*/
|
2013-04-18 18:48:44 +00:00
|
|
|
public function execute() {
|
2009-08-02 19:35:17 +00:00
|
|
|
$stdin = $this->getStdin();
|
2010-05-22 16:50:39 +00:00
|
|
|
while ( !feof( $stdin ) ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$line = fgets( $stdin );
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $line === false ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
// We appear to have lost contact...
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-07-03 12:39:22 +00:00
|
|
|
$blobAddress = trim( $line );
|
|
|
|
|
|
|
|
|
|
// Plain integers are supported for backwards compatibility with pre-MCR dumps.
|
|
|
|
|
if ( strpos( $blobAddress, ':' ) === false && is_numeric( $blobAddress ) ) {
|
|
|
|
|
$blobAddress = SqlBlobStore::makeAddressFromTextId( intval( $blobAddress ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$text = $this->getBlobStore()->getBlob( $blobAddress );
|
2013-04-27 11:23:52 +00:00
|
|
|
$textLen = strlen( $text );
|
2020-07-31 21:46:46 +00:00
|
|
|
} catch ( BlobAccessException | InvalidArgumentException $ex ) {
|
2018-07-03 12:39:22 +00:00
|
|
|
// XXX: log $ex to stderr?
|
|
|
|
|
$textLen = '-1';
|
|
|
|
|
$text = '';
|
2010-06-16 20:12:29 +00:00
|
|
|
}
|
2010-07-19 18:36:52 +00:00
|
|
|
|
2018-07-03 12:39:22 +00:00
|
|
|
$this->output( $blobAddress . "\n" . $textLen . "\n" . $text );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2007-11-20 12:58:34 +00:00
|
|
|
}
|
2018-07-03 12:39:22 +00:00
|
|
|
|
2007-11-20 12:58:34 +00:00
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = FetchText::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|