Skip to content

[4.1] [PHP 8.1] Compatibility of htmlentities() types in tinymce DisplayTrait#36846

Merged
bembelimen merged 4 commits intojoomla:4.1-devfrom
beat:patch-26
Mar 24, 2022
Merged

[4.1] [PHP 8.1] Compatibility of htmlentities() types in tinymce DisplayTrait#36846
bembelimen merged 4 commits intojoomla:4.1-devfrom
beat:patch-26

Conversation

@beat
Copy link
Copy Markdown
Contributor

@beat beat commented Jan 25, 2022

Pull Request for Issue # none

Summary of Changes

This is the Joomla 4.1 identical correspondent pendent of the Joomla 3.10 PR #36804 that got merged, and replaces previous Joomla 4.0 PR #36761 that got outdated due to the cool refactoring of editors into Traits.

In PHP, htmlentities() has following parameters types: 2nd is a non-null int, 4th is à non-null bool.

 htmlentities(
    string $string,
    int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
    ?string $encoding = null,
    bool $double_encode = true
): string

ref.: https://www.php.net/manual/en/function.htmlentities.php

This PR does replace null by their type-conversions: (int) null -> 0, and (bool) null -> false.

Disclaimer: I'm only fixing PHP 8.1 compatibility here.

Testing Instructions

A code-review should be enough here.

I found it with CB internal PMS / New Message, but I guess PHP 8.1 on any tinymce window should show it too.

Actual result BEFORE applying this Pull Request

This is the result on 4.0 (in 4.1-dev, it's erroring on line 380 of DisplayTrait.php instead of line 538 of tinymce.php):

  • Deprecated: htmlentities(): Passing null to parameter # 2 ($flags) of type int is deprecated in /home/beat/www/4.0/plugins/editors/tinymce/tinymce.php on line 538
  • Deprecated: htmlentities(): Passing null to parameter # 4 ($double_encode) of type bool is deprecated in /home/beat/www/4.0/plugins/editors/tinymce/tinymce.php on line 538

Expected result AFTER applying this Pull Request

No errors.

Documentation Changes Required

None.

beat and others added 2 commits January 25, 2022 23:04
@Quy
Copy link
Copy Markdown
Contributor

Quy commented Feb 5, 2022

Please fix conflicts.

@Quy Quy added PHP 8.x PHP 8.x deprecated issues and removed Conflicting Files labels Feb 5, 2022
@Quy
Copy link
Copy Markdown
Contributor

Quy commented Feb 12, 2022

I have tested this item ✅ successfully on 5356a79


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

1 similar comment
@laoneo
Copy link
Copy Markdown
Member

laoneo commented Mar 21, 2022

I have tested this item ✅ successfully on 5356a79


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

@laoneo laoneo removed the PHP 8.x PHP 8.x deprecated issues label Mar 21, 2022
@laoneo
Copy link
Copy Markdown
Member

laoneo commented Mar 21, 2022

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 21, 2022
@laoneo laoneo added the PHP 8.x PHP 8.x deprecated issues label Mar 21, 2022
@bembelimen bembelimen merged commit bf767d6 into joomla:4.1-dev Mar 24, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 24, 2022
@bembelimen
Copy link
Copy Markdown
Contributor

Thx

@bembelimen bembelimen added this to the Joomla 4.1.1 milestone Mar 24, 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