MediaWiki
REL1_41
fixLegacyEncoding.php
Go to the documentation of this file.
1
<?php
22
use
MediaWiki\Storage\SqlBlobStore
;
23
24
require_once __DIR__ .
'/moveToExternal.php'
;
25
26
class
FixLegacyEncoding
extends
MoveToExternal
{
27
public
function
__construct
() {
28
parent::__construct();
29
$this->
addDescription
(
'Change encoding of stored content from legacy encoding to UTF-8'
);
30
}
31
32
protected
function
getConditions
( $blockStart, $blockEnd, $dbr ) {
33
return
[
34
"old_id BETWEEN $blockStart AND $blockEnd"
,
35
'old_flags NOT '
. $dbr->buildLike( $dbr->anyString(),
'utf-8'
, $dbr->anyString() ),
36
'old_flags NOT '
. $dbr->buildLike( $dbr->anyString(),
'utf8'
, $dbr->anyString() ),
37
];
38
}
39
40
protected
function
resolveText
( $text, $flags ) {
41
if
( in_array(
'error'
, $flags ) ) {
42
return
[ $text, $flags ];
43
}
44
$blobStore = $this->
getServiceContainer
()->getBlobStore();
45
if
( in_array(
'external'
, $flags ) && $blobStore instanceof
SqlBlobStore
) {
46
$text = $blobStore->expandBlob( $text, $flags );
47
// It will be put back in external storage again
48
$flags = array_diff( $flags, [
'external'
] );
49
}
50
if
( in_array(
'gzip'
, $flags ) ) {
51
$text = gzinflate( $text );
52
$flags = array_diff( $flags, [
'gzip'
] );
53
}
54
return
[ $text, $flags ];
55
}
56
57
}
58
59
$maintClass
= FixLegacyEncoding::class;
60
require_once RUN_MAINTENANCE_IF_MAIN;
FixLegacyEncoding
Definition
fixLegacyEncoding.php:26
FixLegacyEncoding\__construct
__construct()
Default constructor.
Definition
fixLegacyEncoding.php:27
FixLegacyEncoding\resolveText
resolveText( $text, $flags)
Definition
fixLegacyEncoding.php:40
FixLegacyEncoding\getConditions
getConditions( $blockStart, $blockEnd, $dbr)
Definition
fixLegacyEncoding.php:32
Maintenance\getServiceContainer
getServiceContainer()
Returns the main service container.
Definition
Maintenance.php:637
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:325
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects representing revision data blobs.
Definition
SqlBlobStore.php:51
MoveToExternal
Definition
moveToExternal.php:31
$maintClass
$maintClass
Definition
fixLegacyEncoding.php:59
maintenance
storage
fixLegacyEncoding.php
Generated on Wed Nov 27 2024 07:26:37 for MediaWiki by
1.10.0