Skip to content

Conversation

@beat
Copy link
Contributor

@beat beat commented Feb 11, 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.

@Quy Quy added the PHP 8.x PHP 8.x deprecated issues label Feb 11, 2022
@toivo
Copy link
Contributor

toivo commented Feb 12, 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.

…src/Log/Log.php on line 387`

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

Fedik commented Feb 19, 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?

@laoneo
Copy link
Member

laoneo commented Mar 21, 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.

@RickR2H
Copy link
Member

RickR2H commented Mar 25, 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.

@joomla-cms-bot joomla-cms-bot added PHP 8 and removed Information Required PHP 8.x PHP 8.x deprecated issues labels Mar 25, 2022
@RickR2H
Copy link
Member

RickR2H commented Mar 25, 2022

RTC


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

@RickR2H RickR2H added the RTC This Pull Request is Ready To Commit label Mar 25, 2022
@Quy Quy added PHP 8.x PHP 8.x deprecated issues and removed PHP 8 labels Mar 27, 2022
@laoneo laoneo merged commit 761e52e into joomla:4.1-dev Apr 2, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Apr 2, 2022
@laoneo
Copy link
Member

laoneo commented Apr 2, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PHP 8.x PHP 8.x deprecated issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants