| Index: trunk/phase3/includes/api/ApiEditPage.php |
| — | — | @@ -57,16 +57,36 @@ |
| 58 | 58 | if ( !$titleObj || $titleObj->isExternal() ) { |
| 59 | 59 | $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); |
| 60 | 60 | } |
| | 61 | + |
| | 62 | + if( $params['redirect'] ) { |
| | 63 | + if( $titleObj->isRedirect() ) { |
| | 64 | + $oldTitle = $titleObj; |
| | 65 | + |
| | 66 | + $titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) ); |
| | 67 | + //array_shift( $titles ); |
| | 68 | + |
| | 69 | + $this->getResult()->addValue( null, 'foo', $titles ); |
| | 70 | + |
| | 71 | + |
| | 72 | + $redirValues = array(); |
| | 73 | + foreach ( $titles as $id => $newTitle ) { |
| | 74 | + |
| | 75 | + if( !isset( $titles[ $id - 1 ] ) ) { |
| | 76 | + $titles[ $id - 1 ] = $oldTitle; |
| | 77 | + } |
| | 78 | + |
| | 79 | + $redirValues[] = array( |
| | 80 | + 'from' => $titles[ $id - 1 ]->getPrefixedText(), |
| | 81 | + 'to' => $newTitle->getPrefixedText() |
| | 82 | + ); |
| | 83 | + |
| | 84 | + $titleObj = $newTitle; |
| | 85 | + } |
| | 86 | + |
| | 87 | + $this->getResult()->setIndexedTagName( $redirValues, 'r' ); |
| | 88 | + $this->getResult()->addValue( null, 'redirects', $redirValues ); |
| 61 | 89 | |
| 62 | | - if( $params['redirect'] && $titleObj->isRedirect() ) { |
| 63 | | - $pageSet = new ApiPageSet( $this->getQuery(), true ); // Or true, true to also do variant conversion of titles |
| 64 | | - $pageSet->populateFromTitles( array( $titleObj ) ); |
| 65 | | - foreach ( $pageSet->getRedirectTitles() as $from => $to ) { |
| 66 | | - $redirsValues[] = array( 'from' => $from, 'to' => $to ); |
| 67 | 90 | } |
| 68 | | - |
| 69 | | - $this->getResult()->setIndexedTagName( $redirValues, 'r' ); |
| 70 | | - $this->getResult()->addValue( null, 'redirects', $redirValues ); |
| 71 | 91 | } |
| 72 | 92 | |
| 73 | 93 | // Some functions depend on $wgTitle == $ep->mTitle |