getFileName() ?: 'unknown'; } catch (\Throwable $e) { $path = 'unknown'; } error_log(sprintf('[Grav Upgrade] Installer loaded from %s: %s', $source, $path)); }; if (class_exists('Grav\\Installer\\Install', false)) { // OLD Install class is already loaded. We cannot load the NEW one due to PHP limitations. // However, we can work around this by: // 1. Using a different class name for the NEW installer // 2. Or, accepting that the OLD Install class will run but ensuring it can still upgrade properly // For now, use the OLD Install class but set its location to this extracted package // so it processes files from here $install = Grav\Installer\Install::instance(); // Use reflection to update the location property to point to this package $reflection = new \ReflectionClass($install); if ($reflection->hasProperty('location')) { $locationProp = $reflection->getProperty('location'); $locationProp->setAccessible(true); $locationProp->setValue($install, __DIR__ . '/..'); } $logInstallerSource($install, 'existing installation'); return $install; } // Normal case: Install class not yet loaded, load the NEW one require_once __DIR__ . '/src/Grav/Installer/Install.php'; $install = Grav\Installer\Install::instance(); $logInstallerSource($install, 'extracted update package'); return $install;