r75280 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75279‎ | r75280 | r75281 >
Date:17:48, 23 October 2010
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
Revert r70703 and followup r70715: broke &redirect for API edit with a fatal error
Modified paths:
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -57,16 +57,36 @@
5858 if ( !$titleObj || $titleObj->isExternal() ) {
5959 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
6060 }
 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 );
6189
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 );
6790 }
68 -
69 - $this->getResult()->setIndexedTagName( $redirValues, 'r' );
70 - $this->getResult()->addValue( null, 'redirects', $redirValues );
7191 }
7292
7393 // Some functions depend on $wgTitle == $ep->mTitle

Follow-up revisions

RevisionCommit summaryAuthorDate
r90490* (bug 29278) server error 500 when attempting to add text to a page via redi...reedy22:32, 20 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70703Followup to r70658: Code styling, use ApiPageSet to fix redirects.soxred9315:03, 8 August 2010
r70715follow-up to r70703: converted spaces to tabs and trimmed trailing spacesashley16:45, 8 August 2010

Comments

#Comment by Bryan (talk | contribs)   20:12, 16 November 2010

Ideally this would use ApiPageSet, but then implemented properly.

Status & tagging log