PHP8.1: Deprecated: nl2br(): Passing null to parameter #1 #1712

Closed
opened 2026-10-05 00:53:47 +02:00 by adam · 3 comments
Owner

When running php 8.1, I get this Deprecation warning with piwigo 13.8.0:

Deprecated: nl2br(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/piwigo/include/functions_plugins.inc.php on line 214

It occurs on the main page a lot and in each album or photo once.

I tested it also with php8.2 where I get this warning as well + a ton more.

[Piwigo](https://piwigo.org/) 13.8.0
Installed on 24 April 2022, 1 year 3 months 3 weeks 2 days ago
Operating system: Linux
PHP: 8.1.22
MySQL: 10.5.19-MariaDB-0+deb11u2 [2023-08-18 12:37:00]
Graphics Library: External ImageMagick 6.9.11-60
When running php 8.1, I get this Deprecation warning with piwigo 13.8.0: ``` Deprecated: nl2br(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/piwigo/include/functions_plugins.inc.php on line 214 ``` It occurs on the main page a lot and in each album or photo once. I tested it also with php8.2 where I get this warning as well + a ton more. ``` [Piwigo](https://piwigo.org/) 13.8.0 Installed on 24 April 2022, 1 year 3 months 3 weeks 2 days ago Operating system: Linux PHP: 8.1.22 MySQL: 10.5.19-MariaDB-0+deb11u2 [2023-08-18 12:37:00] Graphics Library: External ImageMagick 6.9.11-60 ``` <!-- github-sync-id:1856648398 -->
adam closed this issue 2026-10-05 00:53:48 +02:00
Author
Owner

Did you try the new version 14 (beta3 currently) ? Does it still occur?

Did you try the new version 14 (beta3 currently) ? Does it still occur? <!-- github-comment-id:1759392867 -->
Author
Owner

I quickly created a new gallery with the current master and it seems to throw no more deprecation warnings, even on php 8.2.
However, I did not replicate my other gallery, thus some plugins might interfere and produce warnings.

I quickly created a new gallery with the current master and it seems to throw no more deprecation warnings, even on php 8.2. However, I did not replicate my other gallery, thus some plugins might interfere and produce warnings. <!-- github-comment-id:1774639090 -->
Author
Owner

I'm closing this issue, but I have encountered the same problem while testing $conf['allow_html_descriptions'] = false; because Piwigo, in include/common.inc.php adds an event handler :

if ( !$conf['allow_html_descriptions'] )
{
  add_event_handler('render_category_description', 'nl2br');
}

We're going to substitute nl2br with a custom pwg_nl2br

I'm closing this issue, but I have encountered the same problem while testing `$conf['allow_html_descriptions'] = false;` because Piwigo, in `include/common.inc.php` adds an event handler : ``` if ( !$conf['allow_html_descriptions'] ) { add_event_handler('render_category_description', 'nl2br'); } ``` We're going to substitute `nl2br` with a custom `pwg_nl2br` <!-- github-comment-id:2551034583 -->
adam changed title from PHP8.1: Deprecated: nl2br(): Passing null to parameter #1 to PHP8.1: Deprecated: nl2br(): Passing null to parameter #1 2026-10-27 11:27:12 +01:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1712