Skip to content

Improve handling of requests, markup and local files - #1245

Open
selul wants to merge 3 commits into
developmentfrom
fix/request-and-markup-handling
Open

selul wants to merge 3 commits into
developmentfrom
fix/request-and-markup-handling

Conversation

@selul

@selul selul commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

A set of small changes to how the plugin handles requests, rewrites markup and works with local files.

  • API requests use WordPress's default request settings.
  • Logs: log files get a per-site file name, the log directory gets an index.html and an .htaccess, and the log viewer answers administrators. Existing logs are moved to the new names on the next admin request, or the next time a log is read or written.
  • Page profiler endpoint: the token fields are typed on the route and signed as separate values, a stored profile is kept until it expires, and background URLs are matched against the service host.
  • Image lazy loading changes loading, srcset and sizes only where they are attributes of the image tag.
  • Video player: the web component sets the video source on the element, and the front-end script is versioned by its build hash like the editor script.
  • Uploads: an upload that is not offloaded keeps the name of its own file.

phpstan-baseline.neon loses one entry that the logger change made stale.

How to test the changes in this Pull Request:

  1. Run composer phpunit and npm test.
  2. With lazy loading on, check a page with images, an embedded video and a video player block: they load as before, with and without "native lazy load".
  3. In Settings, open the offload/rollback logs after a transfer: the logs show for an administrator.
  4. With offloading on, upload the same image twice: the second one still gets a numbered name in the cloud.

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?

Verification

Check Result
PHPUnit, full suite (PHP 8.4, WordPress 7.1) 607 tests pass at 664fea48 (592 on the base)
New and changed PHP tests on PHP 8.0 36 tests pass
Each new test on the base branch fails (15 of 15 cases)
Jest 240 tests pass
composer phpcs, composer phpstan, npm run lint pass

Performance of the image attribute patterns

Measured on PHP 8.4 with Optml_Manager::replace_content() on a page of typical lazy-loaded images, median of 25 runs, base branch against this one:

Page PCRE JIT on PCRE JIT off
50 images 2.47 ms → 2.58 ms 3.50 ms → 3.69 ms
300 images 18.50 ms → 19.04 ms 24.81 ms → 26.26 ms

That is about 2 µs more per lazy-loaded image with JIT and about 5 µs without. On oversized tags the new pattern stays linear: a tag with 100,000 spaces before its attributes took 2.3 s in the previous srcset/sizes pattern without JIT and takes 0.1 ms now. A tag with more attributes than PCRE's limits allow (above roughly 2,000 with JIT, 12,000 without) is left as written.

On a corpus of 22 tag shapes, with native lazy loading off and on, the output is the same as before except where an attribute name appears inside another attribute's value, and in three kinds of unusual markup: a duplicated loading attribute (only the first is changed), an upper-case LOADING (rewritten in place instead of a second attribute being added), and srcset written with no space before it (removed instead of renamed).

Not proven

  • The suite was not run on PHP 7.4: the WordPress test bootstrap does not start there in my environment. The changed files pass a PHP 7.4 syntax check.
  • The script version change in inc/video_player.php has no PHPUnit test, because the PHPUnit job does not build the assets it reads.
  • The .htaccess rules were not exercised on Apache.

🤖 Generated with Claude Code

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@selul selul self-assigned this Nov 19, 2026
@pirate-bot

pirate-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Plugin build for 1faad73 is ready 🛎️!

selul and others added 2 commits November 19, 2026 17:57
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
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