Add caching to the auto_loader for interfaces (#7320)

* update auto loader to load and cache interfaces

* use new method to update the auto loader cache

* use new interface

* use new interface to trigger a cache flush

* update the console upgrade menu

* update the missing implements syntax

* add the clear_cache to the flush cache button
This commit is contained in:
frytimo
2025-03-15 12:13:36 -03:00
committed by GitHub
parent 99b3100ee9
commit 0a42d8f198
7 changed files with 251 additions and 98 deletions

View File

@@ -621,6 +621,33 @@ $text['label-update_filesystem_permissions']['zh-cn'] = "";
$text['label-update_filesystem_permissions']['ja-jp'] = "";
$text['label-update_filesystem_permissions']['ko-kr'] = "";
$text['message-updated_autoloader']['en-us'] = 'Updated autoloader';
$text['message-updated_autoloader']['en-gb'] = 'Updated autoloader';
$text['message-updated_autoloader']['ar-eg'] = 'تم تحديث أداة التحميل التلقائي';
$text['message-updated_autoloader']['de-at'] = 'Aktualisierter Autoloader';
$text['message-updated_autoloader']['de-ch'] = 'Aktualisierter Autoloader';
$text['message-updated_autoloader']['de-de'] = 'Aktualisierter Autoloader';
$text['message-updated_autoloader']['el-gr'] = 'Ενημερώθηκε η αυτόματη φόρτωση';
$text['message-updated_autoloader']['es-cl'] = 'Cargador automático actualizado';
$text['message-updated_autoloader']['es-mx'] = 'Cargador automático actualizado';
$text['message-updated_autoloader']['fr-ca'] = 'Chargeur automatique mis à jour';
$text['message-updated_autoloader']['fr-fr'] = 'Chargeur automatique mis à jour';
$text['message-updated_autoloader']['he-il'] = 'טוען אוטומטי מעודכן';
$text['message-updated_autoloader']['it-it'] = 'Caricatore automatico aggiornato';
$text['message-updated_autoloader']['ka-ge'] = 'განახლებულია ავტოჩამტვირთავი';
$text['message-updated_autoloader']['nl-nl'] = 'Bijgewerkte autoloader';
$text['message-updated_autoloader']['pl-pl'] = 'Zaktualizowany autoloader';
$text['message-updated_autoloader']['pt-br'] = 'Carregador automático atualizado';
$text['message-updated_autoloader']['pt-pt'] = 'Carregador automático atualizado';
$text['message-updated_autoloader']['ro-ro'] = 'Încărcare automată actualizată';
$text['message-updated_autoloader']['ru-ru'] = 'Обновленный автозагрузчик';
$text['message-updated_autoloader']['sv-se'] = 'Uppdaterad autoloader';
$text['message-updated_autoloader']['uk-ua'] = 'Оновлений автозавантажувач';
$text['message-updated_autoloader']['tr-tr'] = 'Güncellenmiş otomatik yükleyici';
$text['message-updated_autoloader']['zh-cn'] = '更新的自动加载器';
$text['message-updated_autoloader']['ja-jp'] = 'オートローダーの更新';
$text['message-updated_autoloader']['ko-kr'] = '업데이트된 자동 로더';
$text['label-upgrade_menu']['en-us'] = "Menu Defaults";
$text['label-upgrade_menu']['en-gb'] = "Menu Defaults";
$text['label-upgrade_menu']['ar-eg'] = "افتراضيات القائمة";

View File

@@ -141,9 +141,6 @@
fclose($file_handle);
}
//include files
require dirname(__DIR__, 2) . "/resources/require.php";
//check the permission
if(defined('STDIN')) {
$display_type = 'text'; //html, text
@@ -177,11 +174,13 @@
exit();
}
//always update the auto_loader cache just-in-case the source files have updated
$auto_loader = new auto_loader();
$auto_loader->reload_classes();
$auto_loader->update_cache();
$auto_loader->clear_cache();
//always update the now global autoload cache just-in-case the source files have updated
$autoload->update();
//trigger clear cache for any classes that require it
foreach ($autoload->get_interface_list('clear_cache') as $class) {
$class::clear_cache();
}
//get the version of the software
if ($upgrade_type == 'version') {

View File

@@ -147,18 +147,13 @@ function show_upgrade_menu() {
* @global type $text
*/
function do_upgrade_auto_loader() {
global $text;
//remove temp file
unlink(sys_get_temp_dir() . '/' . auto_loader::FILE);
global $text, $autoload;
//remove temp files
unlink(sys_get_temp_dir() . '/' . auto_loader::CLASSES_FILE);
unlink(sys_get_temp_dir() . '/' . auto_loader::INTERFACES_FILE);
//create a new instance of the autoloader
$loader = new auto_loader();
//reload the classes
$loader->reload_classes();
echo "{$text['label-reloaded_classes']}\n";
//re-create cache file
if ($loader->update_cache()) {
echo "{$text['label-updated_cache']}\n";
}
$autoload->update();
echo "{$text['message-updated_autoloader']}\n";
}
/**
@@ -195,7 +190,7 @@ function do_filesystem_permissions($text, settings $settings) {
$directories[] = $log_directory . '/xml_cdr';
}
//update the auto_loader cache permissions file
$directories[] = sys_get_temp_dir() . '/' . auto_loader::FILE;
$directories[] = sys_get_temp_dir() . '/' . auto_loader::CLASSES_FILE;
//execute chown command for each directory
foreach ($directories as $dir) {
if ($dir !== null) {