Debugs admin/plugins feature

main
Yasen Pramatarov 2026-01-19 11:40:36 +02:00
parent 064614f73f
commit aff2ec4003
2 changed files with 40 additions and 34 deletions

View File

@ -654,30 +654,36 @@ endif; ?>
try { try {
// Check plugin files exist // Check plugin files exist
$migrationFiles = glob($plugin['path'] . '/migrations/*.sql');
$hasMigration = !empty($migrationFiles);
$checkResults['files'] = [ $checkResults['files'] = [
'manifest' => file_exists($plugin['path'] . '/plugin.json'), 'manifest' => file_exists($plugin['path'] . '/plugin.json'),
'bootstrap' => file_exists($plugin['path'] . '/bootstrap.php'), 'bootstrap' => file_exists($plugin['path'] . '/bootstrap.php'),
'migration' => file_exists($plugin['path'] . '/migrations/create_' . $plugin['slug'] . '_tables.sql'), 'migration' => $hasMigration,
]; ];
// Check database tables // Check database tables
global $db; global $db;
$pluginTables = [];
if ($db instanceof PDO) { if ($db instanceof PDO) {
$stmt = $db->query("SHOW TABLES LIKE 'user_pro_%'"); $stmt = $db->query("SHOW TABLES");
$allTables = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); $allTables = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
$migrationFile = $plugin['path'] . '/migrations/create_' . $plugin['slug'] . '_tables.sql'; if ($hasMigration) {
if (file_exists($migrationFile)) { // Check each migration file for table references
foreach ($migrationFiles as $migrationFile) {
$migrationContent = file_get_contents($migrationFile); $migrationContent = file_get_contents($migrationFile);
$pluginTables = [];
foreach ($allTables as $table) { foreach ($allTables as $table) {
if (strpos($migrationContent, $table) !== false) { if (strpos($migrationContent, $table) !== false) {
$pluginTables[] = $table; $pluginTables[] = $table;
} }
} }
}
$pluginTables = array_unique($pluginTables);
}
}
$checkResults['tables'] = $pluginTables; $checkResults['tables'] = $pluginTables;
}
}
// Check plugin functions // Check plugin functions
$bootstrapPath = $plugin['path'] . '/bootstrap.php'; $bootstrapPath = $plugin['path'] . '/bootstrap.php';