Skip to content

Media rename and video block break on WordPress below 6.2, although the plugin says it requires 5.5 #1201

Closed

Description

@kushh23

Description

The readme says Requires at least: 5.5, but a few features use core APIs that do not exist on older versions:

  1. Rename / Replace file (WP < 6.2). Optml_Attachment_Db_Renamer builds every query with the %i identifier placeholder, which $wpdb->prepare() only understands from WP 6.2. On 5.5 to 6.1, %i is left as plain text, so the SQL reaching MySQL is literally DESCRIBE %i (a syntax error). get_columns() gets no rows, so every table is skipped and replace() returns 0. The file and its sizes are still moved on disk, so posts keep pointing at the old file URL and the image is likely broken. No error is shown to the user.
  2. Optimole Video Player block (WP 5.5). render_video_player_block() calls get_block_wrapper_attributes(), added in WP 5.6. On 5.5, a connected site that renders a post with this block hits Call to undefined function get_block_wrapper_attributes().
  3. Dashboard widget (WP < 6.2). assets/src/widget/index.js uses createRoot from @wordpress/element, which core only ships from WP 6.2 (React 18). On older versions the script throws and the widget stays stuck on the skeleton loader.

Also, wp_cache_flush_group() (WP 6.1) in PageProfiler/Storage/ObjectCache::delete_all() is not guarded, but nothing calls delete_all() in 4.2.17, so it has no effect today.

Expected: either raise Requires at least to 6.2 (simplest, since 1 and 3 both need it), or guard each call (for example, check $wpdb->has_cap( 'identifier_placeholders' ) and fall back to backtick-quoting the identifier, check function_exists( 'get_block_wrapper_attributes' ), and fall back to render() when createRoot is missing).

The bundled Themeisle SDK and symfony/polyfill-php80 do not raise the floor: their newer calls are guarded or polyfilled.

Step-by-step reproduction instructions

Rename (no Optimole account needed):

  1. On a test site, install WordPress 6.1 (wp core download --version=6.1.7) with PHP 7.4 to 8.1, and set WP_DEBUG and WP_DEBUG_LOG to true.
  2. wp plugin install optimole-wp --version=4.2.17 --activate
  3. ID=$(wp media import ./test.jpg --porcelain) then URL=$(wp eval "echo wp_get_attachment_url($ID);")
  4. wp post create --post_status=publish --post_title="Rename test" --post_content="<img src=\"$URL\">"
  5. In wp-admin, go to Media > Library, open the image's edit screen, enter renamed-test in Rename attached file, and click Update.
  6. Run wp db query "SELECT ID FROM $(wp db prefix)posts WHERE post_content LIKE '%renamed-test%'". It returns nothing. The post still uses the old URL, the old file is gone from uploads/, and the image is broken on the front end.
  7. debug.log shows wpdb::prepare was called incorrectly ... placeholders (0) for the number of arguments passed (1) and WordPress database error ... for query DESCRIBE %i.
  8. Repeat on WordPress 6.2 or later. The post content is updated to renamed-test.jpg.

Shorter check: on 6.1, wp eval 'var_dump( ( new Optml_Attachment_Db_Renamer( true ) )->replace( "<old url>", "<new url>" ) );' prints int(0) even when posts contain <old url>.

The prepare() behaviour can also be reproduced with plain PHP. This copies the 5.5 to 6.1 regex steps and gives:

WP 5.5-6.1 prepare('DESCRIBE %i', 'wp_posts')
  notice : _doing_it_wrong: The query does not contain the correct number of placeholders (0) for the number of arguments passed (1).
  SQL    : DESCRIBE %i

Video block (WordPress 5.5, PHP 7.4): on a site connected to Optimole (the block is only registered when connected), run wp post create --post_status=publish --post_title="Video test" --post_content='<!-- wp:optimole/video-player /-->' and open the post. You get a fatal error. Without an account: wp eval 'echo ( new Optml_Video_Player() )->render_video_player_block( [], "", null );' gives the same fatal error.

Dashboard widget (WordPress 6.1): on a connected site where the widget shows, open Dashboard. The console shows createRoot is not a function. Running typeof wp.element.createRoot returns "undefined".

Screenshots, screen recording, code snippet or Help Scout ticket

Environment info

Optimole 4.2.17 (the same code is on master and development). Rename/Replace and the widget fail on WordPress 5.5 to 6.1. The video block fails on WordPress 5.5. Any PHP version from 7.4 that those WordPress versions support.

Is the issue you are reporting a regression

No. The same code has been there since 4.0.0, when Requires at least was already 5.5.

Found while writing the WordPress compatibility checks for Optimole.

Activity

  1. added
    bugThis label could be used to identify issues that are caused by a defect in the product.
    on Oct 28, 2026
  2. added theissue type on Oct 28, 2026
  3. girishpanchal30 commented on Oct 28, 2026

    @girishpanchal30
    Contributor

    I have fixed it with PR #1208

  4. kushh23 commented on Nov 4, 2026

    @kushh23
    ContributorAuthor
  5. milicavs commented on Nov 5, 2026

    @milicavs

    🧪 QA steps and test links

    Optimole says it supports WordPress 5.5 and newer, but on WordPress below 6.2 renaming an image (Media → edit image → Rename attached file) moves the file without updating the posts that use it, so those posts show a broken image. No error appears on screen. Older versions also break the Optimole dashboard widget (below 6.2) and the Video Player block (5.5).

    Requires: a site on WordPress 6.1 (any version from 5.5 to 6.1 works).

    Link Build Bot check
    Reproduce the bug Optimole 4.2.19 (released) ✅ Reproduced: after the rename the file is renamed-test.jpg, the post still points to qa-rename-test.jpg (now gone), and QA Logs shows DESCRIBE %i database errors
    Verify the fix PR #1208 build 4487913 ✅ Fixed: the post now uses renamed-test.jpg and QA Logs has no errors

    In the links:

    • WordPress 6.1 with PHP 8.0. Steps 1 and 2 are already done, and the links open on step 3's edit screen of QA rename test.
    • Optimole isn't connected: renaming doesn't need an account. The widget and the Video Player block need a connected site, so they are edge cases below.
    • The PR build also shows 4.2.19 on the Plugins screen.
    • Tools → QA Logs shows debug.log.

    Reproduce on Optimole 4.2.19:

    1. Go to Media → Add New and upload any image.
    2. Go to Posts → Add New, add an Image block with that image and publish the post.
    3. Go to Media → Library, open the image and click Edit more details.
    4. In Rename attached file, type renamed-test and click Rename.
    5. Open the post on the front end.
    • Bug: the image is broken. Its address still ends in the old file name, which no longer exists. Tools → QA Logs shows wpdb::prepare was called incorrectly and WordPress database error ... for query DESCRIBE %i.
    • Fixed: the image shows, its address ends in renamed-test.jpg, and no database errors are logged.
    Edge cases
    • Replace file (Media → image → Replace) on WordPress 6.1: posts show the new image.
    • Rename on WordPress 6.2 or later: posts are still updated, as before.
    • Connected site on WordPress 6.1, Dashboard: the Optimole widget loads instead of staying on the loading skeleton.
    • Connected site on WordPress 5.5, a post with the Optimole Video Player block: the post opens with no fatal error.
    • Connected site on WordPress 5.8, Optimole → Settings → Compression: the three compression modes show as radio buttons and switching them saves.

    Fix: #1208 (open)

  6. pirate-bot commented on Nov 5, 2026

    @pirate-bot
    Collaborator

    QA agent — 🟢 Passing checks · Legacy media, video and dashboard checks passed.

    Renaming and replacing images updated the posts on WordPress 6.1; equivalent journeys left broken links on the base build. The video player, dashboard widget and compression settings worked on the older versions tested. Rename and modern dashboard controls also worked on WordPress 6.2. Connected-site checks used seeded account data and mocked service responses, not a real account.

    Worth a human look

    1. Verify connection and live service behavior with a real Optimole account.
    2. Check the separate rename-history row from issue Renaming an image leaves the old URL in comments and term descriptions, with "Unknown column 'ID'" database errors #1199 when that change is available.
    Checks (9 passed)
    • ✅ On WordPress 6.1, renaming an attachment moves the original and image sizes to the new name and updates the attachment's own URL.
    • ✅ After renaming on WordPress 6.1, the published post uses the new image URL and displays the image without the old broken URL or database placeholder errors.
    • ✅ On WordPress 6.1, replacing an image preserves working post references to the replacement and its generated sizes.
    • ✅ On WordPress 6.1, a connected site's Optimole dashboard widget renders its image optimization statistics instead of remaining on the skeleton loader.
    • ✅ On WordPress 5.5, a connected site's post containing the Optimole Video Player block opens without a fatal error and renders its wrapper and player.
    • ✅ On WordPress 5.8, the connected Compression settings show all three selectable modes using radio controls.
    • ✅ On WordPress 5.8, switching the compression mode and saving persists the selected mode after reload.
    • ✅ On WordPress 6.2 or later, renaming still updates the published post's image URL and leaves the image accessible.
    • ✅ On WordPress 5.5, the connected Optimole dashboard loads and a settings save can display its feedback notice without a missing notices-store error.

    Full report, evidence and session trail

  7. pirate-bot commented on Nov 12, 2026

    @pirate-bot
    Collaborator

    🎉 This issue has been resolved in version 4.2.20 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

  8. added
    releasedIndicate that an issue has been resolved and released in a particular version of the product.
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugThis label could be used to identify issues that are caused by a defect in the product.releasedIndicate that an issue has been resolved and released in a particular version of the product.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions