A lot bugfixes for ext-cache and deprecated files removed:
[mailer.git] / inc / extensions.php
index 62ab4f43018852eede4458dad60983498b366e17..5eb14f67ad7f43e8aaa1163807ee7a20897780ce 100644 (file)
@@ -88,7 +88,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
                $GLOBALS['ext_loaded']['lang'][$ext_name] = true;
                loadIncludeOnce($langInclude);
-       } elseif (($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
+       } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
                // No language file is not so good...
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s",
                        $ext_name, getLanguage()
@@ -104,7 +104,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
                $GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
                loadIncludeOnce($funcsInclude);
-       } elseif (($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
+       } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
                // No functions file is not so good...
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no own functions file or we cannot read from it.",
                        $ext_name
@@ -328,7 +328,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
                //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />\n";
                // Remove task from system when id and extension's name is valid
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
-               array(bigintval($task_id)), __FUNCTION__, __LINE__);
+                       array(bigintval($task_id)), __FUNCTION__, __LINE__);
        }
 
        // Is this the sql_patches?
@@ -361,7 +361,10 @@ function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
        $ext_name = GET_EXT_NAME($ext_id);
 
        // If it is not set then maybe there is no extension for that ID number
-       if ($ext_name == '') return false;
+       if (empty($ext_name)) {
+               // We should fix these all!
+               debug_report_bug(__FUNCTION__ . ': ext_name is empty. ext_id=' . $ext_id);
+       } // END - if
 
        // Set current SQL name
        EXT_SET_CURR_NAME($ext_name);
@@ -385,6 +388,9 @@ function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
 
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQLs::count=".COUNT_SQLS()."");
        if ((IS_SQLS_VALID() && (COUNT_SQLS() > 0))) {
+               // Run any filters depending on the action here
+               runFilterChain('extension_' . $load_mode, $ext_name);
+
                // Run SQL commands...
                runFilterChain('run_sqls');
 
@@ -468,7 +474,7 @@ function GET_EXT_VERSION ($ext_name) {
        // Empty extension name should be fixed!
        if (empty($ext_name)) {
                // Please report this bug!
-               debug_report_bug(__FUNCTION__.": ext_name is empty which is not allowed here.");
+               debug_report_bug(__FUNCTION__ . ': ext_name is empty which is not allowed here.');
        } // END - if
 
        // Extensions are all inactive during installation
@@ -669,10 +675,12 @@ function GET_EXT_NAME ($ext_id) {
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_name FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1",
-               array(bigintval($ext_id)), __FUNCTION__, __LINE__);
+                       array(bigintval($ext_id)), __FUNCTION__, __LINE__);
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
+
+       // Return the extension name
        return $ret;
 }
 
@@ -689,7 +697,7 @@ function GET_EXT_ID ($ext_name) {
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
-               array($ext_name), __FUNCTION__, __LINE__);
+                       array($ext_name), __FUNCTION__, __LINE__);
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }