fix: restore missing str_replace subject arg in MokoRestore standalone gen (#226) #228

Merged
jmiller merged 2 commits from fix/mokorestore-str-replace-args into dev 2026-07-06 01:17:02 +00:00
Owner

Problem

Every standalone-mode backup fatally errored at the "Generating standalone restore.php…" step:

MokoRestore error: str_replace() expects at least 3 arguments, 2 given
  .../Engine/MokoRestore.php:181
  #0 MokoRestore.php(181): str_replace('    $checks[] =...', '    $availableB...')
  #1 MokoRestore.php(80): ...::generateStandaloneScript()
  #2 SteppedBackupEngine.php(391): ...::generateStandalone(...)

generateStandaloneScript() rewrites the standalone script's "Backup Archive" pre-check with a str_replace(ORIG_heredoc, REPL_heredoc) — but the call was missing its third $php subject argument. Since PHP 8 that is a fatal ArgumentCountError at runtime (a php -l syntax check cannot catch it).

The archive still finalized and uploaded, but no restore.php was ever produced — the real root cause behind #226 (restore script missing on the remote).

Fix

Add the missing $php subject to the str_replace() at MokoRestore.php:181. Audited all seven str_replace calls in the file — this was the only short one.

Verify

  • php -l clean.
  • All other str_replace calls confirmed to carry their subject arg.

Refs #226

https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i

## Problem Every standalone-mode backup fatally errored at the **"Generating standalone restore.php…"** step: ``` MokoRestore error: str_replace() expects at least 3 arguments, 2 given .../Engine/MokoRestore.php:181 #0 MokoRestore.php(181): str_replace(' $checks[] =...', ' $availableB...') #1 MokoRestore.php(80): ...::generateStandaloneScript() #2 SteppedBackupEngine.php(391): ...::generateStandalone(...) ``` `generateStandaloneScript()` rewrites the standalone script's "Backup Archive" pre-check with a `str_replace(ORIG_heredoc, REPL_heredoc)` — but the call was **missing its third `$php` subject argument**. Since PHP 8 that is a fatal `ArgumentCountError` at runtime (a `php -l` syntax check cannot catch it). The archive still finalized and uploaded, but **no `restore.php` was ever produced** — the real root cause behind #226 (restore script missing on the remote). ## Fix Add the missing `$php` subject to the `str_replace()` at `MokoRestore.php:181`. Audited all seven `str_replace` calls in the file — this was the only short one. ## Verify - `php -l` clean. - All other `str_replace` calls confirmed to carry their subject arg. Refs #226 https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
jmiller added 2 commits 2026-07-06 01:16:18 +00:00
fix: restore missing subject arg in MokoRestore str_replace (standalone gen)
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 30s
0ae9bfd93a
MokoRestore::generateStandaloneScript() rewrites the 'Backup Archive'
pre-check via str_replace(ORIG, REPL) but was missing the third
$php subject argument, so every standalone-mode backup fatally errored
with 'str_replace() expects at least 3 arguments, 2 given' at the
'Generating standalone restore.php...' step. The archive still finalized
and uploaded, but no restore.php was produced -- the underlying cause of
#226 (restore script missing on the remote).

Refs #226

Claude-Session: https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
chore(version): pre-release bump to 02.58.04-dev [skip ci]
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
0a51ed75da
jmiller merged commit aeb9d18ccb into dev 2026-07-06 01:17:02 +00:00
jmiller deleted branch fix/mokorestore-str-replace-args 2026-07-06 01:17:02 +00:00
Sign in to join this conversation.