fix(remotecp): PHP-7.4-Deprecations beheben und PHP_DISPLAY_ERRORS respektieren

RemoteCP 4.0.3.5 hat nach jedem Neustart Deprecation-Meldungen oben auf der
Seite ausgegeben, obwohl PHP_DISPLAY_ERRORS=false gesetzt war.

Ich patche RemoteCP jetzt bei jedem Containerstart idempotent (greift auch
bei bestehenden Volumes):
- rcp_textparser.class.php: $hex{n} -> $hex[n], TMFColorParser-Konstruktor
  auf __construct() umgestellt
- GbxRemote.inc.php: $f_v{n} -> $f_v[n]
- core.functions.php: display_errors/display_startup_errors an
  PHP_DISPLAY_ERRORS gekoppelt statt hart auf 1; PHP-Warnings werden ohne
  Debug-Modus nur noch in cache/errors.log geschrieben
This commit is contained in:
Patrick Asmus committed 2026-11-01 12:47:14 +01:00
1 parent 592f047274
commit 5ca2f1587f
1 file changed
+44
+44
View File
@@ -244,6 +244,50 @@ else
echo "==> Vorhandene AdminServ-Daten gefunden. Keine Aenderungen."
fi
# ============================================================
# RemoteCP: PHP-7.4-Kompatibilitaet & Fehleranzeige (bei jedem Start)
# ============================================================
# RemoteCP 4.0.3.5 nutzt veraltete Syntax ($str{0}, PHP4-Konstruktor), die
# unter PHP 7.4 Deprecation-Meldungen im Browser erzeugt (unter PHP 8 fatal).
# Ausserdem erzwingt core.functions.php display_errors=1 per ini_set() und
# ignoriert damit PHP_DISPLAY_ERRORS. Die Patches sind idempotent und greifen
# auch bei bestehenden Volumes.
RCP_INC="$ADMINSERV_DIR/remotecp/includes"
if [ -d "$RCP_INC" ]; then
echo "==> Patche RemoteCP fuer PHP 7.4..."
# Geschweifte Klammern fuer String-Offsets -> eckige Klammern
[ -f "$RCP_INC/core/rcp_textparser.class.php" ] && sed -i -E \
-e 's/\$hex\{([0-9])\}/$hex[\1]/g' \
-e 's/function TMFColorParser\(/function __construct(/' \
"$RCP_INC/core/rcp_textparser.class.php"
[ -f "$RCP_INC/core/GbxRemote.inc.php" ] && sed -i -E \
-e 's/\$f_v\{([0-9])\}/$f_v[\1]/g' \
"$RCP_INC/core/GbxRemote.inc.php"
# display_errors an PHP_DISPLAY_ERRORS koppeln
if [ -f "$RCP_INC/core.functions.php" ]; then
sed -i -E \
-e "s/^ini_set\('display_errors', 1\);/ini_set('display_errors', getenv('PHP_DISPLAY_ERRORS') === 'true' ? 1 : 0);/" \
-e "s/^ini_set\('display_startup_errors', 1\);/ini_set('display_startup_errors', getenv('PHP_DISPLAY_ERRORS') === 'true' ? 1 : 0);/" \
"$RCP_INC/core.functions.php"
# PHP-Warnings ohne Debug-Modus nur loggen, nicht im Browser anzeigen
if ! grep -q 'tmserver-docker: PHP_DISPLAY_ERRORS' "$RCP_INC/core.functions.php"; then
sed -i "/if(error_reporting() == 0) return;/a\\
\\
\\t//tmserver-docker: PHP_DISPLAY_ERRORS - PHP-Warnings ohne Debug-Modus nur loggen\\
\\tif(\$errno == E_WARNING \&\& !ini_get('display_errors')) {\\
\\t\\twriteLog('errors', \"[\".date('c').\"] [PHP Warning] \$errstr on line \$errline in file \$errfile\");\\
\\t\\treturn true;\\
\\t}" "$RCP_INC/core.functions.php"
fi
fi
# sed -i legt neue Dateien als root an -> Besitzer wiederherstellen
chown www-data:www-data "$RCP_INC/core.functions.php" \
"$RCP_INC/core/rcp_textparser.class.php" "$RCP_INC/core/GbxRemote.inc.php" 2>/dev/null
fi
# ============================================================
# XAseco: First-Run-Logik
# ============================================================