Many rewrites to get rid of dublicate modreg inserts while ext-cache is registered
[mailer.git] / inc / load_extensions.php
index f8589b66d2f7f4a51a932a74ed05747f4512d366..731bbd4bf94aec7335ce0801324bccd38d1f3ea3 100644 (file)
@@ -287,9 +287,12 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($GLOBALS['cache_mode'] == 'init') && (
 
        // Free memory
        SQL_FREERESULT($res_ext_crt);
-} elseif (!EXT_IS_ACTIVE('cache')) {
+} elseif ((!EXT_IS_ACTIVE('cache')) || (($GLOBALS['cache_mode'] == 'init') && (getOutputMode() != 0))) {
        // Init filter system even when there are no extensions installed. #16
        initFilterSystem();
+} elseif ($GLOBALS['cache_mode'] != 'load') {
+       // Something unexpected!
+       debug_report_bug('Unexpected state in '.basename(__FILE__).': cache_mode='.$GLOBALS['cache_mode'].', numRows='.SQL_NUMROWS($res_ext_crt));
 }
 
 // Run the filter
@@ -301,11 +304,11 @@ if (!empty($DEL[0])) {
        foreach ($DEL as $del_ext) {
                // First remove entry from extensions table
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
-               array($del_ext), __FILE__, __LINE__);
+                       array($del_ext), __FILE__, __LINE__);
 
                // Remove (maybe?) found tasks (main task and possible updates
-               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE subject='[%s:]' AND (task_type='EXTENSION' OR task_type='EXTENSION_UPDATE')",
-               array($del_ext), __FILE__, __LINE__);
+               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `subject`='[%s:]' AND (`task_type`='EXTENSION' OR `task_type`='EXTENSION_UPDATE')",
+                       array($del_ext), __FILE__, __LINE__);
        } // END - foreach
 
        // I think it's not neccessary to run the optimization function here