Skip to content

Conversation

@beat
Copy link
Contributor

@beat beat commented Mar 26, 2022

Fixes Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in libraries/src/Mail/MailTemplate.php on line 297

Pull Request for Issue # none.

Summary of Changes

Obvious fix to avoid a default null (instead of empty string) passed to trim() which generates a deprecated warning in PHP 8.1.

Testing Instructions

Code review is enough imho.

To reproduce:

  • PHP 8.1 + debug ON + deprecated warnings on in php.ini
  • Make sure that you never edited the Joomla mail template
  • Make Joomla send an email in admin area (e.g. for new version available)
  • See deprecation warning displayed (or not anymore after fix)

Actual result BEFORE applying this Pull Request

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/beat/www/4.1/libraries/src/Mail/MailTemplate.php on line 297

# | Time | Memory | Function | Location
-- | -- | -- | -- | --
1 | 0.0058 | 364520 | {main}(  ) | .../index.php:0
2 | 0.0223 | 365880 | require_once( '/home/beat/www/4.1/administrator/includes/app.php ) | .../index.php:32
3 | 0.2463 | 1853712 | Joomla\CMS\Application\CMSApplication->execute(  ) | .../app.php:63
4 | 2.2751 | 6298176 | Joomla\CMS\Application\AdministratorApplication->render(  ) | .../CMSApplication.php:284
5 | 2.2752 | 6298216 | Joomla\CMS\Application\CMSApplication->render(  ) | .../AdministratorApplication.php:514
6 | 2.5000 | 8513024 | Joomla\CMS\Application\WebApplication->triggerEvent( $eventName = 'onAfterRender', $args = ??? ) | .../CMSApplication.php:1045
7 | 2.5000 | 8513120 | Joomla\Event\Dispatcher->dispatch( $name = 'onAfterRender', $event = class Joomla\Event\Event { protected $name = 'onAfterRender'; protected $arguments = []; protected $stopped = FALSE } ) | .../EventAware.php:111
8 | 2.5002 | 8513768 | Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure:/home/beat/www/4.1/libraries/src/Plugin/CMSPlugin.php:267-296}( $event = class Joomla\Event\Event { protected $name = 'onAfterRender'; protected $arguments = []; protected $stopped = FALSE } ) | .../Dispatcher.php:486
9 | 2.5002 | 8513768 | PlgSystemUpdatenotification->onAfterRender(  ) | .../CMSPlugin.php:285
10 | 3.0070 | 8978392 | Joomla\CMS\Mail\MailTemplate->send(  ) | .../updatenotification.php:271
11 | 3.0117 | 8993992 | trim( $string = NULL ) | .../MailTemplate.php:297

Expected result AFTER applying this Pull Request

No error.

Documentation Changes Required

None.

Fixes "Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in libraries/src/Mail/MailTemplate.php on line 297"
@alikon alikon added the PHP 8.x PHP 8.x deprecated issues label Mar 27, 2022
@alikon
Copy link
Contributor

alikon commented Mar 27, 2022

I have tested this item ✅ successfully on 5ffd955


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

1 similar comment
@laoneo
Copy link
Member

laoneo commented Mar 27, 2022

I have tested this item ✅ successfully on 5ffd955


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

@Quy
Copy link
Contributor

Quy commented Mar 27, 2022

RTC


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

@Quy Quy removed the PHP 8.x PHP 8.x deprecated issues label Mar 27, 2022
@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 27, 2022
@Quy Quy added the PHP 8.x PHP 8.x deprecated issues label Mar 27, 2022
@bembelimen bembelimen merged commit 9d13d22 into joomla:4.1-dev Mar 30, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 30, 2022
@bembelimen
Copy link
Contributor

Thx

@bembelimen bembelimen added this to the Joomla 4.1.3 milestone Mar 30, 2022
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.

6 participants