[pLog-svn] r6089 - plog/branches/lifetype-1.2/class/security

mark at devel.lifetype.net mark at devel.lifetype.net
Thu Nov 29 01:27:47 EST 2007


Author: mark
Date: 2007-11-29 01:27:47 -0500 (Thu, 29 Nov 2007)
New Revision: 6089

Modified:
   plog/branches/lifetype-1.2/class/security/pipeline.class.php
Log:
Refactoring the for-loop block, we just need one for-loop to run all pipeline filters.

If error happened, It will keep the first invalid result to $this->_result.

If there is no error happened, it will keep the last pipeline filter result.

Modified: plog/branches/lifetype-1.2/class/security/pipeline.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/pipeline.class.php	2007-11-29 05:52:47 UTC (rev 6088)
+++ plog/branches/lifetype-1.2/class/security/pipeline.class.php	2007-11-29 06:27:47 UTC (rev 6089)
@@ -106,7 +106,7 @@
             if( !is_array($_pLogPipelineRegisteredFilters))     // make sure that we have an array...
                 $_pLogPipelineRegisteredFilters = Array();
 
-            $_pLogPipelineRegisteredFilters["$filterClass"] = false;
+            $_pLogPipelineRegisteredFilters["$filterClass"] =  $filterClass;
         }
 
         /**
@@ -129,53 +129,30 @@
             // Assume that this will be successful
             $this->_result = new PipelineResult( true );
 
+            // flag to represent the pipeline filters validate status
+            $filterValidStatus = true;
+
             // if enabled, then check all the filters
-            foreach( $_pLogPipelineRegisteredFilters as $filterClass => $executed ) {
+            foreach( $_pLogPipelineRegisteredFilters as $filterClass ) {
                 // create an instance of the filter
                 $pipelineRequest = new PipelineRequest( $this->_httpRequest, $this->_blogInfo );
                 $filter = new $filterClass( $pipelineRequest );
                 // and execute it...
                 $result = $filter->filter();
-				// and cahge the executed flag to ture
-				$_pLogPipelineRegisteredFilters["$filterClass"] = true;
-                // if there was an error, we better say so now
-                // and quite, making sure that we're keeping the
-                // error code
 
-                // Save off the result
-				$this->_result = $result;
-
-                if( !$result->isValid()) {
-                    // break out of this loop
-                    break;
+                // We just keep the first invalid pipeline filter result
+                if( $filterValidStatus && !$result->isValid()) {
+                    $this->_result = $result;
+                    $filterValidStatus = false;
                 }
-            }
 
-            // If one of the filters returns that this was not a valid result
-            if ( !$this->_result->isValid() ) {
-                // Now rerun through all of the filters so they can clean up
-                // if they have saved anything persistantly
-                // This also gives filters a chance to do anything else they
-                // want to do (i.e. report ip address to dns blacklist)
-
-                foreach( $_pLogPipelineRegisteredFilters as $filterClass => $executed ) {
-                    // We just need to run the unexecuted filters
-                    if( !$executed ) {
-                        // create an instance of the filter
-                        $pipelineRequest = new PipelineRequest( $this->_httpRequest,
-                                                                $this->_blogInfo,
-                                                                true );
-                        $filter = new $filterClass( $pipelineRequest );
-                        // and execute it...
-                        $result = $filter->filter();
-        				// and cahge the executed flag to ture
-        				$_pLogPipelineRegisteredFilters["$filterClass"] = true;
-                        // if there was an error, we want to keep going
-                    }
-                }
+                // If pipeline filter result vlidate, we just the $this->_result
+                // to the last result every time.
+                if( $filterValidStatus )
+                    $this->_result = $result;
             }
 
             return $this->_result ;
         }
     }
-?>
+?>
\ No newline at end of file



More information about the pLog-svn mailing list