]> git.mxchange.org Git - mailer.git/blobdiff - inc/filters.php
Fix for parser error
[mailer.git] / inc / filters.php
index 433f4958099751fac2a590f2c0131458aee57208..5f9fa665c497d402768a257adfa84ae2a8fc1b83 100644 (file)
@@ -47,8 +47,7 @@ function initFilterSystem () {
        // Is the filter already initialized?
        if ((isset($GLOBALS['filters']['chains'])) && (is_array($GLOBALS['filters']['chains']))) {
                // Then abort here
-               addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_ALREADY_INIT'));
-               return false;
+               debug_report_bug(getMessage('FILTER_FAILED_ALREADY_INIT'));
        } // END - if
 
        // Init the filter system (just some ideas)
@@ -63,7 +62,26 @@ function initFilterSystem () {
        $GLOBALS['filters']['counter'] = array();
 
        // Load all saved filers if sql_patches is updated
-       if (GET_EXT_VERSION('sql_patches') >= '0.5.9') {
+       if (isset($GLOBALS['cache_array']['filter']['filter_name'])) {
+               // Found in cache so rewrite the array
+               $filterArray = array();
+               foreach ($GLOBALS['cache_array']['filter']['filter_name'] as $idx => $filterName) {
+                       // Get filter function
+                       $filterFunction = $GLOBALS['cache_array']['filter']['filter_function'][$idx];
+
+                       // Add the element with mapped index
+                       $filterArray['counter'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_counter'][$idx];
+                       $filterArray['loaded'][$filterName][$filterFunction]  = true;
+                       $filterArray['chains'][$filterName][$filterFunction]  = $GLOBALS['cache_array']['filter']['filter_active'][$idx];
+               } // END - foreach
+
+               // Set the array
+               //die('<pre>'.print_r($filterArray, true).'</pre>');
+               $GLOBALS['filters'] = $filterArray;
+
+               // Remove the cache
+               unset($GLOBALS['cache_array']['filter']);
+       } elseif (GET_EXT_VERSION('sql_patches') >= '0.5.9') {
                // Init add
                $add = '';
                if (GET_EXT_VERSION('sql_patches') >= '0.6.0') $add = ", `filter_counter`";
@@ -100,7 +118,7 @@ ORDER BY `filter_id` ASC", __FUNCTION__, __LINE__);
 
                // Free result
                SQL_FREERESULT($result);
-       } // END - if
+       }
 
        // Init filters
        registerFilter('init', 'UPDATE_LOGIN_DATA');
@@ -142,7 +160,7 @@ function registerFilter ($filterName, $filterFunction, $silentAbort = true, $for
        // Is that filter already there?
        if ((isset($GLOBALS['filters']['chains'][$filterName][$filterFunction])) && (!$force)) {
                // Then abort here
-               if (!$silentAbort) {
+               if ($silentAbort === false) {
                        addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_ALREADY_ADDED'), array($filterFunction, $filterName));
                } // END - if
 
@@ -187,11 +205,14 @@ function unregisterFilter ($filterName, $filterFunction, $force = false, $dry_ru
 }
 
 // "Runs" the given filters, data is optional and can be any type of data
-function runFilterChain ($filterName, $data = null, $silentAbort = true) {
+function runFilterChain ($filterName, $data = null) {
        // Is that filter chain there?
        if (!isset($GLOBALS['filters']['chains'][$filterName])) {
                // We should find all these non-existing filter chains
-               debug_report_bug('Filter chain '.$filterName.' not found!');
+               DEBUG_LOG(__FUNCTION__, __LINE__, 'Filter chain ' . $filterName . ' not found!');
+
+               // Abort here
+               return false;
        } // END - if
 
        // Default return value
@@ -319,9 +340,9 @@ function FILTER_FLUSH_FILTERS () {
                        foreach ($filterArray as $filterFunction => $cnt) {
                                // Construct and add the query
                                ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_filters` SET `filter_counter`=%s WHERE `filter_name`='%s' AND `filter_function`='%s' LIMIT 1",
-                               bigintval($cnt),
-                               $filterName,
-                               $filterFunction
+                                       bigintval($cnt),
+                                       $filterName,
+                                       $filterFunction
                                ));
                        } // END - foreach
                } // END - foreach