From: X! Date: Sun, 8 Aug 2010 15:03:30 +0000 (+0000) Subject: Followup to r70658: Code styling, use ApiPageSet to fix redirects. X-Git-Tag: 1.31.0-rc.0~35607 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=04e6adbbd99e4d10bc365d7c60fee862450a9946;p=lhc%2Fweb%2Fwiklou.git Followup to r70658: Code styling, use ApiPageSet to fix redirects. --- diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 1c165b6450..6c4142aca1 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -58,35 +58,17 @@ class ApiEditPage extends ApiBase { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } - if( $params['redirect'] ) { - if( $titleObj->isRedirect() ) { - $oldTitle = $titleObj; - - $titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) ); - //array_shift( $titles ); - - $this->getResult()->addValue( null, 'foo', $titles ); - - - $redirValues = array(); - foreach ( $titles as $id => $newTitle ) { - - if( !isset( $titles[ $id - 1 ] ) ) { - $titles[ $id - 1 ] = $oldTitle; - } - - $redirValues[] = array( - 'from' => $titles[ $id - 1 ]->getPrefixedText(), - 'to' => $newTitle->getPrefixedText() - ); - - $titleObj = $newTitle; - } - - $this->getResult()->setIndexedTagName( $redirValues, 'r' ); - $this->getResult()->addValue( null, 'redirects', $redirValues ); - + if( $params['redirect'] && $titleObj->isRedirect() ) { + + $pageSet = new ApiPageSet( $this->getQuery(), true ); // Or true, true to also do variant conversion of titles + $pageSet->populateFromTitles( array( $titleObj ) ); + foreach ( $pageSet->getRedirectTitles() as $from => $to ) { + $redirsValues[] = array( 'from' => $from, 'to' => $to ); } + + + $this->getResult()->setIndexedTagName( $redirValues, 'r' ); + $this->getResult()->addValue( null, 'redirects', $redirValues ); } // Some functions depend on $wgTitle == $ep->mTitle