| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- // Post-update callback, wired through MANAGE_UPDATE_POST_HOOK in config.php.
- //
- // Runs after the release files are in place and after all pending migrations
- // have succeeded. Migrations handle data changes; this handles the two things
- // that have to happen on every single deploy regardless of what changed.
- declare(strict_types=1);
- /**
- * @param array $context app_root, instance, from_version, to_version,
- * backup_dir, run_id, migrations
- *
- * @return array{success: bool, error?: string}
- */
- function shopAfterUpdate(array $context): array
- {
- $notes = [];
- // 1. The release package excludes data/, so a fresh install or a release
- // that adds a new working directory needs them recreated here.
- foreach ([MANAGE_DIR, MANAGE_BACKUP_DIR, MANAGE_WORK_DIR, MANAGE_UPDATE_BACKUP_DIR] as $dir) {
- try {
- manageEnsureDir((string) $dir);
- } catch (Throwable $exception) {
- return [
- 'success' => false,
- 'error' => 'Arbeitsverzeichnis konnte nicht angelegt werden: ' . $exception->getMessage(),
- ];
- }
- }
- // 2. OPcache caches compiled bytecode keyed by path and mtime. The deploy
- // just replaced PHP files underneath a running process, so without this
- // the shop can keep serving the previous release until the cache expires
- // on its own.
- if (function_exists('opcache_reset') && ini_get('opcache.enable')) {
- $notes[] = opcache_reset() ? 'opcache_reset' : 'opcache_reset_failed';
- }
- manageClientLog('INFO', 'shopAfterUpdate finished', [
- 'from_version' => (string) ($context['from_version'] ?? ''),
- 'to_version' => (string) ($context['to_version'] ?? ''),
- 'notes' => $notes,
- ]);
- return ['success' => true];
- }
|