Skip to content

Fix PHP 8.1 notice "PHP Deprecated: strpos(): Passing null to parameter #1" when saving an article#39299

Merged
laoneo merged 1 commit intojoomla:4.2-devfrom
richard67:4.2-dev-fix-fields-plugin-strpos-deprecation
Nov 28, 2022
Merged

Fix PHP 8.1 notice "PHP Deprecated: strpos(): Passing null to parameter #1" when saving an article#39299
laoneo merged 1 commit intojoomla:4.2-devfrom
richard67:4.2-dev-fix-fields-plugin-strpos-deprecation

Conversation

@richard67
Copy link
Copy Markdown
Member

Pull Request for Issue #39298 .

Summary of Changes

Add is_string check before calling strpos for the intro text which might be null when no Read More button.

Testing Instructions

On PHP 8.1 with error reporting set to maximum in Global Configuration and PHP configured to log errors into a log file, edit an article in backend which has no Read More button and so has no intro text. Save the article. Then check the PHP error log file.

Actual result BEFORE applying this Pull Request

PHP notice PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /path-to-your-joomla-site/plugins/content/fields/fields.php on line 66.

Expected result AFTER applying this Pull Request

No such notice.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed

  • No documentation changes for manual.joomla.org needed

@laoneo laoneo added the Maintainers Checked Used if the PR is conceptional useful label Nov 24, 2022
@toivo
Copy link
Copy Markdown
Contributor

toivo commented Nov 25, 2022

I have tested this item ✅ successfully on 4f91d90

Tested successfully in Joomla 4.2.6-dev using PHP 8.1.10.


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

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Nov 26, 2022

I have tested this item ✅ successfully on 4f91d90


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

@richard67
Copy link
Copy Markdown
Member Author

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Nov 26, 2022
@laoneo laoneo merged commit 1d17613 into joomla:4.2-dev Nov 28, 2022
@laoneo
Copy link
Copy Markdown
Member

laoneo commented Nov 28, 2022

Thank you!

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Nov 28, 2022
@laoneo laoneo added this to the Joomla! 4.2.6 milestone Nov 28, 2022
@richard67 richard67 deleted the 4.2-dev-fix-fields-plugin-strpos-deprecation branch November 28, 2022 10:11
obuisard added a commit to Digital-Peak/joomla-cms that referenced this pull request Dec 12, 2022
Introduced changes made in PR joomla#39299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintainers Checked Used if the PR is conceptional useful PHP 8.x PHP 8.x deprecated issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants