MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/98006


Change subject: Introduce new mobileview parameter, onlyrequestedsections
......................................................................

Introduce new mobileview parameter, onlyrequestedsections

Allows to reduce response size for new app versions being developed. I know
it's ugly as hell, but only this way b/c can be preserved.

Bug: 57440
Change-Id: Ie0d93918ab0fff49a2b6f0afd72e390e90d6dd10
---
M includes/api/ApiMobileView.php
M tests/ApiMobileViewTest.php
2 files changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/06/98006/1

diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index 81cc42e..57d6b82 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -37,6 +37,7 @@
                $this->followRedirects = $params['redirect'] == 'yes';
                $this->noHeadings = $params['noheadings'];
                $this->noTransform = $params['notransform'];
+               $onlyRequestedSections = $params['onlyrequestedsections'];
                $this->offset = $params['offset'];
                $this->maxlen = $params['maxlen'];
 
@@ -87,6 +88,9 @@
                }
                if ( isset( $prop['sections'] ) ) {
                        for ( $i = 0; $i <= count( $data['sections'] ); $i++ ) {
+                               if ( !isset( $requestedSections[$i] ) && 
$onlyRequestedSections ) {
+                                       continue;
+                               }
                                $section = array();
                                if ( $i > 0 ) {
                                        $section = array_intersect_key( 
$data['sections'][$i - 1], $sectionProp );
@@ -431,6 +435,7 @@
                        'noimages' => false,
                        'noheadings' => false,
                        'notransform' => false,
+                       'onlyrequestedsections' => false,
                        'offset' => array(
                                ApiBase::PARAM_TYPE => 'integer',
                                ApiBase::PARAM_MIN => 0,
@@ -466,6 +471,7 @@
                        'noimages' => 'Return HTML without images',
                        'noheadings' => "Don't include headings in output",
                        'notransform' => "Don't transform HTML into 
mobile-specific version",
+                       'onlyrequestedsections' => 'Return only requested 
sections even with prop=sections',
                        'offset' => 'Pretend all text result is one string, and 
return the substring starting at this point',
                        'maxlen' => 'Pretend all text result is one string, and 
limit result to this length',
                );
diff --git a/tests/ApiMobileViewTest.php b/tests/ApiMobileViewTest.php
index 6796a89..20188db 100644
--- a/tests/ApiMobileViewTest.php
+++ b/tests/ApiMobileViewTest.php
@@ -157,6 +157,14 @@
                                        ),
                                ),
                        ),
+                       array(
+                               array( 'sections' => 1, 'onlyrequestedsections' 
=> '' ) + $baseIn,
+                               array(
+                                       'sections' => array(
+                                               $baseOut['sections'][1],
+                                       ),
+                               ),
+                       ),
                );
        }
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/98006
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie0d93918ab0fff49a2b6f0afd72e390e90d6dd10
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to