Skip to content

Commit 3eb87f1

Browse files
committed
Fix: quarantine stale generated container class files on update
1 parent a6908df commit 3eb87f1

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎inc/container.class.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ public static function installUserData(Migration $migration, $version)
241241
/** @var DBmysql $DB */
242242
global $DB;
243243

244+
// Quarantine generated class files: hides stale ones from the autoloader, purged once migration succeeds.
245+
foreach (glob(PLUGINFIELDS_CLASS_PATH . '/*.class.php') ?: [] as $existing_file) {
246+
if (str_ends_with($existing_file, 'dropdown.class.php')) {
247+
continue;
248+
}
249+
250+
rename($existing_file, $existing_file . '.bak');
251+
}
252+
244253
// Disable oversized-table containers instead of crashing.
245254
$obj = new self();
246255
$active_containers = $obj->find(['is_active' => 1]);
@@ -495,6 +504,11 @@ public static function installUserData(Migration $migration, $version)
495504
self::create($container);
496505
}
497506

507+
// Migration succeeded: remaining quarantined files are stale for good.
508+
foreach (glob(PLUGINFIELDS_CLASS_PATH . '/*.class.php.bak') ?: [] as $stale_file) {
509+
unlink($stale_file);
510+
}
511+
498512
return true;
499513
}
500514

0 commit comments

Comments
 (0)