Merge "api: Remove 'recenteditcount' set for BC to be removed in 1.25"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 16 Apr 2019 21:13:58 +0000 (21:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 16 Apr 2019 21:13:58 +0000 (21:13 +0000)
includes/api/ApiQueryAllRevisions.php
includes/api/ApiQueryRevisions.php
maintenance/storage/testCompression.php
tests/phpunit/includes/RevisionDbTestBase.php
tests/phpunit/includes/RevisionMcrWriteBothDbTest.php
tests/phpunit/includes/RevisionNoContentModelDbTest.php
tests/phpunit/includes/RevisionPreMcrDbTest.php
tests/phpunit/includes/api/query/ApiQueryAllRevisionsTest.php [new file with mode: 0644]

index 75d75ec..58445a1 100644 (file)
@@ -82,9 +82,7 @@ class ApiQueryAllRevisions extends ApiQueryRevisionsBase {
 
                if ( $resultPageSet === null ) {
                        $this->parseParameters( $params );
-                       $revQuery = $revisionStore->getQueryInfo(
-                               $this->fetchContent ? [ 'page', 'text' ] : [ 'page' ]
-                       );
+                       $revQuery = $revisionStore->getQueryInfo( [ 'page' ] );
                } else {
                        $this->limit = $this->getParameter( 'limit' ) ?: 10;
                        $revQuery = [
index 7e46c1a..fc50289 100644 (file)
@@ -153,9 +153,6 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                        if ( $this->token !== null || $pageCount > 0 ) {
                                $opts[] = 'page';
                        }
-                       if ( $this->fetchContent ) {
-                               $opts[] = 'text';
-                       }
                        if ( $this->fld_user ) {
                                $opts[] = 'user';
                        }
index 7cac728..fa5364d 100644 (file)
@@ -47,8 +47,8 @@ if ( isset( $options['limit'] ) ) {
 }
 $type = $options['type'] ?? ConcatenatedGzipHistoryBlob::class;
 
-$dbr = $this->getDB( DB_REPLICA );
-$revQuery = Revision::getQueryInfo( [ 'page', 'text' ] );
+$dbr = wfGetDB( DB_REPLICA );
+$revQuery = Revision::getQueryInfo( [ 'page' ] );
 $res = $dbr->select(
        $revQuery['tables'],
        $revQuery['fields'],
index d7f4fd6..983b701 100644 (file)
@@ -1585,11 +1585,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->assertSame( $expected, $rev->getTextId() );
        }
 
-       public function provideGetRevisionText() {
-               yield [
-                       [ 'text' ]
-               ];
-       }
+       abstract public function provideGetRevisionText();
 
        /**
         * @dataProvider provideGetRevisionText
index bb62b2f..30a5484 100644 (file)
@@ -43,4 +43,9 @@ class RevisionMcrWriteBothDbTest extends RevisionDbTestBase {
                yield [ $row, 789 ];
        }
 
+       public function provideGetRevisionText() {
+               yield [
+                       [ 'text' ]
+               ];
+       }
 }
index 19eeab3..f19bc52 100644 (file)
@@ -44,4 +44,10 @@ class RevisionNoContentModelDbTest extends RevisionDbTestBase {
                yield [ $row, 789 ];
        }
 
+       public function provideGetRevisionText() {
+               yield [
+                       [ 'text' ]
+               ];
+       }
+
 }
index e520f2d..444c150 100644 (file)
@@ -44,4 +44,9 @@ class RevisionPreMcrDbTest extends RevisionDbTestBase {
                yield [ $row, 789 ];
        }
 
+       public function provideGetRevisionText() {
+               yield [
+                       [ 'text' ]
+               ];
+       }
 }
diff --git a/tests/phpunit/includes/api/query/ApiQueryAllRevisionsTest.php b/tests/phpunit/includes/api/query/ApiQueryAllRevisionsTest.php
new file mode 100644 (file)
index 0000000..6e4c3c0
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * @group API
+ * @group Database
+ * @group medium
+ * @covers ApiQueryAllRevisions
+ */
+class ApiQueryAllRevisionsTest extends ApiTestCase {
+
+       public function __construct( $name = null, array $data = [], $dataName = '' ) {
+               parent::__construct( $name, $data, $dataName );
+
+               $this->tablesUsed[] = 'revision';
+       }
+
+       /**
+        * @group medium
+        */
+       public function testContentComesWithContentModelAndFormat() {
+               $pageName = 'Help:' . __METHOD__;
+               $title = Title::newFromText( $pageName );
+               $page = WikiPage::factory( $title );
+
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Some text', $page->getTitle() ),
+                       'inserting content'
+               );
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Some other text', $page->getTitle() ),
+                       'adding revision'
+               );
+
+               $apiResult = $this->doApiRequest( [
+                       'action' => 'query',
+                       'list' => 'allrevisions',
+                       'arvprop' => 'content',
+                       'arvslots' => 'main',
+                       'arvdir' => 'older',
+               ] );
+
+               $this->assertArrayHasKey( 'query', $apiResult[0] );
+               $this->assertArrayHasKey( 'allrevisions', $apiResult[0]['query'] );
+               $this->assertArrayHasKey( 0, $apiResult[0]['query']['allrevisions'] );
+               $this->assertArrayHasKey( 'title', $apiResult[0]['query']['allrevisions'][0] );
+               $this->assertSame( $pageName, $apiResult[0]['query']['allrevisions'][0]['title'] );
+               $this->assertArrayHasKey( 'revisions', $apiResult[0]['query']['allrevisions'][0] );
+               $this->assertCount( 2, $apiResult[0]['query']['allrevisions'][0]['revisions'] );
+
+               foreach ( $apiResult[0]['query']['allrevisions'] as $page ) {
+                       $this->assertArrayHasKey( 'revisions', $page );
+                       foreach ( $page['revisions'] as $revision ) {
+                               $this->assertArrayHasKey( 'slots', $revision );
+                               $this->assertArrayHasKey( 'main', $revision['slots'] );
+                               $this->assertArrayHasKey( 'contentformat', $revision['slots']['main'],
+                                       'contentformat should be included when asking content so client knows how to interpret it'
+                               );
+                               $this->assertArrayHasKey( 'contentmodel', $revision['slots']['main'],
+                                       'contentmodel should be included when asking content so client knows how to interpret it'
+                               );
+                       }
+               }
+       }
+}