]> git.mxchange.org Git - mailer.git/blobdiff - inc/filters.php
A lot bugfixes for ext-cache and deprecated files removed:
[mailer.git] / inc / filters.php
index 6d02e30e8409261650cab20ce3669268ccf6b6a2..e8f598c857c1f18dc1c89c20055ef1f343e61b3b 100644 (file)
@@ -180,10 +180,9 @@ function unregisterFilter ($filterName, $filterFunction, $force = false, $dry_ru
        } // END - if
 
        // Shall we remove? (default, not while just showing an extension removal)
-       if (!$dry_run) {
+       if ($dry_run === false) {
                // Mark for filter removal
-               $GLOBALS['filters']['chains'][$filterName][$filterFunction] = "R";
-               unset($GLOBALS['filters']['counter'][$filterName][$filterFunction]);
+               $GLOBALS['filters']['chains'][$filterName][$filterFunction] = 'R';
        } // END  - if
 }
 
@@ -192,7 +191,7 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) {
        // Is that filter chain there?
        if (!isset($GLOBALS['filters']['chains'][$filterName])) {
                // Then abort here (quick'N'dirty hack)
-               if ((!$silentAbort) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
+               if (($silentAbort === false) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
                        // Add fatal message
                        addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_NO_FILTER_FOUND'), $filterName);
                } // END - if
@@ -207,10 +206,10 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) {
        // Then run all filters
        foreach ($GLOBALS['filters']['chains'][$filterName] as $filterFunction=>$active) {
                // Debug message
-               //* DEBUG: */ echo __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): name={$filterName},func={$filterFunction},active={$active}<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running: name={$filterName},func={$filterFunction},active={$active}");
 
                // Is the filter active?
-               if ($active == 'Y') {
+               if (($active == 'Y') || ((in_array($filterName, array('extension_remove', 'post_extension_run_sql'))) && ($active == 'R'))) {
                        // Is this filter there?
                        if (!function_exists($filterFunction)) {
                                // Unregister it
@@ -224,14 +223,29 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) {
                        $returnValue = call_user_func_array($filterFunction, array($returnValue));
 
                        // Update usage counter
-                       $GLOBALS['filters']['counter'][$filterName][$filterFunction]++;
-               } // END - if
+                       countFilterUsage($filterName, $filterFunction);
+               } elseif (isDebugModeEnabled()) {
+                       // Debug message
+                       DEBUG_LOG(__FUNCTION__, __LINE__, "Skipped: name={$filterName},func={$filterFunction},active={$active}");
+               }
        } // END - foreach
 
        // Return the filtered content
        return $returnValue;
 }
 
+// Count the filter usage
+function countFilterUsage ($filterName, $filterFunction) {
+       // Is it there?
+       if (isset($GLOBALS['filters']['counter'][$filterName][$filterFunction])) {
+               // Yes, then increase
+               $GLOBALS['filters']['counter'][$filterName][$filterFunction]++;
+       } else {
+               // No, then create
+               $GLOBALS['filters']['counter'][$filterName][$filterFunction] = 1;
+       }
+}
+
 // -----------------------------------------------------------------------------
 // Generic filter functions we always need
 // -----------------------------------------------------------------------------