From 77369e5e2b56636fe4c14a6b78cc3b170cfccc03 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 15 Apr 2015 11:32:31 -0400 Subject: [PATCH] Bug PHP 7 compatibility in php-gettext Signed-off-by: Marc Delisle --- ChangeLog | 1 + libraries/php-gettext/gettext.php | 2 +- libraries/php-gettext/streams.php | 6 +++--- test/libraries/php-gettext/PMA_FileReader_test.php | 8 +++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48ffd131321f..22e8ba1fa0a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ phpMyAdmin - ChangeLog - bug #4794 Server error viewing table content - bug Fix issues related to number of decimal places in time - bug #4853 Relation view between 1600 and 1780 px +- bug PHP 7 compatibility in php-gettext 4.4.2.0 (2015-04-13) - bug #4835 PMA_hideShowConnection not called after submit_num_fields diff --git a/libraries/php-gettext/gettext.php b/libraries/php-gettext/gettext.php index 5064047cbd24..3486e92f0731 100644 --- a/libraries/php-gettext/gettext.php +++ b/libraries/php-gettext/gettext.php @@ -98,7 +98,7 @@ function readintarray($count) { * @param object Reader the StreamReader object * @param boolean enable_cache Enable or disable caching of strings (default on) */ - function gettext_reader($Reader, $enable_cache = true) { + public function __construct($Reader, $enable_cache = true) { // If there isn't a StreamReader, turn on short circuit mode. if (! $Reader || isset($Reader->error) ) { $this->short_circuit = true; diff --git a/libraries/php-gettext/streams.php b/libraries/php-gettext/streams.php index 3cdc1584e1fa..ab947194a2f1 100644 --- a/libraries/php-gettext/streams.php +++ b/libraries/php-gettext/streams.php @@ -49,7 +49,7 @@ class StringReader { var $_pos; var $_str; - function StringReader($str='') { + public function __construct($str='') { $this->_str = $str; $this->_pos = 0; } @@ -86,7 +86,7 @@ class FileReader { var $_fd; var $_length; - function FileReader($filename) { + public function __construct($filename) { if (file_exists($filename)) { $this->_length=filesize($filename); @@ -143,7 +143,7 @@ function close() { // Preloads entire file in memory first, then creates a StringReader // over it (it assumes knowledge of StringReader internals) class CachedFileReader extends StringReader { - function CachedFileReader($filename) { + public function __construct($filename) { if (file_exists($filename)) { $length=filesize($filename); diff --git a/test/libraries/php-gettext/PMA_FileReader_test.php b/test/libraries/php-gettext/PMA_FileReader_test.php index df48e3117468..c083d3ab9db2 100644 --- a/test/libraries/php-gettext/PMA_FileReader_test.php +++ b/test/libraries/php-gettext/PMA_FileReader_test.php @@ -121,8 +121,10 @@ public function testClose() public function testForNonExistingFile() { $file = new FileReader('./path/for/no/file.txt'); + // looking at the return value of a constructor is curious + // but the constructor returns a value $this->assertFalse( - $file->FileReader('./path/for/no/file.txt') + $file->__construct('./path/for/no/file.txt') ); } @@ -130,11 +132,11 @@ public function testForCachedFileReader() { $reader = new CachedFileReader('./test/test_data/test.file'); $this->assertEquals( - $reader->CachedFileReader('./test/test_data/test.file'), + $reader->__construct('./test/test_data/test.file'), null ); $this->assertFalse( - $reader->CachedFileReader('./path/for/no/file.txt') + $reader->__construct('./path/for/no/file.txt') ); }