Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -58,35 +58,17 @@ |
59 | 59 | $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); |
60 | 60 | } |
61 | 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 ); |
89 | | - |
| 62 | + if( $params['redirect'] && $titleObj->isRedirect() ) { |
| 63 | + |
| 64 | + $pageSet = new ApiPageSet( $this->getQuery(), true ); // Or true, true to also do variant conversion of titles |
| 65 | + $pageSet->populateFromTitles( array( $titleObj ) ); |
| 66 | + foreach ( $pageSet->getRedirectTitles() as $from => $to ) { |
| 67 | + $redirsValues[] = array( 'from' => $from, 'to' => $to ); |
90 | 68 | } |
| 69 | + |
| 70 | + |
| 71 | + $this->getResult()->setIndexedTagName( $redirValues, 'r' ); |
| 72 | + $this->getResult()->addValue( null, 'redirects', $redirValues ); |
91 | 73 | } |
92 | 74 | |
93 | 75 | // Some functions depend on $wgTitle == $ep->mTitle |