| 12345678910111213141516171819202122232425262728293031 |
- <?php
- // Post-update callback, wired up in manage-client/config.php as
- // MANAGE_UPDATE_POST_HOOK. It runs after a release has been deployed and after
- // the release's migrations have succeeded.
- //
- // The context is documented in the client package under
- // docs/07_POST_UPDATE_HOOKS.md: app_root, instance, from_version, to_version,
- // backup_dir, run_id and the migrations applied in this run.
- function psaAfterUpdate(array $context): void
- {
- $appRoot = rtrim((string) $context["app_root"], "/\\");
- // A release ships no data/ directory, so a new installation - or a release
- // that starts writing somewhere new - needs the writable directories to
- // exist before the first request hits them.
- foreach (["data", "data/uploads", "data/logs"] as $relative) {
- $directory = $appRoot . "/" . $relative;
- if (!is_dir($directory) && !mkdir($directory, 02775, true) && !is_dir($directory)) {
- throw new RuntimeException("Verzeichnis konnte nicht angelegt werden: " . $relative);
- }
- }
- // The deployment replaced PHP files underneath a running opcache. Resetting
- // it here only helps when the update was triggered from the admin panel;
- // from the CLI it is a no-op, because the web server runs its own cache.
- if (function_exists("opcache_reset") && ini_get("opcache.enable")) {
- @opcache_reset();
- }
- }
|