[MediaWiki-commits] [Gerrit] Test gzdecode() in TemplateDataBlob::newFromDatabase() - change (mediawiki...TemplateData)

2013-09-11 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Test gzdecode() in TemplateDataBlob::newFromDatabase()
..


Test gzdecode() in TemplateDataBlob::newFromDatabase()

gzdecode() has been introduced in PHP 5.4 although gzencode() has been
there for a while.  Wikimedia is still using PHP 5.3, so the
TemplateDataBlob::newFromDatabase() would trigger a fatal error whenever
it is passed compressed JSON :-(

The test does not fix the root cause (that needs a fallback function in
the TemplateData extension), but it does highlight the issue in PHP 5.3.x.

Updated a @return comment, correcting the class being returned.

bug: 54058
Change-Id: I8357b474165f4317982b9c924cf0afe68650d677
---
M TemplateDataBlob.php
M tests/TemplateDataBlobTest.php
2 files changed, 17 insertions(+), 1 deletion(-)

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



diff --git a/TemplateDataBlob.php b/TemplateDataBlob.php
index 9270c32..d41b4dd 100644
--- a/TemplateDataBlob.php
+++ b/TemplateDataBlob.php
@@ -31,7 +31,7 @@
 *
 * @param string $json
 * @throws MWException
-* @return TemplateInfo
+* @return TemplateDataBlob
 */
public static function newFromJSON( $json ) {
$tdb = new self( json_decode( $json ) );
diff --git a/tests/TemplateDataBlobTest.php b/tests/TemplateDataBlobTest.php
index 712d84a..37b371f 100644
--- a/tests/TemplateDataBlobTest.php
+++ b/tests/TemplateDataBlobTest.php
@@ -381,4 +381,20 @@
$cases['msg']
);
}
+
+   /**
+* Verify we can gzdecode() which came in PHP 5.4.0. Mediawiki needs a
+* fallback function for it.
+* If this test fail, we are most probably attempting to use gzdecode()
+* with PHP before 5.4.
+*
+* @see bug 54058
+*/
+   public function testGetJsonForDatabase() {
+   // Compress JSON to trigger the code pass in newFromDatabase 
that ends
+   // up calling gzdecode().
+   $gzJson = gzencode( '{}' );
+   $templateInfo = TemplateDataBlob::newFromDatabase( $gzJson );
+   $this->assertInstanceOf( 'TemplateDataBlob', $templateInfo );
+   }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8357b474165f4317982b9c924cf0afe68650d677
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/TemplateData
Gerrit-Branch: master
Gerrit-Owner: Hashar 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: jenkins-bot

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] test gzdecode() in TemplateDataBlob::newFromDatabase() - change (mediawiki...TemplateData)

2013-09-11 Thread Hashar (Code Review)
Hashar has uploaded a new change for review.

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


Change subject: test gzdecode() in TemplateDataBlob::newFromDatabase()
..

test gzdecode() in TemplateDataBlob::newFromDatabase()

gzdecode() has been introduced in PHP 5.4 although gzencode() has been
there for a while.  Wikimedia is still using PHP 5.3, so the
TemplateDataBlob::newFromDatabase() would trigger a fatal error whenever
it is passed compressed json :-(

The test does not fix the root cause (that needs a fallback function in
MediaWiki core), but it does highlight the issue in PHP 5.3.x.

bug: 54058
Change-Id: I8357b474165f4317982b9c924cf0afe68650d677
---
M tests/TemplateDataBlobTest.php
1 file changed, 15 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TemplateData 
refs/changes/82/83982/1

diff --git a/tests/TemplateDataBlobTest.php b/tests/TemplateDataBlobTest.php
index 712d84a..105320d 100644
--- a/tests/TemplateDataBlobTest.php
+++ b/tests/TemplateDataBlobTest.php
@@ -381,4 +381,19 @@
$cases['msg']
);
}
+
+   /**
+* Verify we can gzdecode() which came in PHP 5.4.0. Mediawiki needs a
+* fallback function for it.
+* If this test fail, we are most probably attempting to use gzdecode()
+* with PHP before 5.4.
+*
+* @see bug 54058
+*/
+   public function testGetJsonForDatabase() {
+   // Compress JSON to trigger the code pass in newFromDatabase 
that ends
+   // up calling gzdecode().
+   $gzJson = gzencode( '{}' );
+   TemplateDataBlob::newFromDatabase( $gzJson );
+   }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8357b474165f4317982b9c924cf0afe68650d677
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TemplateData
Gerrit-Branch: master
Gerrit-Owner: Hashar 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits