Change API result data structure to be cleaner in new formats
[lhc/web/wiklou.git] / includes / api / ApiQueryUserContributions.php
index f6c6356..e5ec67d 100644 (file)
@@ -335,7 +335,7 @@ class ApiQueryContributions extends ApiQueryBase {
                $anyHidden = false;
 
                if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
-                       $vals['texthidden'] = '';
+                       $vals['texthidden'] = true;
                        $anyHidden = true;
                }
 
@@ -343,7 +343,7 @@ class ApiQueryContributions extends ApiQueryBase {
                $vals['userid'] = $row->rev_user;
                $vals['user'] = $row->rev_user_text;
                if ( $row->rev_deleted & Revision::DELETED_USER ) {
-                       $vals['userhidden'] = '';
+                       $vals['userhidden'] = true;
                        $anyHidden = true;
                }
                if ( $this->fld_ids ) {
@@ -367,20 +367,14 @@ class ApiQueryContributions extends ApiQueryBase {
                }
 
                if ( $this->fld_flags ) {
-                       if ( $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id ) ) {
-                               $vals['new'] = '';
-                       }
-                       if ( $row->rev_minor_edit ) {
-                               $vals['minor'] = '';
-                       }
-                       if ( $row->page_latest == $row->rev_id ) {
-                               $vals['top'] = '';
-                       }
+                       $vals['new'] = $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id );
+                       $vals['minor'] = (bool)$row->rev_minor_edit;
+                       $vals['top'] = $row->page_latest == $row->rev_id;
                }
 
                if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->rev_comment ) ) {
                        if ( $row->rev_deleted & Revision::DELETED_COMMENT ) {
-                               $vals['commenthidden'] = '';
+                               $vals['commenthidden'] = true;
                                $anyHidden = true;
                        }
 
@@ -400,8 +394,8 @@ class ApiQueryContributions extends ApiQueryBase {
                        }
                }
 
-               if ( $this->fld_patrolled && $row->rc_patrolled ) {
-                       $vals['patrolled'] = '';
+               if ( $this->fld_patrolled ) {
+                       $vals['patrolled'] = (bool)$row->rc_patrolled;
                }
 
                if ( $this->fld_size && !is_null( $row->rev_len ) ) {
@@ -429,7 +423,7 @@ class ApiQueryContributions extends ApiQueryBase {
                }
 
                if ( $anyHidden && $row->rev_deleted & Revision::DELETED_RESTRICTED ) {
-                       $vals['suppressed'] = '';
+                       $vals['suppressed'] = true;
                }
 
                return $vals;