PR-staging

Pending

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
4 Sep 2017

Partial Pull Request for Issue #16584

Summary of Changes

PHP 7.2 deprecates the track_errors INI configuration and the scoped $php_errormsg variable in favor of using the error_get_last() function for retrieving error data, and at PHP 7.0 using error_clear_last() to clear any errors (to my knowledge we aren't doing anything in core requiring the latter at the moment).

This PR phases out this deprecated functionality for the HTTP and Language packages.

Testing Instructions

The packages should still function normally, including error handling (easiest way to test error handling is enable debug mode and language debug and break one of the language files with a parsing error).

avatar joomla-cms-bot joomla-cms-bot - change - 4 Sep 2017
Category Libraries
avatar mbabker mbabker - open - 4 Sep 2017
avatar mbabker mbabker - change - 4 Sep 2017
Status New Pending
avatar mbabker mbabker - change - 12 Nov 2017
Labels Added: PR-staging
avatar csthomas
csthomas - comment - 8 Jan 2018

I suggest to use error_clear_last.

For test I removed the first double quote character from com_content language file.

Before patch:

JROOT/language/en-GB/en-GB.com_content.ini : error(s) in line(s) 6

After patch:

    JROOT/language/en-GB/en-GB.com_content.ini : error(s) in line(s) 6
    PHPJROOT/language/en-GB/en-GB.mod_menu.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_tags_popular.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_articles_category.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_articles_archive.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_articles_popular.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_syndicate.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_login.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_breadcrumbs.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_custom.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_languages.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/language/en-GB/en-GB.mod_search.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6
    PHPJROOT/administrator/language/en-GB/en-GB.plg_system_debug.iniPHP parser errors :syntax error, unexpected BOOL_TRUE in /home/tomash/public_html/a4/language/en-GB/en-GB.com_content.ini on line 6 
avatar mbabker
mbabker - comment - 8 Jan 2018

I suggest to use error_clear_last.

How reliable is the polyfill for error_clear_last()?. error_clear_last() was only introduced in PHP 7.0 so we need to polyfill it until 4.0.

avatar csthomas
csthomas - comment - 8 Jan 2018

Or you can remember the previous error message before line error_reporting(E_ALL) and compare it to the last one at the bottom. I assumed that error messages are unique:)

avatar csthomas
csthomas - comment - 8 Jan 2018

This is my test.

$ php -a
Interactive mode enabled

php > echo $e;
PHP Notice:  Undefined variable: e in php shell code on line 1
php > $handler = function() { return false;};
php > set_error_handler($handler);
php > @trigger_error('');
php > restore_error_handler();
php > print_r(error_get_last());
Array
(
    [type] => 1024
    [message] => 
    [file] => php shell code
    [line] => 1
)
php > echo phpversion();
7.1.12-3+ubuntu16.04.1+deb.sury.org+1
avatar mbabker
mbabker - comment - 21 Jul 2018

Eh, maybe later.

avatar mbabker mbabker - change - 21 Jul 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-07-21 02:35:30
Closed_By mbabker
avatar mbabker mbabker - close - 21 Jul 2018

Add a Comment

Login with GitHub to post a comment