r112315 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112314‎ | r112315 | r112316 >
Date:11:47, 24 February 2012
Author:wikinaut
Status:reverted
Tags:gerritmigration 
Comment:
improved code legibility function namespacePrefixedQuery
Modified paths:
  • /trunk/extensions/RSS/RSSData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RSS/RSSData.php
@@ -28,14 +28,12 @@
2929 $defaultNS = "";
3030 }
3131
32 - $q = "/rss/channel/item";
33 - $q = preg_replace( '#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $defaultNS . '$2', $q );
34 - $items = $xpath->query( $q ); // is it an RSS feed ?
 32+ // is it an RSS feed ?
 33+ $items = $xpath->query( $this->namespacePrefixedQuery( "/rss/channel/item", $defaultNS ) );
3534
3635 if ( $items->length === 0 ) {
37 - $q = "/feed/entry";
38 - $q = preg_replace( '#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $defaultNS . '$2', $q );
39 - $items = $xpath->query( $q ); // is it an ATOM feed ?
 36+ // or is it an ATOM feed ?
 37+ $items = $xpath->query( $this->namespacePrefixedQuery( "/feed/entry", $defaultNS ) );
4038 }
4139
4240 if( $items->length !== 0 ) {
@@ -63,6 +61,14 @@
6462 }
6563 }
6664
 65+ protected function namespacePrefixedQuery( $query, $namespace = "" ) {
 66+ if ( $namespace !== "" ) {
 67+ $ret = preg_replace( '#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' . $namespace . '$2', $query );
 68+ } else {
 69+ $ret = $query;
 70+ }
 71+ return $ret;
 72+ }
6773 /**
6874 * Return a string that will be used to map RSS elements that
6975 * contain similar data (e.g. dc:date, date, and pubDate) to the

Follow-up revisions

RevisionCommit summaryAuthorDate
r114390Revert r111347, r111348, r111350, r111351, r111515, r111816, r112243, r112251......catrope18:40, 21 March 2012

Status & tagging log