Replace deprecated Title::getCdnUrls
Change-Id: Ie3cd9ebd6ef442af19a054a1bb81e5c3574fb2bb
This commit is contained in:
parent
08f18cf94b
commit
1b80321f39
5 changed files with 21 additions and 15 deletions
|
|
@ -517,14 +517,16 @@ class MediaWiki {
|
|||
}
|
||||
|
||||
# Let CDN cache things if we can purge them.
|
||||
if ( $this->config->get( 'UseCdn' ) &&
|
||||
in_array(
|
||||
// Use PROTO_INTERNAL because that's what getCdnUrls() uses
|
||||
wfExpandUrl( $request->getRequestURL(), PROTO_INTERNAL ),
|
||||
$requestTitle->getCdnUrls()
|
||||
)
|
||||
) {
|
||||
$output->setCdnMaxage( $this->config->get( 'CdnMaxAge' ) );
|
||||
if ( $this->config->get( 'UseCdn' ) ) {
|
||||
$htmlCacheUpdater = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
|
||||
if ( in_array(
|
||||
// Use PROTO_INTERNAL because that's what HtmlCacheUpdater::getUrls() uses
|
||||
wfExpandUrl( $request->getRequestURL(), PROTO_INTERNAL ),
|
||||
$htmlCacheUpdater->getUrls( $requestTitle )
|
||||
)
|
||||
) {
|
||||
$output->setCdnMaxage( $this->config->get( 'CdnMaxAge' ) );
|
||||
}
|
||||
}
|
||||
|
||||
$action->show();
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class RawAction extends FormlessAction {
|
|||
$contentType == 'text/javascript'
|
||||
) {
|
||||
// CSS/JSON/JS raw content has its own CDN max age configuration.
|
||||
// Note: Title::getCdnUrls() includes action=raw for css/json/js
|
||||
// Note: HtmlCacheUpdater::getUrls() includes action=raw for css/json/js
|
||||
// pages, so if using the canonical url, this will get HTCP purges.
|
||||
$smaxage = intval( $config->get( 'ForcedRawSMaxage' ) );
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -159,10 +159,11 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
* @return int[] Map of (URL => rebound purge delay)
|
||||
*/
|
||||
private function resolveReboundDelayByUrl() {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
/** @var Title $title */
|
||||
|
||||
// Avoid multiple queries for getCdnUrls() call
|
||||
$lb = MediaWikiServices::getInstance()->getLinkBatchFactory()->newLinkBatch();
|
||||
// Avoid multiple queries for HtmlCacheUpdater::getUrls() call
|
||||
$lb = $services->getLinkBatchFactory()->newLinkBatch();
|
||||
foreach ( $this->titleTuples as list( $title, $delay ) ) {
|
||||
$lb->addObj( $title );
|
||||
}
|
||||
|
|
@ -171,8 +172,9 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
$reboundDelayByUrl = [];
|
||||
|
||||
// Resolve the titles into CDN URLs
|
||||
$htmlCacheUpdater = $services->getHtmlCacheUpdater();
|
||||
foreach ( $this->titleTuples as list( $title, $delay ) ) {
|
||||
foreach ( $title->getCdnUrls() as $url ) {
|
||||
foreach ( $htmlCacheUpdater->getUrls( $title ) as $url ) {
|
||||
// Use the highest rebound for duplicate URLs in order to handle the most lag
|
||||
$reboundDelayByUrl[$url] = max( $reboundDelayByUrl[$url] ?? 0, $delay );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -871,7 +871,7 @@ class FileRepo {
|
|||
public function getDescriptionStylesheetUrl() {
|
||||
if ( isset( $this->scriptDirUrl ) ) {
|
||||
// Must match canonical query parameter order for optimum caching
|
||||
// See Title::getCdnUrls
|
||||
// See HtmlCacheUpdater::getUrls
|
||||
return $this->makeUrl( 'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class PurgeList extends Maintenance {
|
|||
private function doPurge() {
|
||||
$stdin = $this->getStdin();
|
||||
$urls = [];
|
||||
$htmlCacheUpdater = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
|
||||
|
||||
while ( !feof( $stdin ) ) {
|
||||
$page = trim( fgets( $stdin ) );
|
||||
|
|
@ -92,7 +93,7 @@ class PurgeList extends Maintenance {
|
|||
} elseif ( $page !== '' ) {
|
||||
$title = Title::newFromText( $page );
|
||||
if ( $title ) {
|
||||
$newUrls = $title->getCdnUrls();
|
||||
$newUrls = $htmlCacheUpdater->getUrls( $title );
|
||||
|
||||
foreach ( $newUrls as $url ) {
|
||||
$this->output( "$url\n" );
|
||||
|
|
@ -119,6 +120,7 @@ class PurgeList extends Maintenance {
|
|||
*/
|
||||
private function purgeNamespace( $namespace = false ) {
|
||||
$dbr = $this->getDB( DB_REPLICA );
|
||||
$htmlCacheUpdater = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
|
||||
$startId = 0;
|
||||
if ( $namespace === false ) {
|
||||
$conds = [];
|
||||
|
|
@ -142,7 +144,7 @@ class PurgeList extends Maintenance {
|
|||
$urls = [];
|
||||
foreach ( $res as $row ) {
|
||||
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
|
||||
$urls = array_merge( $urls, $title->getCdnUrls() );
|
||||
$urls = array_merge( $urls, $htmlCacheUpdater->getUrls( $title ) );
|
||||
$startId = $row->page_id;
|
||||
}
|
||||
$this->sendPurgeRequest( $urls );
|
||||
|
|
|
|||
Loading…
Reference in a new issue