jenkins-bot has submitted this change and it was merged.

Change subject: (bug 51040) Fix json decode in PropertyInfoTable.
......................................................................


(bug 51040) Fix json decode in PropertyInfoTable.

json_decode was missing the second parameter in one instance
in PropertyInfoTable.

Change-Id: I4ab1888956481e44f6f2320532dbfb1ddcb78225
---
M lib/includes/store/sql/PropertyInfoTable.php
1 file changed, 25 insertions(+), 3 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/store/sql/PropertyInfoTable.php 
b/lib/includes/store/sql/PropertyInfoTable.php
index 8c1c3e0..bd4c476 100644
--- a/lib/includes/store/sql/PropertyInfoTable.php
+++ b/lib/includes/store/sql/PropertyInfoTable.php
@@ -117,14 +117,36 @@
                if ( $res === false ) {
                        $info = null;
                } else {
-                       $info = json_decode( $res, true );
+                       $info = $this->decodeInfo( $res );
 
                        if ( $info === null ) {
-                               wfLogWarning( "failed to decode property info 
blob for " . $propertyId . ": " . $res );
+                               wfLogWarning( "failed to decode property info 
blob for " . $propertyId . ": " . substr( $res, 0, 200 ) );
                        }
                }
 
                wfProfileOut( __METHOD__ );
+               return $info;
+       }
+
+       /**
+        * Decodes an info blob.
+        *
+        * @param string|null|bool  $blob
+        *
+        * @return array|null The decoded blob as an associative array, or null 
if the blob
+        *         could not be decoded.
+        */
+       protected function decodeInfo( $blob ) {
+               if ( $blob === false || $blob === null ) {
+                       return null;
+               }
+
+               $info = json_decode( $blob, true );
+
+               if ( !is_array( $info ) ) {
+                       $info = null;
+               }
+
                return $info;
        }
 
@@ -149,7 +171,7 @@
                $infos = array();
 
                while ( $row = $res->fetchObject() ) {
-                       $info = json_decode( $row->pi_info );
+                       $info = $this->decodeInfo( $row->pi_info );
 
                        if ( $info === null ) {
                                wfLogWarning( "failed to decode property info 
blob for property "

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4ab1888956481e44f6f2320532dbfb1ddcb78225
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Raimond Spekking <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to