Anomie has uploaded a new change for review.

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

Change subject: Update ApiResult handling for mediawiki/core change I7b37295e
......................................................................

Update ApiResult handling for mediawiki/core change I7b37295e

Change I7b37295e for mediawiki/core deprecates several methods, and more
importantly changes the format of the data returned from
ApiResult::getData(). This change should handle these differences in a
backwards-compatible manner.

Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678e
---
M includes/api/ApiAddStudents.php
M includes/api/ApiListStudents.php
2 files changed, 68 insertions(+), 26 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EducationProgram 
refs/changes/79/183579/1

diff --git a/includes/api/ApiAddStudents.php b/includes/api/ApiAddStudents.php
index 0c4b9e9..b48fedc 100644
--- a/includes/api/ApiAddStudents.php
+++ b/includes/api/ApiAddStudents.php
@@ -49,13 +49,19 @@
 
                $api = new \ApiMain( $apiParams );
                $api->execute();
-               $usersData = & $api->getResultData();
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $usersData = ApiResult::removeMetadataNonRecursive(
+                               $api->getResult()->getResultData()
+                       );
+               } else {
+                       $usersData = & $api->getResultData();
+               }
 
                // make lists: valid and invalid (invalid name or non-existent) 
users
                $validUsersMap = array(); // associative array, id => name
                $invalidUserNames = array(); // just names, indexed numerically
 
-               foreach ( $usersData['query']['users'] as $userData ) {
+               foreach ( $usersData['query']['users'] as $key => $userData ) {
                        if ( isset ( $userData['userid'] ) ) {
                                $validUsersMap[$userData['userid']] = 
$userData['name'];
                        } else {
diff --git a/includes/api/ApiListStudents.php b/includes/api/ApiListStudents.php
index 078fdc1..4ca7541 100644
--- a/includes/api/ApiListStudents.php
+++ b/includes/api/ApiListStudents.php
@@ -162,10 +162,14 @@
 
                } else {
                        // Replace all the instances of $courseIndex in the 
results.
-                       $results->setIndexedTagName_internal(
-                               null,
-                               'course'
-                       );
+                       if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                               $results->defineIndexedTagName( null, 'course' 
);
+                       } else {
+                               $results->setIndexedTagName_internal(
+                                       null,
+                                       'course'
+                               );
+                       }
                }
        }
 
@@ -310,10 +314,17 @@
                }
 
                // Index the participants.
-               $results->setIndexedTagName_internal(
-                       $this->usersPath( $courseIndex, $courseRolePlural ),
-                       $courseRole
-               );
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $results->defineIndexedTagName(
+                               $this->usersPath( $courseIndex, 
$courseRolePlural ),
+                               $courseRole
+                       );
+               } else {
+                       $results->setIndexedTagName_internal(
+                               $this->usersPath( $courseIndex, 
$courseRolePlural ),
+                               $courseRole
+                       );
+               }
        }
 
        /**
@@ -402,19 +413,30 @@
                                        }
 
                                        //Index the reviewers for the article.
-                                       $results->setIndexedTagName_internal(
-                                               $articlePath,
-                                               'reviewer'
-                                       );
+                                       if ( defined( 'ApiResult::META_CONTENT' 
) ) {
+                                               $results->defineIndexedTagName( 
$articlePath, 'reviewer' );
+                                       } else {
+                                               
$results->setIndexedTagName_internal(
+                                                       $articlePath,
+                                                       'reviewer'
+                                               );
+                                       }
                                        $articleIndex++;
 
                                }
 
                                // Index the articles for the student.
-                               $results->setIndexedTagName_internal(
-                                       $this->userPath( $courseIndex, 
'students', $studentIndex ),
-                                       'article'
-                               );
+                               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                                       $results->defineIndexedTagName(
+                                               $this->userPath( $courseIndex, 
'students', $studentIndex ),
+                                               'article'
+                                       );
+                               } else {
+                                       $results->setIndexedTagName_internal(
+                                               $this->userPath( $courseIndex, 
'students', $studentIndex ),
+                                               'article'
+                                       );
+                               }
                        }
 
                        $studentIndex++;
@@ -422,10 +444,17 @@
                }
 
                // Index the students.
-               $results->setIndexedTagName_internal(
-                       $this->usersPath( $courseIndex, 'students' ),
-                       'student'
-               );
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $results->defineIndexedTagName(
+                               $this->usersPath( $courseIndex, 'students' ),
+                               'student'
+                       );
+               } else {
+                       $results->setIndexedTagName_internal(
+                               $this->usersPath( $courseIndex, 'students' ),
+                               'student'
+                       );
+               }
        }
 
        /**
@@ -458,10 +487,17 @@
                        $articleNames
                );
 
-               $results->setIndexedTagName_internal(
-                       $this->articlesPath( $courseIndex ),
-                       'articles'
-               );
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $results->defineIndexedTagName(
+                               $this->articlesPath( $courseIndex ),
+                               'articles'
+                       );
+               } else {
+                       $results->setIndexedTagName_internal(
+                               $this->articlesPath( $courseIndex ),
+                               'articles'
+                       );
+               }
 
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

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

Reply via email to