? ? PHP 8.x Pending

User tests: Successful: Unsuccessful:

avatar beat
beat
11 Feb 2022

Pull Request for Issue # none.

Summary of Changes

Fixes Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in libraries/src/Log/Log.php on line 387

With call-stack:

1 | 0.0001 | 373216 | {main}(  ) | .../index.php:0
2 | 0.0001 | 373968 | require_once( '/home/beat/www/4.0/includes/app.php ) | .../index.php:32
3 | 0.0092 | 985176 | Joomla\CMS\Application\CMSApplication->execute(  ) | .../app.php:63
4 | 0.0096 | 1067760 | Joomla\CMS\Application\SiteApplication->doExecute(  ) | .../CMSApplication.php:278
5 | 0.0987 | 2766720 | Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ) | .../SiteApplication.php:243
6 | 0.1001 | 2761952 | Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_ajax', $params = ??? ) | .../SiteApplication.php:204
7 | 0.1006 | 2784232 | Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch(  ) | .../ComponentHelper.php:389
8 | 0.1007 | 2786136 | Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure:/home/beat/www/4.0/libraries/src/Dispatcher/LegacyComponentDispatcher.php:68-70}(  $path = '/home/beat/www/4.0/components/com_ajax/ajax.php' ) | .../LegacyComponentDispatcher.php:71
9 | 0.1007 | 2788312 | require_once( '/home/beat/www/4.0/components/com_ajax/ajax.php ) | .../LegacyComponentDispatcher.php:69
10 | 0.1008 | 2792728 | Joomla\CMS\Log\Log::add( $entry = 'Please specify a valid response format, other than that of HTML, such as json, raw, debug, etc.', $priority = 8, $category = ???, $date = ???, $context = ??? ) | .../ajax.php:265
11 | 0.1010 | 2799720 | Joomla\CMS\Log\Log->addLogEntry( $entry = class  Joomla\CMS\Log\LogEntry { public $category = NULL; public $context =  []; public $date = class Joomla\CMS\Date\Date { protected $tz = class  DateTimeZone { ... }; public $date = '2022-02-11 20:59:49.174797';  public $timezone_type = 3; public $timezone = 'UTC' }; public $message =  'Please specify a valid response format, other than that of HTML, such  as json, raw, debug, etc.'; public $priority = 8; protected $priorities =  [0 => 1, 1 => 2, 2 => 4, 3 => 8, 4 => 16, 5 => 32, 6  => 64, 7 => 128]; public $callStack = [0 => [...], 1 =>  [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6  => [...], 7 => [...], 8 => [...], 9 => [...]] } ) | .../Log.php:175
12 | 0.1010 | 2799720 | Joomla\CMS\Log\Log->findLoggers( $priority = 8, $category = NULL ) | .../Log.php:333
13 | 0.1010 | 2799720 | strtolower( $string = NULL ) | .../Log.php:387

This is a code-safe B/C fix.

There is an alternate fix possible, which is to give a default value of empty string '' in LogEntry to its attribute public $category;, like public $category = ''; here:
https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Log/LogEntry.php#L31

or to initialize it to empty string in its constructor when no $category is passed to it, here:
https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Log/LogEntry.php#L115

Testing Instructions

Code review or:

In PHP 8.1 with debug on, go to: http://localhost/.../index.php/component/ajax/?plugin=RunSchedulerWebcron&group=system&hash=ERoRNEvIxx8cLCIho0T2

(without &format=raw to better see the error, but with &format=raw error is there too)

Actual result BEFORE applying this Pull Request

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in libraries/src/Log/Log.php on line 387

Expected result AFTER applying this Pull Request

That error is not displayed anymore.

Documentation Changes Required

None.

avatar beat beat - open - 11 Feb 2022
avatar beat beat - change - 11 Feb 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Feb 2022
Category Libraries
avatar beat beat - change - 11 Feb 2022
Labels Added: ? ?
avatar toivo toivo - test_item - 12 Feb 2022 - Tested successfully
avatar toivo
toivo - comment - 12 Feb 2022

I have tested this item successfully on 7cf3a41

Tested successfully in Joomla 4.1.0-rc4 using PHP 8.1.2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37009.

avatar Fedik
Fedik - comment - 19 Feb 2022

There is an alternate fix possible, which is to give a default value of empty string '' in LogEntry to its attribute public $category;, like public $category = '';

@beat I think this would better, or do we have any potential b/c with it?

avatar laoneo
laoneo - comment - 21 Mar 2022

I have tested this item successfully on 4f8d6b5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37009.

avatar laoneo laoneo - test_item - 21 Mar 2022 - Tested successfully
avatar RickR2H
RickR2H - comment - 25 Mar 2022

I have tested this item successfully on 4f8d6b5

After following your instructions the error described in the PR was gone. Only now an other error emerged: Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in ***\components\com_ajax\ajax.php on line 39. This will probably being fixed in an other PR.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37009.

avatar RickR2H RickR2H - test_item - 25 Mar 2022 - Tested successfully
avatar RickR2H RickR2H - change - 25 Mar 2022
Status Pending Ready to Commit
avatar RickR2H
RickR2H - comment - 25 Mar 2022

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37009.

avatar laoneo laoneo - change - 1 Apr 2022
Labels Added: ? PHP 8.x
Removed: ?
avatar laoneo laoneo - change - 2 Apr 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-04-02 07:52:21
Closed_By laoneo
avatar laoneo laoneo - close - 2 Apr 2022
avatar laoneo laoneo - merge - 2 Apr 2022
avatar laoneo
laoneo - comment - 2 Apr 2022

Thanks!

Add a Comment

Login with GitHub to post a comment