PHP 7, Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;

Bug #1522900 reported by Oleksiy
62
This bug affects 12 people
Affects Status Importance Assigned to Milestone
php-gettext
Fix Released
Undecided
Unassigned
php-gettext (Debian)
Fix Released
Unknown

Bug Description

Hi,
PHP 7 gives these warnings:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; StringReader has a deprecated constructor in .../streams.php on line 48

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; FileReader has a deprecated constructor in .../streams.php on line 84

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; CachedFileReader has a deprecated constructor in .../streams.php on line 145

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; gettext_reader has a deprecated constructor in .../gettext.php on line 36

I cannot fix it with cahnges of: error_reporting = , only with setting: display_errors= Off in php.ini file on Mac OS El Capitan.
But it is not too good to have errors reporting disabled on developing machine.

With best regards,
Oleksiy

Revision history for this message
Oleksiy (oleksiy-muzalyev) wrote :

PHP 7 is so much faster, that I do not want to return to PHP 5.

Revision history for this message
Oleksiy (oleksiy-muzalyev) wrote :

I am using the latest 1.0.12 version.

Revision history for this message
Oleksiy (oleksiy-muzalyev) wrote :

It seems I solved this issue on my installation of the php-gettext. I excahnged

class CachedFileReader extends StringReader {
  function CachedFileReader($filename) {...

on

class CachedFileReader extends StringReader {
 function __construct ($filename) {...

class gettext_reader {
...
 function gettext_reader($Reader, $enable_cache = true) {...
on
class gettext_reader {
...
function __construct ($Reader, $enable_cache = true) {...

(and on two more functions, which have the same name as its class; all together four functions)

and warnings on PHP 7.0.2 disappeared.

Revision history for this message
Alex (normadize) wrote :

Got this too in Xenial (phpmyadmin relies on php-gettext). This should be fixed properly in the package.

Revision history for this message
Daniel (enoch85) wrote :
Download full text (4.0 KiB)

I got this when running phpmyadmin:

Deprecation Notice in ./../php/php-gettext/streams.php#48
 Methods with the same name as their class will not be constructors in a future version of PHP; StringReader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#41: require()
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)
./error_report.php#8: require_once(./libraries/common.inc.php)
Deprecation Notice in ./../php/php-gettext/streams.php#84
 Methods with the same name as their class will not be constructors in a future version of PHP; FileReader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#41: require()
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)
./error_report.php#8: require_once(./libraries/common.inc.php)
Deprecation Notice in ./../php/php-gettext/streams.php#145
 Methods with the same name as their class will not be constructors in a future version of PHP; CachedFileReader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#41: require()
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)
./error_report.php#8: require_once(./libraries/common.inc.php)
Deprecation Notice in ./../php/php-gettext/gettext.php#36
 Methods with the same name as their class will not be constructors in a future version of PHP; gettext_reader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#42: require()
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)
./error_report.php#8: require_once(./libraries/common.inc.php)
Deprecation Notice in ./../php/php-gettext/streams.php#48
 Methods with the same name as their class will not be constructors in a future version of PHP; StringReader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#41: require()
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)
./db_structure.php#13: require_once(./libraries/common.inc.php)
Deprecation Notice in ./../php/php-gettext/streams.php#84
 Methods with the same name as their class will not be constructors in a future version of PHP; FileReader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#41: require()
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)
./db_structure.php#13: require_once(./libraries/common.inc.php)
Deprecation Notice in ./../php/php-gettext/streams.php#145
 Methods with the same name as their class will not be constructors in a future version of PHP; CachedFileReader has a deprecated constructor

Backtrace

./../php/php-gettext/gettext.inc#41: require()
./libraries/select_lang.lib.php#477: require_onc...

Read more...

Changed in php-gettext (Debian):
status: Unknown → New
Revision history for this message
dregad (dregad) wrote :

Proposed fix, replacing PHP4-style constructors with __construct().

Revision history for this message
Richard Laager (rlaager) wrote :

@dregad, why are you removing the "Select_string only accepts integers:" check? I have literally zero clue about this code. I'm just asking this based on looking at the patch.

Revision history for this message
dregad (dregad) wrote :

Hi Richard

Thanks for the heads up. Actually that's a mistake, I must have done something wrong using bazaar (I'm not so familiar with it). Sorry about that, will upload a corrected patch.

Revision history for this message
dregad (dregad) wrote :
Revision history for this message
Jean-Max Reymond (jmreymond-free) wrote :

patch is ok for me. No more complaints from phpmyadmin. Thanks a lot

Revision history for this message
Richard Laager (rlaager) wrote :

This can be reproduced using one of the built-in examples:
sed "s|\.\./gettext.inc|/usr/share/php/php-gettext/gettext.inc|" /usr/share/doc/php-gettext/examples/pigs_dropin.php | php

Or in Yakkety:
sed "s|\.\./gettext.inc|/usr/share/php/php-gettext/gettext.inc|" /usr/share/doc/php-php-gettext/examples/pigs_dropin.php | php

I'm attaching debdiffs for both Xenial and Yakkety which integrate dregad's patch. I've confirmed that the bug exists before and is fixed after.

Revision history for this message
Richard Laager (rlaager) wrote :
Richard Laager (rlaager)
Changed in php-gettext:
status: New → Confirmed
Changed in php-gettext (Debian):
status: New → Fix Released
Revision history for this message
Jonathan Bossenger (jonathanbossenger) wrote :

Is there any ETA on when this will be rolled out to Ubuntu installs. I'm running PHP7 on 17.10 and the php-gettext package still uses the old style class constructors.

Revision history for this message
Jonathan Bossenger (jonathanbossenger) wrote :

Apologies, that was meant to be 16.04 LTS not 17.10

Revision history for this message
Richard Laager (rlaager) wrote :

The Debian bug was fixed (with my patch) in 1.0.11-4. Zesty is the first version of Ubuntu (still shown at packages.ubuntu.com) with the fix, at 1.0.12-0.1.

Changed in php-gettext:
status: Confirmed → Fix Released
Revision history for this message
Richard Leger (richard-leger) wrote :

Would you know when the fix will be released to 16.04 LTS?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.