Make WordPress Core

Opened 2 years ago

Closed 21 months ago

Last modified 21 months ago

#46402 closed defect (bug) (fixed)

wp_targeted_link_rel() corrupts serialized array data including ACF field settings.

Reported by: elliotcondon Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.1
Component: Formatting Keywords: dev-feedback has-patch has-unit-tests
Focuses: Cc:


Hi all,

In 43732, the wp_targeted_link_rel() callback was added to filter content before it's saved to the database.

This addition is corrupting all serialized array data saved in post_content containing an <a> element, and is breaking the Advanced Custom Fields plugin.

The Advanced Custom Fields uses the post_content value to save serialized array data for both its field and field group settings.

Users who include an <a> element within the field "instructions" (or other field settings) are experiencing this issue first hand when their field no longer loads.

Serialized data is very useful, but is open to "corruption" by any change in character length.

Is it possible to improve the wp_targeted_link_rel() function by avoiding serialized / JSON data?

I believe there is a related issue affecting JSON data 46316 which may also be solved by this improvement.

Attachments (1)

46402.diff (1.5 KB) - added by birgire 22 months ago.

Download all attachments as: .zip

Change History (6)

#1 @TobiasBg
2 years ago

  • Keywords dev-feedback added
  • Version set to 5.1

22 months ago

#2 @birgire
22 months ago

  • Component changed from General to Formatting
  • Keywords has-patch has-unit-tests added

46402.diff is a suggestion how we could ignore entirely serialized content using is_serialized().

Within is_serialized() there are various checks before the regex matches kick in there, like if the trimmed content has : as the second character. So in most cases when the content isn't entirely serialized, it shouldn't hit these extra regex matches in is_serialized().

As the content of custom post types can be used for various data formats, I also wonder if the wp_targeted_link_rel() filtering should be made easier to remove per post type or post ID?

#3 @SergeyBiryukov
22 months ago

  • Milestone changed from Awaiting Review to 5.3

#4 @SergeyBiryukov
21 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 45408:

Formatting: Don't run wp_targeted_link_rel() on entirely serialized content.

Props birgire, elliotcondon.
Fixes #46402.

#5 @SergeyBiryukov
21 months ago

In 45409:

Docs: Remove full stop from ticket number.

See #46402.

Note: See TracTickets for help on using tickets.