* @return Title Title object to be $wgTitle
*/
private function parseTitle() {
- global $wgContLang;
-
$request = $this->context->getRequest();
$curid = $request->getInt( 'curid' );
$title = $request->getVal( 'title' );
if ( !is_null( $ret ) && $ret->getNamespace() == NS_MEDIA ) {
$ret = Title::makeTitle( NS_FILE, $ret->getDBkey() );
}
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
// Check variant links so that interwiki links don't have to worry
// about the possible different language variants
- if ( count( $wgContLang->getVariants() ) > 1
- && !is_null( $ret ) && $ret->getArticleID() == 0
+ if (
+ $contLang->hasVariants() && !is_null( $ret ) && $ret->getArticleID() == 0
) {
- $wgContLang->findVariantLink( $title, $ret );
+ $contLang->findVariantLink( $title, $ret );
}
}
if ( $ret === null || !$ret->isSpecialPage() ) {
// We can have urls with just ?diff=,?oldid= or even just ?diff=
$oldid = $request->getInt( 'oldid' );
- $oldid = $oldid ? $oldid : $request->getInt( 'diff' );
+ $oldid = $oldid ?: $request->getInt( 'diff' );
// Allow oldid to override a changed or missing title
if ( $oldid ) {
$rev = Revision::newFromId( $oldid );
// Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ( !$this->tryNormaliseRedirect( $title ) ) {
// Prevent information leak via Special:MyPage et al (T109724)
+ $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
if ( $title->isSpecialPage() ) {
- $specialPage = SpecialPageFactory::getPage( $title->getDBkey() );
+ $specialPage = $spFactory->getPage( $title->getDBkey() );
if ( $specialPage instanceof RedirectSpecialPage ) {
$specialPage->setContext( $this->context );
if ( $this->config->get( 'HideIdentifiableRedirects' )
&& $specialPage->personallyIdentifiableTarget()
) {
- list( , $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( , $subpage ) = $spFactory->resolveAlias( $title->getDBkey() );
$target = $specialPage->getRedirect( $subpage );
// target can also be true. We let that case fall through to normal processing.
if ( $target instanceof Title ) {
// Special pages ($title may have changed since if statement above)
if ( $title->isSpecialPage() ) {
// Actions that need to be made when we have a special pages
- SpecialPageFactory::executePath( $title, $this->context );
+ $spFactory->executePath( $title, $this->context );
} else {
// ...otherwise treat it as an article view. The article
// may still be a wikipage redirect to another article or URL.
}
if ( $title->isSpecialPage() ) {
- list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $title->getDBkey() );
if ( $name ) {
$title = SpecialPage::getTitleFor( $name, $subpage );
}
// If $target is set, then a hook wanted to redirect.
if ( !$ignoreRedirect && ( $target || $page->isRedirect() ) ) {
// Is the target already set by an extension?
- $target = $target ? $target : $page->followRedirect();
+ $target = $target ?: $page->followRedirect();
if ( is_string( $target ) ) {
if ( !$this->config->get( 'DisableHardRedirects' ) ) {
// we'll need to redirect
/**
* @see MediaWiki::preOutputCommit()
- * @param callable $postCommitWork [default: null]
+ * @param callable|null $postCommitWork [default: null]
* @since 1.26
*/
public function doPreOutputCommit( callable $postCommitWork = null ) {
* the user can receive a response (in case commit fails)
*
* @param IContextSource $context
- * @param callable $postCommitWork [default: null]
+ * @param callable|null $postCommitWork [default: null]
* @since 1.27
*/
public static function preOutputCommit(
// Record ChronologyProtector positions for DBs affected in this request at this point
$cpIndex = null;
- $lbFactory->shutdown( $flags, $postCommitWork, $cpIndex );
+ $cpClientId = null;
+ $lbFactory->shutdown( $flags, $postCommitWork, $cpIndex, $cpClientId );
wfDebug( __METHOD__ . ': LBFactory shutdown completed' );
if ( $cpIndex > 0 ) {
$now = time();
$expires = $now + ChronologyProtector::POSITION_COOKIE_TTL;
$options = [ 'prefix' => '' ];
- $value = LBFactory::makeCookieValueFromCPIndex( $cpIndex, $now ); // T190082
+ $value = LBFactory::makeCookieValueFromCPIndex( $cpIndex, $now, $cpClientId );
$request->response()->setCookie( 'cpPosIndex', $value, $expires, $options );
}
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
}
+ // Disable WebResponse setters for post-send processing (T191537).
+ WebResponse::disableForPostSend();
+
$blocksHttpClient = true;
// Defer everything else if possible...
$callback = function () use ( $mode, &$blocksHttpClient ) {
$this->performRequest();
// GUI-ify and stash the page output in MediaWiki::doPreOutputCommit() while
- // ChronologyProtector synchronizes DB positions or replicas accross all datacenters.
+ // ChronologyProtector synchronizes DB positions or replicas across all datacenters.
$buffer = null;
$outputWork = function () use ( $output, &$buffer ) {
if ( $buffer === null ) {
try {
$statsdServer = explode( ':', $config->get( 'StatsdServer' ) );
$statsdHost = $statsdServer[0];
- $statsdPort = isset( $statsdServer[1] ) ? $statsdServer[1] : 8125;
+ $statsdPort = $statsdServer[1] ?? 8125;
$statsdSender = new SocketSender( $statsdHost, $statsdPort );
$statsdClient = new SamplingStatsdClient( $statsdSender, true, false );
$statsdClient->setSamplingRates( $config->get( 'StatsdSamplingRates' ) );
$invokedWithSuccess = true;
if ( $sock ) {
- $special = SpecialPageFactory::getPage( 'RunJobs' );
+ $special = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getPage( 'RunJobs' );
$url = $special->getPageTitle()->getCanonicalURL( $query );
$req = (
"POST $url HTTP/1.1\r\n" .