Skip to content

[4.1] [PHP 8.1] compatibility of htmlentities types in tinymce.php (fixes Deprecated tinymce.php on line 538)#36761

Closed
beat wants to merge 1 commit intojoomla:4.1-devfrom
beat:patch-11
Closed

[4.1] [PHP 8.1] compatibility of htmlentities types in tinymce.php (fixes Deprecated tinymce.php on line 538)#36761
beat wants to merge 1 commit intojoomla:4.1-devfrom
beat:patch-11

Conversation

@beat
Copy link
Copy Markdown
Contributor

@beat beat commented Jan 20, 2022

Pull Request for Issue # : None, found and fixed it directly here.

Summary of Changes

This is the Joomla 4.0 identical pendent of this Joomla 3.10 PR #36804 that got merged.

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

  • 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.

@alikon alikon added the PHP 8.x PHP 8.x deprecated issues label Jan 21, 2022
beat added a commit to beat/joomla-cms that referenced this pull request Jan 23, 2022
…fixes Deprecated tinymce.php on line 603)

Fixes `Deprecated: htmlentities(): Passing null to parameter #2 ($flags) of type int is deprecated in plugins/editors/tinymce/tinymce.php on line 603`
Joomla 3.10 version of Joomla 4.0 joomla#36761
@beat beat changed the title Fix PHP 8.1 compatibility of htmlentities types in tinymce.php (fixes Deprecated tinymce.php on line 538) [4.0] [PHP 8.1] compatibility of htmlentities types in tinymce.php (fixes Deprecated tinymce.php on line 538) Jan 23, 2022
@brianteeman
Copy link
Copy Markdown
Contributor

In theory you dont need to create this as it will be merged up from 3.x

@beat
Copy link
Copy Markdown
Contributor Author

beat commented Jan 24, 2022

This is the Joomla 4.0 identical pendent of this Joomla 3.10 PR #36804 (had wrong title, fixed) that got merged.
In Joomla 4, there is only one use of htmlentities() without correctly typed parameters, instead of 2 in Joomla 3.10.

@beat
Copy link
Copy Markdown
Contributor Author

beat commented Jan 24, 2022

In theory you dont need to create this as it will be merged up from 3.x

Nice! Good to know for all my other 3.10 PRs that just got merged.

Then in practice this PR might still help as the tinymce.php code changed quite a bit, So, keeping it open.

Of course, in case the corresponding #36804 Joomla 3.10 PR gets adapted and merged into 4.x-dev branches, feel free to comment commit # and close this PR.

@bembelimen bembelimen changed the base branch from 4.0-dev to 4.1-dev January 24, 2022 10:32
@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Jan 24, 2022

As brian said that should be fixed on the merge up and when we merge here it results into conflicts. So i would like to hear @bembelimen 's opinion first whether he wants to merge here or merge 3.10 into 4.0/4.1 first. My proposal would be the latter once merged up we can check whether this PR is still needed.

@beat beat changed the title [4.0] [PHP 8.1] compatibility of htmlentities types in tinymce.php (fixes Deprecated tinymce.php on line 538) [4.1] [PHP 8.1] compatibility of htmlentities types in tinymce.php (fixes Deprecated tinymce.php on line 538) Jan 25, 2022
@beat
Copy link
Copy Markdown
Contributor Author

beat commented Jan 25, 2022

Closing in favor of #36846 as there is no chance that PR #36804 gets up-merged automatically from 3.10-dev, since the code got split into Traits.

@beat beat closed this Jan 25, 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.

5 participants