API: Don't apply size limit to action=compare
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 8 Jan 2018 14:21:23 +0000 (09:21 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 8 Jan 2018 14:37:35 +0000 (09:37 -0500)
Some diffs can be really huge. Since ApiComparePages is intended to
return only the diff and some small metadata, bypass $wgAPIMaxResultSize
to allow the diff to be returned even if it's insanely huge.

Really insanely huge diffs might still make PHP run out of memory, even
before it gets the chance to return the diff to the API. That is outside
the scope of this change.

Bug: T184412
Change-Id: I755417f573c3caf85031d03b262aa55bd8cf36d7

includes/api/ApiComparePages.php

index 5486594..375fc18 100644 (file)
@@ -167,7 +167,10 @@ class ApiComparePages extends ApiBase {
                        ApiResult::setContentValue( $vals, 'body', $difftext );
                }
 
-               $this->getResult()->addValue( null, $this->getModuleName(), $vals );
+               // Diffs can be really big and there's little point in having
+               // ApiResult truncate it to an empty response since the diff is the
+               // whole reason this module exists. So pass NO_SIZE_CHECK here.
+               $this->getResult()->addValue( null, $this->getModuleName(), $vals, ApiResult::NO_SIZE_CHECK );
        }
 
        /**