r70703 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70702‎ | r70703 | r70704 >
Date:15:03, 8 August 2010
Author:soxred93
Status:reverted (Comments)
Tags:
Comment:
Followup to r70658: Code styling, use ApiPageSet to fix redirects.
Modified paths:
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -58,35 +58,17 @@
5959 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
6060 }
6161
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 );
9068 }
 69+
 70+
 71+ $this->getResult()->setIndexedTagName( $redirValues, 'r' );
 72+ $this->getResult()->addValue( null, 'redirects', $redirValues );
9173 }
9274
9375 // Some functions depend on $wgTitle == $ep->mTitle

Follow-up revisions

RevisionCommit summaryAuthorDate
r70715follow-up to r70703: converted spaces to tabs and trimmed trailing spacesashley16:45, 8 August 2010
r75280Revert r70703 and followup r70715: broke &redirect for API edit with a fatal ...catrope17:48, 23 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70658(bug 24330) Add &redirect parameter to ?action=editsoxred9301:14, 8 August 2010

Comments

#Comment by Bryan (talk | contribs)   19:32, 10 September 2010

Am I missing some magic that ApiPageSet does or are you not overwritting $titleObj anymore?

#Comment by Reedy (talk | contribs)   18:28, 20 October 2010

Also, $this->getQuery() doesn't exist

Status & tagging log