Page 1 of 1

php 5.4.12

Posted: Fri Feb 22, 2013 8:44 pm
by DoYouSpeakWak
Hey all

Today i upgraded my servers to php 5.4.12, But right after i was greeted with this php debug notice

Code: Select all

[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
Board is vanila and latest. no changes. And this error did not show up 2 hours earlier.

Any ideas on what the cause can be and if a bug report to php.net should be submitted, what should it include.

Wak

Re: php 5.4.12

Posted: Sat Feb 23, 2013 3:50 am
by rxu
For phpBB 3.0.11 includes/session.php there's line 2208:

Code: Select all

return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']);
Here, strtr() with 2 arguments has been used. As per the PHP manual, in this case the second argument should be an array in the form array('from' => 'to', ...).
But $user->lang['datetime'] (see language/en/common.php 'datetime' entry) is a multidimensional array having subarray of

Code: Select all

		'AGO'		=> array(
			0		=> 'less than a minute ago',
			1		=> '%d minute ago',
			2		=> '%d minutes ago',
			60		=> '1 hour ago',
		),
If you put this block of code into comment (/*...*/), the error is gone.

So, with PHP 5.4.12 this pretty much looks like a phpBB bug.

You can temporarily fix the issue by suppressing the error output adding @ sign at the front of strtr call:

Code: Select all

return @strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']);
This is not an actual fix but getting rid of the error messages only. This bug shouldn't affect the board features operation though.

Re: php 5.4.12

Posted: Sat Feb 23, 2013 6:24 am
by wang5555
rxu wrote: You can temporarily fix the issue by suppressing the error output adding @ sign at the front of strtr call:

Code: Select all

return @strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']);
This is not an actual fix but getting rid of the error messages only. This bug shouldn't affect the board features operation though.
Thanks very much. :D

Re: php 5.4.12

Posted: Sat Feb 23, 2013 8:46 am
by DoYouSpeakWak
Thx for the fix rxu.

Bug ticket opened.

http://tracker.phpbb.com/browse/PHPBB3-11361
rxu wrote: This is not an actual fix but getting rid of the error messages only. This bug shouldn't affect the board features operation though.
Sadly not. ucp,mcp,acp doesnt really work with this error and debug,debug extra on. lets hope it gets fixed in the next version. until then not that many will use this latest version of php.

Re: php 5.4.12

Posted: Sat Feb 23, 2013 10:00 am
by bantu
Please try 'lang' => array_filter($this->lang['datetime'], 'is_string'), in $date_cache[$format] = array( definition.

Re: php 5.4.12

Posted: Sat Feb 23, 2013 11:09 am
by RMcGirr83
Any mods installed?

Re: php 5.4.12

Posted: Sat Feb 23, 2013 11:19 am
by HGN
DoYouSpeakWak wrote:Board is vanila and latest. no changes.

Re: php 5.4.12

Posted: Sat Feb 23, 2013 11:37 am
by RMcGirr83
Damn it...lack of coffee intake

Re: php 5.4.12

Posted: Sat Feb 23, 2013 12:03 pm
by DoYouSpeakWak
bantu wrote:Please try 'lang' => array_filter($this->lang['datetime'], 'is_string'), in $date_cache[$format] = array( definition.
Tried with this. i assume thats what you meant.

Code: Select all

			// Is the user requesting a friendly date format (i.e. 'Today 12:42')?
			$date_cache[$format] = array(
				'is_short'		=> strpos($format, '|'),
				'format_short'	=> substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1),
				'format_long'	=> str_replace('|', '', $format),
				'lang' => array_filter($this->lang['datetime'], 'is_string'),
			);
Only the lang line that is changed. cleaned my cache rm *.php and browser cache, reloaded. same error still there.

Re: php 5.4.12

Posted: Sat Feb 23, 2013 3:10 pm
by rxu
bantu wrote:Please try 'lang' => array_filter($this->lang['datetime'], 'is_string'), in $date_cache[$format] = array( definition.
That worked for me.

Re: php 5.4.12

Posted: Sun Feb 24, 2013 2:27 am
by wang5555
rxu wrote:
bantu wrote:Please try 'lang' => array_filter($this->lang['datetime'], 'is_string'), in $date_cache[$format] = array( definition.
That worked for me.
+1, thanks! :D

Re: php 5.4.12

Posted: Sun Feb 24, 2013 11:12 am
by bantu
DoYouSpeakWak wrote:Only the lang line that is changed. cleaned my cache rm *.php and browser cache, reloaded. same error still there.
Please double check.

Re: php 5.4.12

Posted: Thu Feb 28, 2013 7:37 pm
by DoYouSpeakWak
Checked. was my fault. had apc and did not clear its cache