Skip to content

Page sync stores absolute paths, which break when the CLI and web server see different roots #172

Closed

Description

@vinnysgreen

Summary

Page_Sync saves each synced page's file locations as absolute paths in post meta (_blockstudio_page_template_path, _blockstudio_page_content_path, _blockstudio_page_source, _blockstudio_page_layout, _blockstudio_page_directory). Later web requests read those paths back and call is_file() on them, for example in Tailwind::compile_editor_css() (via Page_Registry::hydrate_from_posts()), Pages::negotiates_markdown(), and the static prerender's page_source_dependencies().

If wp bs pages sync runs in an environment where the theme sits under a different absolute path than the web server sees, every stored path is wrong for web requests. On hosts with open_basedir, each one logs a warning on every request.

Environment

  • Host: InstaWP. Its WP-CLI runs in a jailed shell, where the site is at /web/<site>/public_html. PHP-FPM sees the same files at /home/<user>/web/<site>/public_html and has open_basedir limited to that tree.
  • The same thing happens after any migration that changes the absolute path (a host move, a new Docker mount or a staging clone) until a sync is run again from the new location.

Steps to reproduce

  1. Use a theme that has file-based pages under pages/<slug>/ (both index.php and index.md).
  2. Run wp bs pages sync from a shell where get_stylesheet_directory() resolves to a different absolute path than it does under PHP-FPM, for example InstaWP's SSH/WP-CLI.
  3. Load any page on the front end with WP_DEBUG_LOG on.

Actual

Each page logs a warning like this (once from includes/classes/tailwind.php, and once from the Markdown negotiation for .md pages):

PHP Warning:  is_file(): open_basedir restriction in effect. File(/web/live-example.instawp.site/public_html/wp-content/themes/<theme>/pages/refunds/index.md) is not within the allowed path(s): (/home/<user>/web/live-example.instawp.site/public_html:/home/<user>/tmp:/opt:...:/tmp:/usr/share:/usr/bin:/usr/local/bin:/bin:/var/www/html) in .../wp-content/plugins/blockstudio/includes/classes/tailwind.php

The files exist, but Blockstudio cannot find them from the web side, so:

  • Tailwind's editor compile misses candidates from page templates.
  • Markdown negotiation stops serving .md pages.
  • Prerender signatures don't pick up changes to those source files.

Expected

The stored paths should still work if the install's absolute root changes. Two options:

  • Store paths relative to the theme (or to the pages root), e.g. pages/refunds/index.md, and resolve them against get_stylesheet_directory() / get_template_directory() when they're read. _blockstudio_page_dependencies already does this with its theme: ids.
  • Or, when a stored absolute path isn't under the current theme root, rebase it with string logic before calling is_file(). Probing it with is_file() first is what triggers the open_basedir warning.

Workaround

Run the sync from the web context (for example the admin) rather than the jailed CLI, so the stored paths match what PHP-FPM sees.

Activity

  1. dnnsjsk commented on Oct 23, 2026

    @dnnsjsk
    Contributor

    Fixed and released in 7.7.7, implemented in e0f6d59f. Synced theme sources now use portable locations, and legacy absolute theme paths are rebased before filesystem checks. Markdown, layouts, editor Tailwind sources, and prerender dependencies use the resolved paths. Ordinary requests do not synchronize content or rewrite metadata. Regression tests include different CLI/web roots and open_basedir restrictions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions