strip_tags() deprecated warnings #2123

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

In debug mode, I regularly get several times the below line after calling pwg.categories.getImages:

<br /><b>Deprecated</b>:  strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in <b>
/home/…/piwigo/16.x/include/ws_functions/pwg.categories.php</b> on line <b>135</b><br />

Piwigo 16.0.0RC2
Operating system: Linux (container)
PHP: 8.2.29 [2025-11-16 22:48:21]
MySQL: 11.4.9-MariaDB [2025-11-16 22:48:21]
Graphics Library: External ImageMagick 6.9.13-25
Cache size 412.11 Mo   calculated 5 days ago

PS: These lines are placed at the top of the JSON data returned by the API method.

In debug mode, I regularly get several times the below line after calling `pwg.categories.getImages`: ``` <br /><b>Deprecated</b>: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in <b> /home/…/piwigo/16.x/include/ws_functions/pwg.categories.php</b> on line <b>135</b><br /> ``` Piwigo 16.0.0RC2 Operating system: Linux (container) PHP: 8.2.29 [2025-11-16 22:48:21] MySQL: 11.4.9-MariaDB [2025-11-16 22:48:21] Graphics Library: External ImageMagick 6.9.13-25 Cache size 412.11 Mo   calculated 5 days ago PS: These lines are placed at the top of the JSON data returned by the API method. <!-- github-sync-id:3631185724 -->
adam closed this issue 2026-10-05 01:07:00 +02:00
Author
Owner

OK, so here is the "problem": the photo title (or "name") can be empty. With recent versions of PHP, the strip_tags function requires a non-null input parameter. OK, so I simply added a ?? '' operation to input an empty string instead of null. I fixed pwg.categories.getImages as reported, but also pwg.images.getInfo and pwg.images.search as well.

But that may not be the right way to fix it.

On the page of the photo in the web user interface (I mean page picture.php) even if the photo title is empty, you get a title. Why is that? Because function render_element_name uses a modified version of the filename if the title is empty.

So question: should the API behaves like picture.php and use the filename when title is empty? In that case, especially for pwg.images.getInfo it's going to be important to use the new output field name_raw if remote apps want to fill an edit form for the photo.

@EddyLB what do you think?

OK, so here is the "problem": the photo title (or "name") can be empty. With recent versions of PHP, the `strip_tags` function requires a non-null input parameter. OK, so I simply added a `?? ''` operation to input an empty string instead of `null`. I fixed `pwg.categories.getImages` as reported, but also `pwg.images.getInfo` and `pwg.images.search` as well. But that may not be the right way to fix it. On the page of the photo in the web user interface (I mean page `picture.php`) even if the photo title is empty, you get a title. Why is that? Because function `render_element_name` uses a modified version of the filename if the title is empty. So question: should the API behaves like `picture.php` and use the filename when title is empty? In that case, especially for `pwg.images.getInfo` it's going to be important to use the new output field `name_raw` if remote apps want to fill an edit form for the photo. @EddyLB what do you think? <!-- github-comment-id:3553320861 -->
Author
Owner

Hi @plg,
Third-party apps manage empty photo titles as they wish/need already (probably like picture.php in many cases) and we should avoid breaking their functionality. If such modification was put in place, those storing data in cache would then probably store two times the filename of each photo, which would take space for useless reasons.

So I think that you should not change the behaviour of the API.

Hi @plg, Third-party apps manage empty photo titles as they wish/need already (probably like `picture.php` in many cases) and we should avoid breaking their functionality. If such modification was put in place, those storing data in cache would then probably store two times the filename of each photo, which would take space for useless reasons. So I think that you should not change the behaviour of the API. <!-- github-comment-id:3556044980 -->
Author
Owner

OK. So I close this issue.

OK. So I close this issue. <!-- github-comment-id:3557371320 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2123