Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51084 closed defect (bug) (fixed)

„Trying to access array offset on value of type bool“ in "/wp-admin/includes/class-wp-privacy-policy-content.php on line 96 & 97“

Reported by: treibstoff's profile treibstoff Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: normal Version: 5.5
Component: Privacy Keywords: needs-privacy-review
Focuses: administration Cc:

Description

Using WP 5.5 and PHP 7.4 producing masses of following Notice & Warnings on the Admin-Area (only):
Notice: Trying to access array offset on value of type bool in /homepages/…/wp-admin/includes/class-wp-privacy-policy-content.php on line 96

Notice: Trying to access array offset on value of type bool in /homepages/…/wp-admin/includes/class-wp-privacy-policy-content.php on line 97

Warning: Cannot modify header information – headers already sent by (output started at /homepages/…/wp-admin/includes/class-wp-privacy-policy-content.php:96) in /homepages/../wp-admin/admin-header.php on line 9

Line 96 & 97 says:
‘plugin_name’ => $data[‘plugin_name’],
‘policy_text’ => $data[‘policy_text’],

testing without plugins & without my functions in functions.php. Also testing with Standart-Theme. No chance.
The Warnings follwing the Notices....

Change History (8)

#1 @treibstoff
4 years ago

  • Focuses administration added
  • Version set to 5.5

This does not happen with PHP 7.3, as I just realized.

Last edited 4 years ago by treibstoff (previous) (diff)

#2 @carike
4 years ago

  • Component changed from General to Privacy
  • Focuses privacy added
  • Keywords needs-privacy-review added

Don't mind me, just adding this to the privacy workflows.

This ticket was mentioned in Slack in #core-privacy by carike. View the logs.


4 years ago

#4 @treibstoff
4 years ago

this is from an older ticket:

„PHP 7.4 introduces a „Trying to access array offset on value of type …“ warning for accessing null/bool/int/float/resource (everything but array, string and object) as if it were an array.“
and
„I expect more issues to be reported – both in Core as well as in plugins and themes – once PHP 7.4 is out and starting to be used for real.“

#47704

Last edited 4 years ago by SergeyBiryukov (previous) (diff)

#5 follow-up: @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.6
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

Hi there, welcome back to WordPress Trac! Thanks for the report.

Just noting that I could not reproduce the issue on a clean install, but it looks like this can happen when the _wp_suggested_privacy_policy_content meta value for the Privacy Policy page is somehow corrupted.

I think adding an is_array() check before accessing the $data['plugin_name'] and $data['policy_text'] values would make sense.

#6 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 48836:

Privacy: Avoid a PHP 7.4 notice in WP_Privacy_Policy_Content::text_change_check().

When iterating over the items stored in '_wp_suggested_privacy_policy_content` meta value for the Privacy Policy page, make sure the item is an array before accessing its properties.

Props treibstoff.
Fixes #51084.

#7 in reply to: ↑ 5 @treibstoff
4 years ago

Replying to SergeyBiryukov:

Hi there, welcome back to WordPress Trac! Thanks for the report.

Just noting that I could not reproduce the issue on a clean install, but it looks like this can happen when the _wp_suggested_privacy_policy_content meta value for the Privacy Policy page is somehow corrupted.

I think adding an is_array() check before accessing the $data['plugin_name'] and $data['policy_text'] values would make sense.

thanx @SergeyBiryukov, this solution works.
hope it will stay with the next update of class-wp-privacy-policy-content.php

#8 @garrett-eclipse
4 years ago

  • Focuses privacy removed

Dropping privacy focus as it's already in the Privacy component.

Note: See TracTickets for help on using tickets.