r97076 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97075‎ | r97076 | r97077 >
Date:17:38, 14 September 2011
Author:preilly
Status:ok
Tags:
Comment:
fix for r97026 based on c22503
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -707,13 +707,8 @@
708708 return $s;
709709 }
710710
711 - private function removeQuerystringVar( $url, $key ) {
712 - $url = preg_replace( '/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&' );
713 - $url = substr( $url, 0, -1 );
714 - return ( $url );
715 - }
716 -
717711 private function createWMLCard( $s ) {
 712+ global $wgRequest;
718713 wfProfileIn( __METHOD__ );
719714 $segments = explode( $this->WMLSectionSeperator, $s );
720715 $card = '';
@@ -727,20 +722,28 @@
728723 $card .= "<p>" . $idx . "/" . $segmentsCount . "</p>";
729724
730725 $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : '';
731 -
732 - $basePage = self::$currentURL;
733 -
734 - $basePage = $this->removeQuerystringVar( $this->removeQuerystringVar( $basePage, 'useformat' ), 'seg' );
735 -
736 - $delimiter = ( strpos( $basePage, '?' ) === false ) ? '?' : '&';
737726
 727+ // Title::getLocalUrl doesn't work at this point since PHP 5.1.x, all objects have their destructors called
 728+ // before the output buffer callback function executes.
 729+ // Thus, globalized objects will not be available as expected in the function.
 730+ // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104]
 731+ $mDefaultQuery = $wgRequest->getQueryValues();
 732+ unset( $mDefaultQuery['seg'] );
 733+ unset( $mDefaultQuery['useformat'] );
 734+
 735+ $qs = wfArrayToCGI( $mDefaultQuery );
 736+ $delimiter = ( !empty( $qs ) ) ? '?' : '';
 737+ $basePageParts = wfParseUrl( self::$currentURL );
 738+ $basePage = $basePageParts['scheme'] . $basePageParts['delimiter'] . $basePageParts['host'] . $basePageParts['path'] . $delimiter . $qs;
 739+ $appendDelimiter = ( $delimiter === '?' ) ? '&' : '?';
 740+
738741 if ( $idx < $segmentsCount ) {
739 - $card .= "<p><a href=\"{$basePage}{$delimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>";
 742+ $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>";
740743 }
741744
742745 if ( $idx > 1 ) {
743746 $back_idx = $requestedSegment - 1;
744 - $card .= "<p><a href=\"{$basePage}{$delimiter}seg={$back_idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-back'] . "</a></p>";
 747+ $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$back_idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-back'] . "</a></p>";
745748 }
746749
747750 $card .= '</card>';
@@ -931,6 +934,8 @@
932935 && empty( self::$search ) && !self::$isMainPage ) {
933936 $contentHtml = $this->headingTransform( $contentHtml );
934937 } elseif ( $this->contentFormat == 'WML' ) {
 938+ $homeButton = self::$messages['mobile-frontend-home-button'];
 939+ $randomButton = self::$messages['mobile-frontend-random-button'];
935940 //header( 'Content-Type: text/vnd.wap.wml' );
936941
937942 // TODO: Content transformations required

Follow-up revisions

RevisionCommit summaryAuthorDate
r97215mft r97214 and r97076preilly22:14, 15 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97026fix for wml view pagination linkspreilly00:16, 14 September 2011

Status & tagging log