113 parent::__construct( $config );
115 $this->swiftAuthUrl = $config[
'swiftAuthUrl'];
116 $this->swiftUser = $config[
'swiftUser'];
117 $this->swiftKey = $config[
'swiftKey'];
119 $this->authTTL = isset( $config[
'swiftAuthTTL'] )
120 ? $config[
'swiftAuthTTL']
122 $this->swiftTempUrlKey = isset( $config[
'swiftTempUrlKey'] )
123 ? $config[
'swiftTempUrlKey']
125 $this->swiftStorageUrl = isset( $config[
'swiftStorageUrl'] )
126 ? $config[
'swiftStorageUrl']
128 $this->shardViaHashLevels = isset( $config[
'shardViaHashLevels'] )
129 ? $config[
'shardViaHashLevels']
131 $this->rgwS3AccessKey = isset( $config[
'rgwS3AccessKey'] )
132 ? $config[
'rgwS3AccessKey']
134 $this->rgwS3SecretKey = isset( $config[
'rgwS3SecretKey'] )
135 ? $config[
'rgwS3SecretKey']
140 if ( isset( $config[
'wanCache'] ) && $config[
'wanCache'] instanceof
WANObjectCache ) {
141 $this->memCache = $config[
'wanCache'];
146 if ( !empty( $config[
'cacheAuthInfo'] ) && isset( $config[
'srvCache'] ) ) {
147 $this->srvCache = $config[
'srvCache'];
151 $this->readUsers = isset( $config[
'readUsers'] )
152 ? $config[
'readUsers']
154 $this->writeUsers = isset( $config[
'writeUsers'] )
155 ? $config[
'writeUsers']
157 $this->secureReadUsers = isset( $config[
'secureReadUsers'] )
158 ? $config[
'secureReadUsers']
160 $this->secureWriteUsers = isset( $config[
'secureWriteUsers'] )
161 ? $config[
'secureWriteUsers']
171 if ( !mb_check_encoding( $relStoragePath,
'UTF-8' ) ) {
173 } elseif ( strlen( rawurlencode( $relStoragePath ) ) > 1024 ) {
177 return $relStoragePath;
182 if ( $rel ===
null ) {
197 if ( !isset(
$params[
'headers'] ) ) {
202 unset( $headers[
'content-type' ] );
220 return isset(
$params[
'headers'] )
233 foreach ( $rawHeaders as $name =>
$value ) {
234 $name = strtolower( $name );
235 if ( preg_match(
'/^content-length$/', $name ) ) {
237 } elseif ( preg_match(
'/^(x-)?content-/', $name ) ) {
239 } elseif ( preg_match(
'/^content-(disposition)/', $name ) ) {
244 if ( isset( $headers[
'content-disposition'] ) ) {
247 foreach ( explode(
';', $headers[
'content-disposition'] ) as $part ) {
248 $part = trim( $part );
249 $new = ( $disposition ===
'' ) ? $part :
"{$disposition};{$part}";
250 if ( strlen( $new ) <= 255 ) {
256 $headers[
'content-disposition'] = $disposition;
268 foreach ( $rawHeaders as $name =>
$value ) {
269 $name = strtolower( $name );
270 if ( strpos( $name,
'x-object-meta-' ) === 0 ) {
285 $metadata[substr( $name, strlen(
'x-object-meta-' ) )] =
$value;
295 if ( $dstRel ===
null ) {
301 $sha1Hash = Wikimedia\base_convert( sha1(
$params[
'content'] ), 16, 36, 31 );
302 $contentType = isset(
$params[
'headers'][
'content-type'] )
303 ?
$params[
'headers'][
'content-type']
308 'url' => [ $dstCont, $dstRel ],
310 'content-length' => strlen(
$params[
'content'] ),
311 'etag' => md5(
$params[
'content'] ),
312 'content-type' => $contentType,
313 'x-object-meta-sha1base36' => $sha1Hash
318 $method = __METHOD__;
320 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$request[
'response'];
321 if ( $rcode === 201 ) {
323 } elseif ( $rcode === 412 ) {
331 if ( !empty(
$params[
'async'] ) ) {
344 if ( $dstRel ===
null ) {
350 Wikimedia\suppressWarnings();
351 $sha1Hash = sha1_file(
$params[
'src'] );
352 Wikimedia\restoreWarnings();
353 if ( $sha1Hash ===
false ) {
358 $sha1Hash = Wikimedia\base_convert( $sha1Hash, 16, 36, 31 );
359 $contentType = isset(
$params[
'headers'][
'content-type'] )
360 ?
$params[
'headers'][
'content-type']
363 $handle = fopen(
$params[
'src'],
'rb' );
364 if ( $handle ===
false ) {
372 'url' => [ $dstCont, $dstRel ],
374 'content-length' => filesize(
$params[
'src'] ),
375 'etag' => md5_file(
$params[
'src'] ),
376 'content-type' => $contentType,
377 'x-object-meta-sha1base36' => $sha1Hash
382 $method = __METHOD__;
384 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$request[
'response'];
385 if ( $rcode === 201 ) {
387 } elseif ( $rcode === 412 ) {
395 $opHandle->resourcesToClose[] = $handle;
397 if ( !empty(
$params[
'async'] ) ) {
410 if ( $srcRel ===
null ) {
417 if ( $dstRel ===
null ) {
425 'url' => [ $dstCont, $dstRel ],
427 'x-copy-from' =>
'/' . rawurlencode( $srcCont ) .
428 '/' . str_replace(
"%2F",
"/", rawurlencode( $srcRel ) )
432 $method = __METHOD__;
434 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$request[
'response'];
435 if ( $rcode === 201 ) {
437 } elseif ( $rcode === 404 ) {
445 if ( !empty(
$params[
'async'] ) ) {
458 if ( $srcRel ===
null ) {
465 if ( $dstRel ===
null ) {
474 'url' => [ $dstCont, $dstRel ],
476 'x-copy-from' =>
'/' . rawurlencode( $srcCont ) .
477 '/' . str_replace(
"%2F",
"/", rawurlencode( $srcRel ) )
481 if (
"{$srcCont}/{$srcRel}" !==
"{$dstCont}/{$dstRel}" ) {
483 'method' =>
'DELETE',
484 'url' => [ $srcCont, $srcRel ],
489 $method = __METHOD__;
491 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$request[
'response'];
492 if (
$request[
'method'] ===
'PUT' && $rcode === 201 ) {
494 } elseif (
$request[
'method'] ===
'DELETE' && $rcode === 204 ) {
496 } elseif ( $rcode === 404 ) {
504 if ( !empty(
$params[
'async'] ) ) {
517 if ( $srcRel ===
null ) {
524 'method' =>
'DELETE',
525 'url' => [ $srcCont, $srcRel ],
529 $method = __METHOD__;
531 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$request[
'response'];
532 if ( $rcode === 204 ) {
534 } elseif ( $rcode === 404 ) {
535 if ( empty(
$params[
'ignoreMissingSource'] ) ) {
544 if ( !empty(
$params[
'async'] ) ) {
557 if ( $srcRel ===
null ) {
564 $stat = $this->
getFileStat( [
'src' => $params[
'src'],
'latest' => 1 ] );
565 if ( $stat && !isset( $stat[
'xattr'] ) ) {
566 $stat = $this->
doGetFileStat( [
'src' => $params[
'src'],
'latest' => 1 ] );
576 foreach ( $stat[
'xattr'][
'metadata'] as $name =>
$value ) {
577 $metaHdrs[
"x-object-meta-$name"] =
$value;
579 $customHdrs = $this->
sanitizeHdrs( $params ) + $stat[
'xattr'][
'headers'];
583 'url' => [ $srcCont, $srcRel ],
584 'headers' => $metaHdrs + $customHdrs
587 $method = __METHOD__;
589 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$request[
'response'];
590 if ( $rcode === 202 ) {
592 } elseif ( $rcode === 404 ) {
600 if ( !empty(
$params[
'async'] ) ) {
614 if ( is_array( $stat ) ) {
616 } elseif ( $stat ===
null ) {
617 $status->fatal(
'backend-fail-internal', $this->
name );
618 $this->logger->error( __METHOD__ .
': cannot get container stat' );
624 if ( $stat ===
false ) {
634 if ( empty(
$params[
'noAccess'] ) ) {
639 if ( is_array( $stat ) ) {
640 $readUsers = array_merge( $this->secureReadUsers, [ $this->swiftUser ] );
641 $writeUsers = array_merge( $this->secureWriteUsers, [ $this->swiftUser ] );
648 } elseif ( $stat ===
false ) {
651 $status->fatal(
'backend-fail-internal', $this->
name );
652 $this->logger->error( __METHOD__ .
': cannot get container stat' );
662 if ( is_array( $stat ) ) {
663 $readUsers = array_merge( $this->readUsers, [ $this->swiftUser,
'.r:*' ] );
664 $writeUsers = array_merge( $this->writeUsers, [ $this->swiftUser ] );
672 } elseif ( $stat ===
false ) {
675 $status->fatal(
'backend-fail-internal', $this->
name );
676 $this->logger->error( __METHOD__ .
': cannot get container stat' );
692 if ( $stat ===
false ) {
694 } elseif ( !is_array( $stat ) ) {
695 $status->fatal(
'backend-fail-internal', $this->
name );
696 $this->logger->error( __METHOD__ .
': cannot get container stat' );
702 if ( $stat[
'count'] == 0 ) {
715 return reset( $stats );
732 return $timestamp->getTimestamp( $format );
733 }
catch ( Exception
$e ) {
746 if ( isset( $objHdrs[
'x-object-meta-sha1base36'] ) ) {
752 $this->logger->error( __METHOD__ .
": {path} was not stored with SHA-1 metadata.",
753 [
'path' => $path ] );
755 $objHdrs[
'x-object-meta-sha1base36'] =
false;
771 $tmpFile = $this->
getLocalCopy( [
'src' => $path,
'latest' => 1 ] );
773 $hash = $tmpFile->getSha1Base36();
774 if ( $hash !==
false ) {
775 $objHdrs[
'x-object-meta-sha1base36'] = $hash;
777 $postHeaders[
'x-object-meta-sha1base36'] = $hash;
779 list( $rcode ) = $this->
http->run( [
781 'url' => $this->
storageUrl( $auth, $srcCont, $srcRel ),
784 if ( $rcode >= 200 && $rcode <= 299 ) {
793 $this->logger->error( __METHOD__ .
': unable to set SHA-1 metadata for {path}',
794 [
'path' => $path ] );
804 $ep = array_diff_key(
$params, [
'srcs' => 1 ] );
809 foreach (
$params[
'srcs'] as $path ) {
811 if ( $srcRel ===
null || !$auth ) {
812 $contents[
$path] =
false;
816 $handle = fopen(
'php://temp',
'wb' );
820 'url' => $this->
storageUrl( $auth, $srcCont, $srcRel ),
826 $contents[
$path] =
false;
829 $opts = [
'maxConnsPerHost' =>
$params[
'concurrency'] ];
830 $reqs = $this->
http->runMulti( $reqs, $opts );
831 foreach ( $reqs as $path => $op ) {
832 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $op[
'response'];
833 if ( $rcode >= 200 && $rcode <= 299 ) {
834 rewind( $op[
'stream'] );
835 $contents[
$path] = stream_get_contents( $op[
'stream'] );
836 } elseif ( $rcode === 404 ) {
837 $contents[
$path] =
false;
839 $this->
onError(
null, __METHOD__,
840 [
'src' => $path ] + $ep, $rerr, $rcode, $rdesc );
842 fclose( $op[
'stream'] );
849 $prefix = ( $dir ==
'' ) ?
null :
"{$dir}/";
852 return ( count(
$status->value ) ) > 0;
893 if ( $after === INF ) {
899 $prefix = ( $dir ==
'' ) ?
null :
"{$dir}/";
901 if ( !empty(
$params[
'topOnly'] ) ) {
907 foreach ( $objects as $object ) {
908 if ( substr( $object, -1 ) ===
'/' ) {
914 $getParentDir =
function (
$path ) {
915 return ( strpos( $path,
'/' ) !==
false ) ? dirname( $path ) :
false;
919 $lastDir = $getParentDir( $after );
928 foreach ( $objects as $object ) {
929 $objectDir = $getParentDir( $object );
931 if ( $objectDir !==
false && $objectDir !== $dir ) {
936 if ( strcmp( $objectDir, $lastDir ) > 0 ) {
939 $dirs[] =
"{$pDir}/";
940 $pDir = $getParentDir( $pDir );
941 }
while ( $pDir !==
false
942 && strcmp( $pDir, $lastDir ) > 0
943 && strlen( $pDir ) > strlen( $dir )
946 $lastDir = $objectDir;
951 if ( count( $objects ) < $limit ) {
954 $after = end( $objects );
973 if ( $after === INF ) {
979 $prefix = ( $dir ==
'' ) ?
null :
"{$dir}/";
982 if ( !empty(
$params[
'topOnly'] ) ) {
983 if ( !empty(
$params[
'adviseStat'] ) ) {
990 if ( !empty(
$params[
'adviseStat'] ) ) {
1006 if ( count( $objects ) < $limit ) {
1009 $after = end( $objects );
1010 $after = is_object( $after ) ? $after->name : $after;
1027 foreach ( $objects as $object ) {
1028 if ( is_object( $object ) ) {
1029 if ( isset( $object->subdir ) || !isset( $object->name ) ) {
1035 'size' => (int)$object->bytes,
1038 'md5' => ctype_xdigit( $object->hash ) ? $object->hash :
null,
1041 $names[] = [ $object->name, $stat ];
1042 } elseif ( substr( $object, -1 ) !==
'/' ) {
1044 $names[] = [ $object, null ];
1058 $this->cheapCache->set( $path,
'stat', $val );
1064 if ( !isset( $stat[
'xattr'] ) ) {
1070 return $stat[
'xattr'];
1079 if ( !isset( $stat[
'sha1'] ) ) {
1085 return $stat[
'sha1'];
1097 if ( $srcRel ===
null ) {
1126 if ( empty(
$params[
'allowOB'] ) ) {
1128 call_user_func( $this->obResetFunc );
1131 $handle = fopen(
'php://output',
'wb' );
1132 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1134 'url' => $this->
storageUrl( $auth, $srcCont, $srcRel ),
1137 'stream' => $handle,
1138 'flags' => [
'relayResponseHeaders' => empty(
$params[
'headless'] ) ]
1141 if ( $rcode >= 200 && $rcode <= 299 ) {
1143 } elseif ( $rcode === 404 ) {
1163 $ep = array_diff_key(
$params, [
'srcs' => 1 ] );
1168 foreach (
$params[
'srcs'] as $path ) {
1170 if ( $srcRel ===
null || !$auth ) {
1171 $tmpFiles[
$path] =
null;
1179 $handle = fopen( $tmpFile->getPath(),
'wb' );
1183 'url' => $this->
storageUrl( $auth, $srcCont, $srcRel ),
1186 'stream' => $handle,
1192 $tmpFiles[
$path] = $tmpFile;
1195 $isLatest = ( $this->isRGW || !empty(
$params[
'latest'] ) );
1196 $opts = [
'maxConnsPerHost' =>
$params[
'concurrency'] ];
1197 $reqs = $this->
http->runMulti( $reqs, $opts );
1198 foreach ( $reqs as $path => $op ) {
1199 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $op[
'response'];
1200 fclose( $op[
'stream'] );
1201 if ( $rcode >= 200 && $rcode <= 299 ) {
1202 $size = $tmpFiles[
$path] ? $tmpFiles[
$path]->getSize() : 0;
1204 if ( $size != $rhdrs[
'content-length'] ) {
1205 $tmpFiles[
$path] =
null;
1206 $rerr =
"Got {$size}/{$rhdrs['content-length']} bytes";
1207 $this->
onError(
null, __METHOD__,
1208 [
'src' => $path ] + $ep, $rerr, $rcode, $rdesc );
1212 $stat[
'latest'] = $isLatest;
1213 $this->cheapCache->set( $path,
'stat', $stat );
1214 } elseif ( $rcode === 404 ) {
1215 $tmpFiles[
$path] =
false;
1217 $tmpFiles[
$path] =
null;
1218 $this->
onError(
null, __METHOD__,
1219 [
'src' => $path ] + $ep, $rerr, $rcode, $rdesc );
1227 if ( $this->swiftTempUrlKey !=
'' ||
1228 ( $this->rgwS3AccessKey !=
'' && $this->rgwS3SecretKey !=
'' )
1231 if ( $srcRel ===
null ) {
1241 $expires = time() + $ttl;
1243 if ( $this->swiftTempUrlKey !=
'' ) {
1244 $url = $this->
storageUrl( $auth, $srcCont, $srcRel );
1246 $contPath = parse_url( $this->
storageUrl( $auth, $srcCont ), PHP_URL_PATH );
1247 $signature = hash_hmac(
'sha1',
1248 "GET\n{$expires}\n{$contPath}/{$srcRel}",
1249 $this->swiftTempUrlKey
1252 return "{$url}?temp_url_sig={$signature}&temp_url_expires={$expires}";
1255 $spath =
'/' . rawurlencode( $srcCont ) .
'/' .
1256 str_replace(
'%2F',
'/', rawurlencode( $srcRel ) );
1258 $signature = base64_encode( hash_hmac(
1260 "GET\n\n\n{$expires}\n{$spath}",
1261 $this->rgwS3SecretKey,
1267 return str_replace(
'/swift/v1',
'', $this->
storageUrl( $auth ) . $spath ) .
1270 'Signature' => $signature,
1271 'Expires' => $expires,
1272 'AWSAccessKeyId' => $this->rgwS3AccessKey
1294 if ( !empty(
$params[
'latest'] ) ) {
1295 $hdrs[
'x-newest'] =
'true';
1312 foreach ( $fileOpHandles as $index => $fileOpHandle ) {
1313 $statuses[$index] = $this->
newStatus(
'backend-fail-connect', $this->
name );
1320 $httpReqsByStage = [];
1321 foreach ( $fileOpHandles as $index => $fileOpHandle ) {
1323 $reqs = $fileOpHandle->httpOp;
1325 foreach ( $reqs as $stage => &
$req ) {
1326 list( $container, $relPath ) =
$req[
'url'];
1328 $req[
'headers'] = isset(
$req[
'headers'] ) ?
$req[
'headers'] : [];
1330 $httpReqsByStage[$stage][$index] =
$req;
1336 $reqCount = count( $httpReqsByStage );
1337 for ( $stage = 0; $stage < $reqCount; ++$stage ) {
1338 $httpReqs = $this->
http->runMulti( $httpReqsByStage[$stage] );
1339 foreach ( $httpReqs as $index => $httpReq ) {
1341 $callback = $fileOpHandles[$index]->callback;
1342 call_user_func_array( $callback, [ $httpReq, $statuses[$index] ] );
1345 if ( !$statuses[$index]->isOK() ) {
1346 $stages = count( $fileOpHandles[$index]->httpOp );
1347 for (
$s = ( $stage + 1 );
$s < $stages; ++
$s ) {
1348 unset( $httpReqsByStage[
$s][$index] );
1384 $status->fatal(
'backend-fail-connect', $this->
name );
1389 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1391 'url' => $this->
storageUrl( $auth, $container ),
1393 'x-container-read' => implode(
',',
$readUsers ),
1394 'x-container-write' => implode(
',',
$writeUsers )
1398 if ( $rcode != 204 && $rcode !== 202 ) {
1399 $status->fatal(
'backend-fail-internal', $this->
name );
1400 $this->logger->error( __METHOD__ .
': unexpected rcode value ({rcode})',
1401 [
'rcode' => $rcode ] );
1418 if ( $bypassCache ) {
1419 $this->containerStatCache->clear( $container );
1420 } elseif ( !$this->containerStatCache->has( $container,
'stat' ) ) {
1423 if ( !$this->containerStatCache->has( $container,
'stat' ) ) {
1429 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1431 'url' => $this->
storageUrl( $auth, $container ),
1435 if ( $rcode === 204 ) {
1437 'count' => $rhdrs[
'x-container-object-count'],
1438 'bytes' => $rhdrs[
'x-container-bytes-used']
1440 if ( $bypassCache ) {
1443 $this->containerStatCache->set( $container,
'stat', $stat );
1446 } elseif ( $rcode === 404 ) {
1449 $this->
onError(
null, __METHOD__,
1450 [
'cont' => $container ], $rerr, $rcode, $rdesc );
1456 return $this->containerStatCache->get( $container,
'stat' );
1471 $status->fatal(
'backend-fail-connect', $this->
name );
1477 if ( empty(
$params[
'noAccess'] ) ) {
1479 $readUsers = array_merge( $this->readUsers, [
'.r:*', $this->swiftUser ] );
1480 $writeUsers = array_merge( $this->writeUsers, [ $this->swiftUser ] );
1483 $readUsers = array_merge( $this->secureReadUsers, [ $this->swiftUser ] );
1484 $writeUsers = array_merge( $this->secureWriteUsers, [ $this->swiftUser ] );
1487 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1489 'url' => $this->
storageUrl( $auth, $container ),
1491 'x-container-read' => implode(
',',
$readUsers ),
1492 'x-container-write' => implode(
',',
$writeUsers )
1496 if ( $rcode === 201 ) {
1498 } elseif ( $rcode === 202 ) {
1519 $status->fatal(
'backend-fail-connect', $this->
name );
1524 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1525 'method' =>
'DELETE',
1526 'url' => $this->
storageUrl( $auth, $container ),
1530 if ( $rcode >= 200 && $rcode <= 299 ) {
1531 $this->containerStatCache->clear( $container );
1532 } elseif ( $rcode === 404 ) {
1534 } elseif ( $rcode === 409 ) {
1556 $fullCont,
$type, $limit, $after =
null, $prefix =
null, $delim =
null
1562 $status->fatal(
'backend-fail-connect', $this->
name );
1567 $query = [
'limit' => $limit ];
1568 if (
$type ===
'info' ) {
1569 $query[
'format'] =
'json';
1571 if ( $after !==
null ) {
1572 $query[
'marker'] = $after;
1574 if ( $prefix !==
null ) {
1575 $query[
'prefix'] = $prefix;
1577 if ( $delim !==
null ) {
1578 $query[
'delimiter'] = $delim;
1581 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1583 'url' => $this->
storageUrl( $auth, $fullCont ),
1588 $params = [
'cont' => $fullCont,
'prefix' => $prefix,
'delim' => $delim ];
1589 if ( $rcode === 200 ) {
1590 if (
$type ===
'info' ) {
1591 $status->value = FormatJson::decode( trim( $rbody ) );
1593 $status->value = explode(
"\n", trim( $rbody ) );
1595 } elseif ( $rcode === 204 ) {
1597 } elseif ( $rcode === 404 ) {
1607 foreach ( $containerInfo as $container => $info ) {
1608 $this->containerStatCache->set( $container,
'stat', $info );
1618 foreach (
$params[
'srcs'] as $path ) {
1620 if ( $srcRel ===
null ) {
1621 $stats[
$path] =
false;
1623 } elseif ( !$auth ) {
1624 $stats[
$path] =
null;
1630 if ( $cstat ===
false ) {
1631 $stats[
$path] =
false;
1633 } elseif ( !is_array( $cstat ) ) {
1634 $stats[
$path] =
null;
1640 'url' => $this->
storageUrl( $auth, $srcCont, $srcRel ),
1645 $opts = [
'maxConnsPerHost' =>
$params[
'concurrency'] ];
1646 $reqs = $this->
http->runMulti( $reqs, $opts );
1648 foreach (
$params[
'srcs'] as $path ) {
1649 if ( array_key_exists( $path, $stats ) ) {
1653 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $reqs[
$path][
'response'];
1654 if ( $rcode === 200 || $rcode === 204 ) {
1659 if ( $this->isRGW ) {
1660 $stat[
'latest'] =
true;
1662 } elseif ( $rcode === 404 ) {
1666 $this->
onError(
null, __METHOD__,
$params, $rerr, $rcode, $rdesc );
1668 $stats[
$path] = $stat;
1682 $headers = $this->
sanitizeHdrs( [
'headers' => $rhdrs ] );
1688 'size' => isset( $rhdrs[
'content-length'] ) ? (int)$rhdrs[
'content-length'] : 0,
1689 'sha1' => isset( $metadata[
'sha1base36'] ) ? $metadata[
'sha1base36'] :
null,
1691 'md5' => ctype_xdigit( $rhdrs[
'etag'] ) ? $rhdrs[
'etag'] :
null,
1692 'xattr' => [
'metadata' => $metadata,
'headers' => $headers ]
1700 if ( $this->authErrorTimestamp !==
null ) {
1701 if ( ( time() - $this->authErrorTimestamp ) < 60 ) {
1704 $this->authErrorTimestamp =
null;
1710 if ( !$this->authCreds || $reAuth ) {
1711 $this->authSessionTimestamp = 0;
1713 $creds = $this->srvCache->get( $cacheKey );
1715 if ( isset( $creds[
'auth_token'] ) && isset( $creds[
'storage_url'] ) ) {
1716 $this->authCreds = $creds;
1718 $this->authSessionTimestamp = time() - ceil( $this->authTTL / 2 );
1720 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->
http->run( [
1722 'url' =>
"{$this->swiftAuthUrl}/v1.0",
1724 'x-auth-user' => $this->swiftUser,
1725 'x-auth-key' => $this->swiftKey
1729 if ( $rcode >= 200 && $rcode <= 299 ) {
1730 $this->authCreds = [
1731 'auth_token' => $rhdrs[
'x-auth-token'],
1732 'storage_url' => ( $this->swiftStorageUrl !== null )
1733 ? $this->swiftStorageUrl
1734 : $rhdrs[
'x-storage-url']
1737 $this->srvCache->set( $cacheKey, $this->authCreds, ceil( $this->authTTL / 2 ) );
1738 $this->authSessionTimestamp = time();
1739 } elseif ( $rcode === 401 ) {
1740 $this->
onError(
null, __METHOD__, [],
"Authentication failed.", $rcode );
1741 $this->authErrorTimestamp = time();
1745 $this->
onError(
null, __METHOD__, [],
"HTTP return code: $rcode", $rcode );
1746 $this->authErrorTimestamp = time();
1752 if ( substr( $this->authCreds[
'storage_url'], -3 ) ===
'/v1' ) {
1753 $this->isRGW =
true;
1766 protected function storageUrl( array $creds, $container =
null, $object =
null ) {
1767 $parts = [ $creds[
'storage_url'] ];
1768 if ( strlen( $container ) ) {
1769 $parts[] = rawurlencode( $container );
1771 if ( strlen( $object ) ) {
1772 $parts[] = str_replace(
"%2F",
"/", rawurlencode( $object ) );
1775 return implode(
'/', $parts );
1783 return [
'x-auth-token' => $creds[
'auth_token'] ];
1793 return 'swiftcredentials:' . md5(
$username .
':' . $this->swiftAuthUrl );
1809 $status->fatal(
'backend-fail-internal', $this->
name );
1811 if (
$code == 401 ) {
1814 $msg =
"HTTP {code} ({desc}) in '{func}' (given '{params}')";
1819 'req_params' => FormatJson::encode(
$params ),
1823 $msgParams[
'err'] = $err;
1825 $this->logger->error( $msg, $msgParams );
1892 $this->container = $fullCont;
1894 if ( substr( $this->dir, -1 ) ===
'/' ) {
1895 $this->dir = substr( $this->dir, 0, -1 );
1897 if ( $this->dir ==
'' ) {
1898 $this->suffixStart = 0;
1900 $this->suffixStart = strlen( $this->dir ) + 1;
1918 next( $this->bufferIter );
1922 if ( !$this->
valid() && count( $this->bufferIter ) ) {
1924 $this->container, $this->dir, $this->bufferAfter, self::PAGE_SIZE, $this->params
1934 $this->bufferAfter =
null;
1936 $this->container, $this->dir, $this->bufferAfter, self::PAGE_SIZE, $this->params
1945 if ( $this->bufferIter ===
null ) {
1948 return ( current( $this->bufferIter ) !==
false );
1974 return substr(
current( $this->bufferIter ), $this->suffixStart, -1 );
1991 list( $path, $stat ) =
current( $this->bufferIter );
1992 $relPath = substr( $path, $this->suffixStart );
1993 if ( is_array( $stat ) ) {
1994 $storageDir = rtrim( $this->params[
'dir'],
'/' );
1995 $this->backend->loadListingStatInternal(
"$storageDir/$relPath", $stat );
Apache License January http
interface is intended to be more or less compatible with the PHP memcached client.
A BagOStuff object with no objects in it.
File backend exception for checked exceptions (e.g.
FileBackendStore helper class for performing asynchronous file operations.
FileBackendStore $backend
Base class for all backends using particular storage medium.
setContainerCache( $container, array $val)
Set the cached info for a container.
executeOpHandlesInternal(array $fileOpHandles)
Execute a list of FileBackendStoreOpHandle handles in parallel.
getFileStat(array $params)
Get quick information about a file at a storage path in the backend.
resolveStoragePathReal( $storagePath)
Like resolveStoragePath() except null values are returned if the container is sharded and the shard c...
clearCache(array $paths=null)
Invalidate any in-process file stat and property cache.
primeContainerCache(array $items)
Do a batch lookup from cache for container stats for all containers used in a list of container names...
deleteFileCache( $path)
Delete the cached stat info for a file path.
getContentType( $storagePath, $content, $fsPath)
Get the content type to use in HEAD/GET requests for a file.
fileExists(array $params)
Check if a file exists at a storage path in the backend.
getLocalCopy(array $params)
Get a local copy on disk of the file at a storage path in the backend.
string $name
Unique backend name.
static extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
getScopedFileLocks(array $paths, $type, StatusValue $status, $timeout=0)
Lock the files at the given storage paths in the backend.
newStatus()
Yields the result of the status wrapper callback on either:
scopedProfileSection( $section)
const ATTR_HEADERS
Bitfield flags for supported features.
Library for creating and parsing MW-style timestamps.
Class to handle concurrent HTTP requests.
Class for process caching individual properties of expiring items.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
static send404Message( $fname, $flags=0)
Send out a standard 404 message for a file.
Iterator for listing directories.
pageFromList( $container, $dir, &$after, $limit, array $params)
Get the given list portion (page)
Iterator for listing regular files.
pageFromList( $container, $dir, &$after, $limit, array $params)
Get the given list portion (page)
SwiftFileBackend helper class to page through listings.
string $dir
Storage directory.
string $container
Container name.
__construct(SwiftFileBackend $backend, $fullCont, $dir, array $params)
string $bufferAfter
List items after this path.
pageFromList( $container, $dir, &$after, $limit, array $params)
Get the given list portion (page)
array $bufferIter
List of path or (path,stat array) entries.
SwiftFileBackend $backend
Class for an OpenStack Swift (or Ceph RGW) based file backend.
string $swiftUser
Swift user (account:user) to authenticate as.
sanitizeHdrs(array $params)
Sanitize and filter the custom headers from a $params array.
string $swiftAuthUrl
Authentication base URL (without version)
string $swiftTempUrlKey
Shared secret value for making temp URLs.
isPathUsableInternal( $storagePath)
Check if a file can be created or changed at a given storage path.
getDirListPageInternal( $fullCont, $dir, &$after, $limit, array $params)
Do not call this function outside of SwiftFileBackendFileList.
doPublishInternal( $fullCont, $dir, array $params)
doCreateInternal(array $params)
doGetFileStatMulti(array $params)
Get file stat information (concurrently if possible) for several files.
doGetFileSha1base36(array $params)
array $writeUsers
Additional users (account:user) with write permissions on public containers.
__construct(array $config)
doGetFileXAttributes(array $params)
onError( $status, $func, array $params, $err='', $code=0, $desc='')
Log an unexpected exception for this backend.
buildFileObjectListing(array $params, $dir, array $objects)
Build a list of file objects, filtering out any directories and extracting any stat info if provided ...
authTokenHeaders(array $creds)
getStatFromHeaders(array $rhdrs)
string $swiftStorageUrl
Override of storage base URL.
createContainer( $container, array $params)
Create a Swift container.
doCopyInternal(array $params)
getCredsCacheKey( $username)
Get the cache key for a container.
getDirectoryListInternal( $fullCont, $dir, array $params)
string $rgwS3AccessKey
S3 access key (RADOS Gateway)
setContainerAccess( $container, array $readUsers, array $writeUsers)
Set read/write permissions for a Swift container.
getFileHttpUrl(array $params)
array $secureWriteUsers
Additional users (account:user) with write permissions on private containers.
getCustomHeaders(array $rawHeaders)
int $authTTL
TTL in seconds.
headersFromParams(array $params)
Get headers to send to Swift when reading a file based on a FileBackend params array,...
getMetadata(array $rawHeaders)
bool $isRGW
Whether the server is an Ceph RGW.
addMissingMetadata(array $objHdrs, $path)
Fill in any missing object metadata and save it to Swift.
doStoreInternal(array $params)
int $authErrorTimestamp
UNIX timestamp.
getMetadataHeaders(array $rawHeaders)
int $authSessionTimestamp
UNIX timestamp.
loadListingStatInternal( $path, array $val)
Do not call this function outside of SwiftFileBackendFileList.
doPrepareInternal( $fullCont, $dir, array $params)
doSecureInternal( $fullCont, $dir, array $params)
getFileListInternal( $fullCont, $dir, array $params)
doMoveInternal(array $params)
getFeatures()
Get the a bitfield of extra features supported by the backend medium.
deleteContainer( $container, array $params)
Delete a Swift container.
doGetFileStat(array $params)
doGetLocalCopyMulti(array $params)
string $rgwS3SecretKey
S3 authentication key (RADOS Gateway)
doGetFileContentsMulti(array $params)
storageUrl(array $creds, $container=null, $object=null)
convertSwiftDate( $ts, $format=TS_MW)
Convert dates like "Tue, 03 Jan 2012 22:01:04 GMT"/"2013-05-11T07:37:27.678360Z".
doStreamFile(array $params)
doPrimeContainerCache(array $containerInfo)
Fill the backend-specific process cache given an array of resolved container names and their correspo...
sanitizeHdrsStrict(array $params)
Sanitize and filter the custom headers from a $params array.
resolveContainerPath( $container, $relStoragePath)
Resolve a relative storage path, checking if it's allowed by the backend.
array $readUsers
Additional users (account:user) with read permissions on public containers.
array $secureReadUsers
Additional users (account:user) with read permissions on private containers.
doCleanInternal( $fullCont, $dir, array $params)
ProcessCacheLRU $containerStatCache
Container stat cache.
getFileListPageInternal( $fullCont, $dir, &$after, $limit, array $params)
Do not call this function outside of SwiftFileBackendFileList.
string $swiftKey
Secret key for user.
doDirectoryExists( $fullCont, $dir, array $params)
objectListing( $fullCont, $type, $limit, $after=null, $prefix=null, $delim=null)
Get a list of objects under a container.
directoriesAreVirtual()
Is this a key/value store where directories are just virtual? Virtual directories exists in so much a...
doExecuteOpHandlesInternal(array $fileOpHandles)
doDeleteInternal(array $params)
doDescribeInternal(array $params)
getContainerStat( $container, $bypassCache=false)
Get a Swift container stat array, possibly from process cache.
array $httpOp
List of Requests for MultiHttpClient.
__construct(SwiftFileBackend $backend, Closure $callback, array $httpOp)
static factory( $prefix, $extension='', $tmpDirectory=null)
Make a new temporary file on the file system.
Multi-datacenter aware caching interface.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this hook is for auditing only $req
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
this hook is for auditing only or null if authentication failed before getting that far $username
> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) name
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
if(!is_readable( $file)) $ext