fix(autoload): canary DomainModel after Composer load
Stale vendor/ after the PSR-4 cutover omits AKSRT\ from autoload_psr4, so helpers fatal on DomainModel constants. Fail loud with composer install/dump-autoload guidance and document the deploy step in README + ADR.
This commit is contained in:
+16
-2
@@ -63,18 +63,32 @@ if (!function_exists('aksrt_get_setting')) {
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 加载 Composer 依赖(OAuth2 客户端库等)
|
||||
// 加载 Composer 依赖(第三方库 + 主题 PSR-4:AKSRT\ → src/AKSRT/)
|
||||
// ============================================================
|
||||
$composer_autoload = AKSRT_DIR . '/vendor/autoload.php';
|
||||
if (!file_exists($composer_autoload)) {
|
||||
wp_die(
|
||||
esc_html__('AKSRT requires Composer dependencies. Run composer install in the theme directory.', 'aksrt'),
|
||||
esc_html__('AKSRT requires Composer dependencies. Run "composer install" in the theme directory.', 'aksrt'),
|
||||
esc_html__('AKSRT theme', 'aksrt'),
|
||||
['response' => 500]
|
||||
);
|
||||
}
|
||||
require_once $composer_autoload;
|
||||
|
||||
// Theme classes live under src/AKSRT/ and only load via Composer PSR-4.
|
||||
// Stale vendor/ (e.g. install before composer.json gained "AKSRT\\") leaves
|
||||
// autoload_psr4 without AKSRT\ and fatals on the first DomainModel reference.
|
||||
if (!class_exists(\AKSRT\Core\DomainModel::class, true)) {
|
||||
wp_die(
|
||||
esc_html__(
|
||||
'AKSRT class autoload is incomplete: AKSRT\\Core\\DomainModel was not found. In the theme directory run "composer install" (or "composer dump-autoload -o"), then clear any opcode cache (opcache_reset / php-fpm reload).',
|
||||
'aksrt'
|
||||
),
|
||||
esc_html__('AKSRT theme', 'aksrt'),
|
||||
['response' => 500]
|
||||
);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 加载 Bootstrap(辅助函数 → 类文件 → 核心钩子)
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user