[pLog-svn] r3330 - plog/trunk

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Thu May 4 11:00:25 GMT 2006


Author: jondaley
Date: 2006-05-04 11:00:24 +0000 (Thu, 04 May 2006)
New Revision: 3330

Modified:
   plog/trunk/wizard.php
Log:
more result closing to lower memory usage

Modified: plog/trunk/wizard.php
===================================================================
--- plog/trunk/wizard.php	2006-05-03 23:53:17 UTC (rev 3329)
+++ plog/trunk/wizard.php	2006-05-04 11:00:24 UTC (rev 3330)
@@ -1329,38 +1329,45 @@
             foreach( $Inserts as $key => $insert ) {
 				$checkKeyQuery = "SELECT * FROM ".$this->_dbPrefix."config WHERE config_key ='".$key."';";
 				$result = $this->_db->Execute($checkKeyQuery);
-				if ($result->RecordCount() == 0)
-				{
-                        // try to guess the url where plog is running
-		            $httpProtocol = (array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
-		            $httpHost = $_SERVER["HTTP_HOST"];
-		            $requestUrl = $_SERVER["REQUEST_URI"];
-		            $requestUrl = str_replace( "/wizard.php", "", $requestUrl );
-		            $plogUrl = $httpProtocol.$httpHost.$requestUrl;
-		            // Find some of the tools we are going to need (last one is for os x, with fink installed)
-		            // TBD: support for Windows specific directories
-		            $folders = Array( "/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/" );
-		            $finder = new FileFinder();
-		            $pathToUnzip = $finder->findBinary( "unzip", $folders );
-		            $pathToTar = $finder->findBinary( "tar", $folders);
-		            $pathToGzip = $finder->findBinary( "gzip", $folders);
-		            $pathToBzip2 = $finder->findBinary( "bzip2", $folders);
-		            $pathToConvert = $finder->findBinary( "convert", $folders);
-	                // replace the de prefix and base url
-	                $query = str_replace( "{dbprefix}", $this->_dbPrefix, $insert );
-	                $query = str_replace( "{plog_base_url}", $plogUrl, $query );
-	                // replace also the placeholders for the paths to the tools
-	                $query = str_replace( "{path_to_tar}", $pathToTar, $query );
-	                $query = str_replace( "{path_to_unzip}", $pathToUnzip, $query );
-	                $query = str_replace( "{path_to_bz2}", $pathToBzip2, $query );
-	                $query = str_replace( "{path_to_gzip}", $pathToGzip, $query );
-	                $query = str_replace( "{path_to_convert}", $pathToConvert, $query );
-	                $query = str_replace( "{path_to_convert}", $pathToConvert, $query );
-	                if( !$this->_db->Execute( $query )) {
-	                    $message .= "Error executing code: ".$this->_db->ErrorMsg()."<br/>";
-	                    $errors = true;
-	                }
-	            }
+                if(!$result){
+                    $message .= "Error executing code: ".$this->_db->ErrorMsg()."<br/>";
+                    $errors = true;
+                }
+				else{
+                    $result->Close();
+                    
+                    if ($result->RecordCount() == 0){
+                            // try to guess the url where plog is running
+                        $httpProtocol = (array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
+                        $httpHost = $_SERVER["HTTP_HOST"];
+                        $requestUrl = $_SERVER["REQUEST_URI"];
+                        $requestUrl = str_replace( "/wizard.php", "", $requestUrl );
+                        $plogUrl = $httpProtocol.$httpHost.$requestUrl;
+                            // Find some of the tools we are going to need (last one is for os x, with fink installed)
+                            // TBD: support for Windows specific directories
+                        $folders = Array( "/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/" );
+                        $finder = new FileFinder();
+                        $pathToUnzip = $finder->findBinary( "unzip", $folders );
+                        $pathToTar = $finder->findBinary( "tar", $folders);
+                        $pathToGzip = $finder->findBinary( "gzip", $folders);
+                        $pathToBzip2 = $finder->findBinary( "bzip2", $folders);
+                        $pathToConvert = $finder->findBinary( "convert", $folders);
+                            // replace the de prefix and base url
+                        $query = str_replace( "{dbprefix}", $this->_dbPrefix, $insert );
+                        $query = str_replace( "{plog_base_url}", $plogUrl, $query );
+                            // replace also the placeholders for the paths to the tools
+                        $query = str_replace( "{path_to_tar}", $pathToTar, $query );
+                        $query = str_replace( "{path_to_unzip}", $pathToUnzip, $query );
+                        $query = str_replace( "{path_to_bz2}", $pathToBzip2, $query );
+                        $query = str_replace( "{path_to_gzip}", $pathToGzip, $query );
+                        $query = str_replace( "{path_to_convert}", $pathToConvert, $query );
+                        $query = str_replace( "{path_to_convert}", $pathToConvert, $query );
+                        if( !$this->_db->Execute( $query )) {
+                            $message .= "Error executing code: ".$this->_db->ErrorMsg()."<br/>";
+                            $errors = true;
+                        }
+                    }
+                }
             }
 
                 // check to see if we need to remove duplicates and the id index
@@ -1447,7 +1454,7 @@
                 else
                     $numUpdated++;
             }
-
+            $res1->Close();
             $this->message .= "{$numUpdated} users updated<br/>";
             return true;                        
         }
@@ -1477,6 +1484,7 @@
             while( $row = $res1->FetchRow()) {
                 $numComments[$row["article_id"]] = $row["total"];
             }
+            $res1->Close();
             
             // total number of active comments
             $res2 = $this->db->Execute( $query2 );
@@ -1488,6 +1496,7 @@
             while( $row = $res2->FetchRow()) {
                 $numActiveComments[$row["article_id"]] = $row["total"];
             }
+            $res2->Close();
             
             // number of trackbacks
             $res3 = $this->db->Execute( $query3 );
@@ -1499,6 +1508,7 @@
             while( $row = $res3->FetchRow()) {
                 $numTrackbacks[$row["article_id"]] = $row["total"];
             }           
+            $res3->Close();
             
             // article ids
             $res4 = $this->db->Execute( $query4 );
@@ -1540,6 +1550,7 @@
                 else
                     $numUpdated++;
             }
+            $res4->Close();
             
             $this->message .= "{$numUpdated} articles updated<br/>";
             return true;
@@ -1565,6 +1576,7 @@
             while( $row = $res1->FetchRow()) {
                 $numArticles[$row["category_id"]] = $row["total"];
             }
+            $res1->Close();
                         
             // total number of active comments
             $res2 = $this->db->Execute( $query2 );
@@ -1576,6 +1588,7 @@
             while( $row = $res2->FetchRow()) {
                 $numActiveArticles[$row["category_id"]] = $row["total"];
             }
+            $res2->Close();
             
             // load each one of the categories and update them
             $res3 = $this->db->Execute( $query3 );
@@ -1607,6 +1620,7 @@
                 else
                     $numUpdated++;
             }
+            $res3->Close();
             
             $this->message .= "{$numUpdated} categories updated<br/>";
             return true;
@@ -1649,6 +1663,7 @@
             while( $row = $res1->FetchRow()) {
                 $numArticles[$row["blog_id"]] = $row["total"];
             }
+            $res1->Close();
                         
             // total number of active comments
             $res2 = $this->db->Execute( $query2 );
@@ -1660,6 +1675,7 @@
             while( $row = $res2->FetchRow()) {
                 $numComments[$row["blog_id"]] = $row["total"];
             }
+            $res2->Close();
             
             // total number of trackbacks
             $res3 = $this->db->Execute( $query3 );
@@ -1671,6 +1687,7 @@
             while( $row = $res3->FetchRow()) {
                 $numTrackbacks[$row["blog_id"]] = $row["total"];
             }
+            $res3->Close();
             
             // update and create dates
             $res5 = $this->db->Execute( $query5 );
@@ -1684,6 +1701,7 @@
                 $createDates[$row["blog_id"]] = $row["create_date"];
                 $lastUpdateDates[$row["blog_id"]] = $row["last_update_date"];
             }
+            $res5->Close();
                         
             // load each one of the categories and update them
             $res4 = $this->db->Execute( $query4 );
@@ -1729,6 +1747,7 @@
                 else
                     $numUpdated++;
             }
+            $res4->Close();
             
             $this->message .= "{$numUpdated} blogs updated<br/>";
             return true;            
@@ -1775,6 +1794,7 @@
                 else
                     $this->message .= "Error adding trackback with id ".$row["id"]."<br/>";
             }
+            $result->Close();
             
             $this->message .= "{$totalAdded} trackbacks modified.<br/>";            
         
@@ -1798,6 +1818,7 @@
             while( $row = $res1->FetchRow()) {
                 $numLinks[$row["category_id"]] = $row["total"];
             }
+            $res1->Close();
             
             // load each one of the categories and update them
             $res2 = $this->db->Execute( $query2 );
@@ -1824,6 +1845,7 @@
                 else
                     $numUpdated++;
             }
+            $res2->Close();
             
             $this->message .= "{$numUpdated} links categories updated<br/>";
             return true;
@@ -1844,6 +1866,7 @@
             while( $row = $res1->FetchRow()) {
                 $commentBlogIds[$row["comment_id"]] = $row["blog_id"];
             }
+            $res1->Close();
             
             // now process all the comments
             $query2 = "SELECT id FROM ".$this->dbPrefix."articles_comments";
@@ -1866,6 +1889,7 @@
                 else
                     $numUpdated++;
             }
+            $res2->Close();
             
             $this->message .= "{$numUpdated} comments updated.<br/>";
         	 
@@ -1889,6 +1913,7 @@
             while( $row = $res1->FetchRow()) {
                 $numResources[$row["album_id"]] = $row["total"];
             }
+            $res1->Close();
             
             $res2 = $this->db->Execute( $query2 );
             if( !$res2 ) {
@@ -1899,8 +1924,9 @@
             while( $row = $res2->FetchRow()) {
                 $numChildren[$row["parent_id"]] = $row["total"];
             }
-            
-            // now update all albums
+            $res2->Close();
+
+                // now update all albums
             $query3 = "SELECT id FROM ".$this->dbPrefix."gallery_albums";
             $res3 = $this->db->Execute( $query3 );
             if( !$res3 ) {
@@ -1924,6 +1950,7 @@
                 else
                     $numUpdated++;
             }
+            $res3->Close();
              
             $this->message .= "{$numUpdated} gallery albums updated successfully<br/>";
             



More information about the pLog-svn mailing list