X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fextensions-functions.php;h=4dec81d05fcdf2edb805f58df47f5254fa8c7807;hb=12c1362cb389d6bfbc330db68e34d74ff10b143a;hp=58e0560271cb2ff34fe9bf6268eb01928cd3eaf9;hpb=6a8deec242fcd1b28090ad693e0cef67a1d0a818;p=mailer.git diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 58e0560271..4dec81d05f 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -42,11 +42,12 @@ if (!defined('__SECURITY')) { // Load the extension and maybe found language and function files. function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = false) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_mode=' . $ext_mode . ',ext_ver=' . $ext_ver . ',dry_run=' . intval($dry_run)); // Loading an extension in same mode, but not test/update, twice is not // good, so is the extension $ext_name already loaded in mode $ext_mode? if ((isset($GLOBALS['loaded_extension'][$ext_name][$ext_mode])) && (!in_array($ext_mode, array('update', 'test')))) { // If this happens twice, we need the bug report from you, except for updates/tests - debug_report_bug(__FUNCTION__, __LINE__, '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true)); + debug_report_bug(__FUNCTION__, __LINE__, __FUNCTION__ . '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true)); } // END - if // Make sure this situation can only happen once @@ -151,19 +152,16 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal // Extensions are not always active by default setExtensionAlwaysActive('N'); - // Extension update notes - // @TODO Do we still need this? setExtensionUpdateNotes(''); - // Include the extension file loadCurrentExtensionInclude(); // Is this extension deprecated? - if ((isExtensionDeprecated()) && (getExtensionMode() != 'test')) { + if ((isExtensionDeprecated()) && (!in_array(getExtensionMode(), array('test', 'update', 'deactivate'))) && (isExtensionActive($ext_name))) { // Deactivate the extension doDeactivateExtension($ext_name); // Abort here - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Extension load aborted, ext_name=' . $ext_name); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Extension load aborted, ext_name=' . $ext_name . ' - Extension is deprecated.'); return false; } // END - if @@ -181,7 +179,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal // Registers an extension and possible update dependencies function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates = false) { // Set current extension name - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $taskId . ',dry_run=' . intval($dry_run) . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $taskId . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - ENTERED!'); setCurrentExtensionName($ext_name); // Enable dry-run @@ -950,7 +948,7 @@ function doDeactivateExtension ($ext_name) { // Is the extension installed? if (!isExtensionInstalled($ext_name)) { // Non-installed extensions cannot be activated - debug_report_bug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name); + debug_report_bug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name . ',getExtensionMode()=' . getExtensionMode()); } // END - if // Activate the extension @@ -963,6 +961,9 @@ function doDeactivateExtension ($ext_name) { // Create new task (we ignore the task id here) createExtensionDeactivationTask($ext_name); + // Rebuild cache + rebuildCache('extension', 'extension'); + // Notify the admin sendAdminNotification( '{--ADMIN_EXTENSION_DEACTIVATED_SUBJECT--}', @@ -1313,7 +1314,7 @@ function isExtensionUpdateRunning ($ext_name, $ignoreDependencies = false) { $isRunning = false; // Walk through whole array - foreach ($GLOBALS['ext_running_updates'] as $ext1=>$depends) { + foreach ($GLOBALS['ext_running_updates'] as $ext1 => $depends) { // Is it found? //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext1=' . $ext1 . ',ext_name=' . $ext_name . ',depends=' . print_r($depends, true)); if (($ext1 == $ext_name) || ((in_array($ext_name, $depends)) && ($ignoreDependencies === false))) {