Feature PHP 8.x PR-5.0-dev ? Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
24 Oct 2022

Summary of Changes

This is one of several PRs to separate out the fixes from #38471. The track_errors feature was removed in PHP 7.2 and this code isn't working anyway in this method.

Testing Instructions

Codereview

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar Hackwar Hackwar - open - 24 Oct 2022
avatar Hackwar Hackwar - change - 24 Oct 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 Oct 2022
Category Libraries
avatar wilsonge
wilsonge - comment - 24 Oct 2022

The track_errors feature was removed in PHP 7.2

track errors was deprecated in 7.2 and removed in 8. so that's not actually true (https://www.php.net/manual/en/errorfunc.configuration.php#ini.track-errors)

There is a recommended alternative - https://www.php.net/manual/en/migration72.deprecated.php#migration72.deprecated.track_errors-and-php_errormsg using error_get_last. Which is also something we use in the framework package - https://github.com/joomla-framework/language/blob/2.0-dev/src/Parser/IniParser.php#L126-L132 - so is there a reason not to implement it?

avatar Hackwar
Hackwar - comment - 24 Oct 2022

Yes, you are right, it isn't removed in 7.2. I didn't introduce error_get_last() here, because we aren't handling the $php_errormsg right now anyway. It is simply a bunch of dead code.

avatar wilsonge
wilsonge - comment - 27 Oct 2022

Just because we aren't handling errors properly doesn't mean we should just remove the error handling

avatar Hackwar Hackwar - change - 9 Nov 2022
Labels Added: PR-4.3-dev
avatar Hackwar
Hackwar - comment - 15 Nov 2022

But there is no error handling and I don't see how we could or would want to include error handling at this point. parse_ini_file() and parse_ini_string() both don't throw any exceptions and only either return an array or false on error. We've so far also swallowed up all errors in this case. We added an @ in front of both parsing calls, which would suppress any errors anyway, then even when it returns a false value, it silently is swallowed up by returning an empty array. All this means that even if we wanted, we couldn't change the behavior of the method at this point. And I honestly don't think we should log an error in a language file to a log file by default.

avatar HLeithner
HLeithner - comment - 8 Mar 2023

@Hackwar @wilsonge
Suggestion for 4.4,

  • remove the $php_errormsg code
  • check error_get_last() if $strings
  • if we have an error add a deprecation warning which says that we throw an exception starting with 5.0

While checking the source code I found out that most of the functions calling the parseFile are unable to handle a return value of false some of them directly access it as array and at least one call give the return value directly to a function which has the parameter typed as array which would lead to an exception...

is this ok for you george if you can you rework this pr hannes and rebase it for 4.4 and create a new pr for 5.0 which adds the exception? and of course don't forget the documentation pr.

thanks

avatar wilsonge
wilsonge - comment - 9 Mar 2023

I'm happy with that

avatar Hackwar Hackwar - change - 18 Apr 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-04-18 12:06:32
Closed_By Hackwar
Labels Added: ? ?
avatar Hackwar Hackwar - close - 18 Apr 2023
avatar Hackwar Hackwar - change - 18 Apr 2023
Status Closed New
Closed_Date 2023-04-18 12:06:32
Closed_By Hackwar
avatar Hackwar Hackwar - change - 18 Apr 2023
Status New Pending
avatar Hackwar Hackwar - reopen - 18 Apr 2023
avatar Hackwar Hackwar - change - 18 Apr 2023
Title
[4.3] Fixing php compatibility issues 2
[5.0] Fixing php compatibility issues 2
avatar Hackwar Hackwar - edited - 18 Apr 2023
avatar Hackwar Hackwar - change - 30 May 2023
Labels Added: Feature PR-5.0-dev
Removed: ? PR-4.3-dev
avatar HLeithner
HLeithner - comment - 31 Aug 2023

@Hackwar can you bring this pr uptodate with the requests then I can merge it before beta1

avatar Quy
Quy - comment - 25 Sep 2023

Closing in favor of #41908. Thanks.

avatar Quy Quy - close - 25 Sep 2023
avatar Quy Quy - change - 25 Sep 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-09-25 14:09:58
Closed_By Quy
Labels Added: PHP 8.x

Add a Comment

Login with GitHub to post a comment