dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Allow partially blocked users to import images"
[lhc/web/wiklou.git]
/
maintenance
/
storage
/
moveToExternal.php
diff --git
a/maintenance/storage/moveToExternal.php
b/maintenance/storage/moveToExternal.php
index
639ef58
..
9554797
100644
(file)
--- a/
maintenance/storage/moveToExternal.php
+++ b/
maintenance/storage/moveToExternal.php
@@
-21,6
+21,8
@@
* @ingroup Maintenance ExternalStorage
*/
* @ingroup Maintenance ExternalStorage
*/
+use MediaWiki\MediaWikiServices;
+
define( 'REPORTING_INTERVAL', 1 );
if ( !defined( 'MEDIAWIKI' ) ) {
define( 'REPORTING_INTERVAL', 1 );
if ( !defined( 'MEDIAWIKI' ) ) {
@@
-30,25
+32,22
@@
if ( !defined( 'MEDIAWIKI' ) ) {
$fname = 'moveToExternal';
$fname = 'moveToExternal';
- if ( !isset( $args[
0
] ) ) {
- print "Usage: php moveToExternal.php [-s <startid>] [-e <endid>] <
cluster
>\n";
+ if ( !isset( $args[
1
] ) ) {
+ print "Usage: php moveToExternal.php [-s <startid>] [-e <endid>] <
type> <location
>\n";
exit;
}
exit;
}
- $cluster = $args[0];
+ $type = $args[0]; // e.g. "DB" or "mwstore"
+ $location = $args[1]; // e.g. "cluster12" or "global-swift"
$dbw = wfGetDB( DB_MASTER );
$dbw = wfGetDB( DB_MASTER );
- if ( isset( $options['e'] ) ) {
- $maxID = $options['e'];
- } else {
- $maxID = $dbw->selectField( 'text', 'MAX(old_id)', '', $fname );
- }
+ $maxID = $options['e'] ?? $dbw->selectField( 'text', 'MAX(old_id)', '', $fname );
$minID = $options['s'] ?? 1;
$minID = $options['s'] ?? 1;
- moveToExternal( $
cluster
, $maxID, $minID );
+ moveToExternal( $
type, $location
, $maxID, $minID );
}
}
-function moveToExternal( $
cluster
, $maxID, $minID = 1 ) {
+function moveToExternal( $
type, $location
, $maxID, $minID = 1 ) {
$fname = 'moveToExternal';
$dbw = wfGetDB( DB_MASTER );
$dbr = wfGetDB( DB_REPLICA );
$fname = 'moveToExternal';
$dbw = wfGetDB( DB_MASTER );
$dbr = wfGetDB( DB_REPLICA );
@@
-57,7
+56,9
@@
function moveToExternal( $cluster, $maxID, $minID = 1 ) {
$blockSize = 1000;
$numBlocks = ceil( $count / $blockSize );
print "Moving text rows from $minID to $maxID to external storage\n";
$blockSize = 1000;
$numBlocks = ceil( $count / $blockSize );
print "Moving text rows from $minID to $maxID to external storage\n";
- $ext = new ExternalStoreDB;
+
+ $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
+ $extStore = $esFactory->getStore( $type );
$numMoved = 0;
for ( $block = 0; $block < $numBlocks; $block++ ) {
$numMoved = 0;
for ( $block = 0; $block < $numBlocks; $block++ ) {
@@
-112,7
+113,7
@@
function moveToExternal( $cluster, $maxID, $minID = 1 ) {
# print "Storing " . strlen( $text ) . " bytes to $url\n";
# print "old_id=$id\n";
# print "Storing " . strlen( $text ) . " bytes to $url\n";
# print "old_id=$id\n";
- $url = $ext
->store( $cluster
, $text );
+ $url = $ext
Store->store( $location
, $text );
if ( !$url ) {
print "Error writing to external storage\n";
exit;
if ( !$url ) {
print "Error writing to external storage\n";
exit;