Skip to content

Prevented database errors when renaming image URLs - #1209

Merged
pirate-bot merged 2 commits into
developmentfrom
bugfix/1199
Oct 30, 2026
Merged

pirate-bot merged 2 commits into
developmentfrom
bugfix/1199

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Fixed attachment URL rewriting after file renames by updating rows through each table’s actual primary key in both plain-text and serialized-data paths, and counting replacements only when updates succeed. The serialized path now searches the column itself, matches base filenames consistently with the plain-text path - including -300x200 and -scaled variants - and processes all matching rows without the previous 100-row limit. Both paths preserve the port in searched URLs and use a shared helper, with duplicate rows detected by primary key.

Closes #1199

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@pirate-bot

pirate-bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Plugin build for 5b22686 is ready 🛎️!

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

Fix the port and escaped-video gaps in URL replacement, and add a test for the JSON-escaped search.

Question for the author: $skip_tables holds unprefixed names, so it never matches. The new term description test needs term_taxonomy processed. Should the skip list be removed, or fixed without term_taxonomy?

Validation details
  • Files reviewed: 3/3 changed files. The narrowed-input checks (rejected values, base, failure guarded, sources) stayed unchecked.
  • PHPUnit 9.6.22 on WordPress 7.1.4, PHP 8.3.36: rm /var/www/html/wp-content/plugins/optimole-wp && cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-… printed OK (24 tests, 68 assertions) (run R5)
  • The base tree with HEAD tests fails nine added tests on assertions: rm /var/www/html/wp-content/plugins/optimole-wp && cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-… printed Failures: 9 (run R5)
  • The security pass found no new trust-boundary issue.
Untested areas
  • The narrowed-input checks (rejected values, base, failure guarded, sources) were not settled. No source of a pathless attachment URL was found.
  • PHPStan did not run. CI owns it.

🤖 Automated review · run code-review-agent_6ae2ec4c91b679.69256087.


🤖 Review agent — review posted ✅ on 3e634829 · changes requested · 3 findings · 25 min

Run code-review-agent_6ae2ec4c91b679.69256087 · trail

@girishpanchal30

Copy link
Copy Markdown
Contributor Author

@pirate-bot

$skip_tables holds unprefixed names, so it never matches. The new term description test needs term_taxonomy processed. Should the skip list be removed, or fixed without term_taxonomy?

Keeping $skip_tables as is. It has never matched because wpdb::tables() returns prefixed names, so every table has always been scanned. Making it match as written would skip term_taxonomy and stop term descriptions from being rewritten, which is what #1199 fixes.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The PR passes. The port, escaped-URL and escaped-video fixes work, and each has a test that fails without it.

Validation details
  • Files reviewed: 3/3 changed files. These rows stayed unchecked: the consumer of the changed replace_urls_in_value() return, and the narrowed-input checks (rejected values, base, failure guarded, sources).
  • PHPUnit 9.6.22, WordPress 7.1.4, PHP 8.3.36: Test_Attachment_Db_Renamer printed OK (27 tests, 71 assertions) at HEAD.
  • With pr-base code, all three new tests fail on their assertions.
  • With 3e63482 code, the port and no-sizes video tests fail.
  • Security and requirements checks are reused from run code-review-agent_6ae2ec4c91b679.69256087, not rerun.
Untested areas
  • The consumer of the replace_urls_in_value() return and the narrowed-input checks were not settled.
  • Same-stem serialized rows are rewritten when serialize_precision differs from the stored float precision. Production reachability was not traced.
  • The earlier $skip_tables question has no answer yet.
  • PHPStan did not run. CI owns it.

🤖 Automated review · run code-review-agent_6ae2f7d9423b55.32752775.


🤖 Review agent — review posted ✅ on 5b22686c · approved · 0 findings · 9 min

Run code-review-agent_6ae2f7d9423b55.32752775 · trail

@pirate-bot
pirate-bot merged commit fa116d1 into development Oct 30, 2026
16 checks passed
@pirate-bot
pirate-bot deleted the bugfix/1199 branch October 30, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants