Files
computer-playbook/roles/web-app-joomla/files/php/toggle_debug.php
T
kevinveenbirkenbachandClaude Opus 4.8 5aae5a0be3 fix(swarm-deploy): evaluate resolve-container-id in listmonk + joomla; hoist joomla PHP to files
In swarm mode *_CONTAINER_ADDRESS resolves to "$(/usr/bin/resolve-container-id
<stack> <service>)", which must reach /bin/sh unquoted so the subshell runs.

- listmonk: drop the `| quote` filter; shlex.quote single-quoted the whole
  "$(...)", suppressing the substitution, so docker received the literal token
  ("No such container: $(...)").
- joomla: rewrite the docker/container exec tasks from the shell argv-list form
  (executed directly, never via /bin/sh, so the $() was never evaluated) to the
  free-form string shell, and switch the raw `docker exec` calls to the
  `container` wrapper (the argv form had hidden them from the no-raw-docker lint).
- joomla: move the three inline PHP scripts (configuration.php debug toggle, DB
  settings patch, OIDC plugin ZIP packaging) out of inline `vars:` into
  files/php/*.php, fed via `lookup('file', ...)` over stdin to
  `container exec -i ... php --`, with their inputs passed as J_* env vars
  (the files/php + stdin convention already used by friendica/espocrm/snipe-it).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 05:43:31 +02:00

31 lines
1.3 KiB
PHP

<?php
$f = getenv('J_CONFIG_FILE');
if (!file_exists($f)) { fwrite(STDERR, "configuration.php missing\n"); exit(1); }
$c = file_get_contents($f);
$changed = 0;
$debug = getenv('J_MODE_DEBUG') === '1';
$err = getenv('J_ERR_LEVEL') ?: 'default';
// Clean up previously broken lines
$c = preg_replace('/^\s*public\s+1\s*=.*?;$/m', '', $c, -1, $nBad1); $changed += $nBad1;
$c = preg_replace('/^\s*public\s*=\s*maximum;$/m', '', $c, -1, $nBad2); $changed += $nBad2;
// Ensure: public $debug = true|false;
$lineDebug = "public \$debug = " . ($debug ? 'true' : 'false') . ";";
if (preg_match('/public\s*\$debug\s*=\s*[^;]*;/', $c)) {
$c = preg_replace('/public\s*\$debug\s*=\s*[^;]*;/', $lineDebug, $c, 1, $n); $changed += $n;
} else {
$c = preg_replace("/\n\}\s*$/", "\n\t".$lineDebug."\n}\n", $c, 1, $n); $changed += $n;
}
// Ensure: public $error_reporting = 'maximum'|'default';
$lineErr = "public \$error_reporting = '" . str_replace("'", "\\'", $err) . "';";
if (preg_match('/public\s*\$error_reporting\s*=\s*[^;]*;/', $c)) {
$c = preg_replace('/public\s*\$error_reporting\s*=\s*[^;]*;/', $lineErr, $c, 1, $n); $changed += $n;
} else {
$c = preg_replace("/\n\}\s*$/", "\n\t".$lineErr."\n}\n", $c, 1, $n); $changed += $n;
}
if ($changed) { file_put_contents($f, $c); echo "changed"; } else { echo "ok"; }