fix(install): guard package script against Cannot redeclare class fatal #301
Reference in New Issue
Block a user
Delete Branch "fix/package-script-redeclare-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Wraps Pkg_MokoSuiteBackupInstallerScript in a class_exists guard so the package update flow (which can include script.php twice in one request) no longer fatals with a compile-time Cannot redeclare class. Live error hit on suite.dev.
https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
Package updates could fatal with a compile-time "Cannot redeclare class Pkg_MokoSuiteBackupInstallerScript" when Joomla extracts/includes the package script.php twice in one request (two tmp/install_* dirs). Because the class is a top-level unconditional declaration it is early-bound at compile time, so a runtime return can't prevent the redeclare — wrapping it in `if (!class_exists(...)) { ... }` makes it a conditional (runtime) declaration, so the second include is a no-op instead of a fatal. Claude-Session: https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i