Skip to content

N°8681 - PHP 8.1: Fix deprecated notice for null value passed to preg_match_all()#803

Merged
Molkobain merged 3 commits intosupport/3.2from
issue/8681-php-81-fix-deprecated-passing-null-parameter
Feb 16, 2026
Merged

N°8681 - PHP 8.1: Fix deprecated notice for null value passed to preg_match_all()#803
Molkobain merged 3 commits intosupport/3.2from
issue/8681-php-81-fix-deprecated-passing-null-parameter

Conversation

@Molkobain
Copy link
Contributor

@Molkobain Molkobain commented Feb 15, 2026

Base information

Question Answer
Related to a SourceForge thread / Another PR / Combodo ticket? N°8681
Type of change? Bug fix

Symptom (bug)

Deprecated Passing null to parameter #2 ($subject) of type string is deprecated in core/attributedef.class.inc.php on line 4469
Deprecated Passing null to parameter #2 ($subject) of type string is deprecated in core/inlineimage.cIass.inc.php on line 291

Reproduction procedure (bug)

  1. On iTop 3.2.2
  2. With PHP 8.1.0
  3. With a particular customization ??

I could not find how to reproduce locally what we witnessed on the customer's instance...

Cause (bug)

Shallow cause:
In AttributeText::GetAsHTML(), $sValue seems to be null in some cases, which when passed to AttributeText::RenderWikiHtml() and InlineImage::FixUrls() will be passed to preg_match_all() in the $subject parameter that as of PHP 8.1 only supports string values.

Root cause:
How we happen to pass null in AttributeText::GetAsHTML() remains a mystery for now.

Proposed solution (bug and enhancement)

Even though we can't find where the null comes from, we can harden the AttributeText::RenderWikiHtml() and InlineImage::FixUrls() methods so they convert null values to string. Minimizing the risk of regression while fixing the issue.

During the merge into 3.3 branch, I suggest to also change the AttributeText::RenderWikiHtml() and InlineImage::FixUrls() methods prototype to type the relevant parameter to string|null.

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand digging in the code?

Checklist of things to do before PR is ready to merge

@Molkobain Molkobain added this to the 3.2.3 milestone Feb 15, 2026
@Molkobain Molkobain self-assigned this Feb 15, 2026
@Molkobain Molkobain added the bug Something isn't working label Feb 15, 2026
@CombodoApplicationsAccount CombodoApplicationsAccount added the internal Work made by Combodo label Feb 15, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes PHP 8.1 deprecation notices caused by passing null as the $subject argument to preg_match_all() by hardening wiki/HTML rendering paths to coerce null inputs to empty strings.

Changes:

  • Coerce null to '' in AttributeText::RenderWikiHtml() before running regex processing.
  • Coerce null to '' in InlineImage::FixUrls() before parsing/replacing <img ... data-img-id="..."> tags.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
core/inlineimage.class.inc.php Hardens InlineImage::FixUrls() against null input before calling preg_match_all().
core/attributedef.class.inc.php Hardens AttributeText::RenderWikiHtml() against null input before calling preg_match_all().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Molkobain Molkobain merged commit 6bd5a7b into support/3.2 Feb 16, 2026
@Molkobain Molkobain deleted the issue/8681-php-81-fix-deprecated-passing-null-parameter branch February 16, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants