AdvancedCustomFields / AdvancedCustomFields/acf

Slashes in ACF block attributes break search + replace

Open
#483 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

When migrating a site from dev to live, it's standard to run a search/replace tool from the old domain to the new (eg the wp-cli version, or the Better Search Replace function, which both handle serialized data).

However, URLs that are stored in ACF fields for a block don't get replaced correctly.

When I look in the code editor it has something along these lines:

<!-- wp:acf/myblock {"id":"block_60134f136bcab","name":"acf/myblock","data":{"link":"https://www.google.com","_link":"field_60134e9b92143"},"align":"","mode":"auto"} /-->

But in the MySQL database it will have:

<!-- wp:acf/myblock {"id":"block_60134f136bcab","name":"acf\/myblock","data":{"link":"https:\/\/www.google.com","_link":"field_60134e9b92143"},"align":"","mode":"auto"} /-->

The extra slashes stored are what causes the problem.

This does not happen with default blocks, eg if I insert a Media & Text block, it contains a URL in the mediaLink attribute which doesn't have the extra slashes in the database.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Reproduce the shown ACF block migration and trace how its attributes are serialized into MySQL, comparing the escaped ACF block with a default block; done means search/replace updates URLs in ACF block attributes without corrupting serialized content.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
content, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.