[pLog-svn] r3320 - in plog/trunk/class: config dao dao/customfields
dao/userdata gallery/dao
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Tue May 2 11:11:32 GMT 2006
Author: jondaley
Date: 2006-05-02 11:11:31 +0000 (Tue, 02 May 2006)
New Revision: 3320
Modified:
plog/trunk/class/config/configdbstorage.class.php
plog/trunk/class/dao/articles.class.php
plog/trunk/class/dao/customfields/customfieldsvalues.class.php
plog/trunk/class/dao/referers.class.php
plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
plog/trunk/class/dao/userdata/ploguserdataprovider.class.php
plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
plog/trunk/class/gallery/dao/galleryresourcequotas.class.php
plog/trunk/class/gallery/dao/galleryresources.class.php
Log:
more cleanup - I think I am now calling Close on every SELECT query.
Modified: plog/trunk/class/config/configdbstorage.class.php
===================================================================
--- plog/trunk/class/config/configdbstorage.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/config/configdbstorage.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -117,7 +117,8 @@
else
$this->_data[$key] = $value;
}
-
+ $result->Close();
+
return true;
}
@@ -196,7 +197,9 @@
if( !$result )
return false;
- if( $result->RowCount() > 0 )
+ $ret = ($result->RowCount() > 0);
+ $result->Close();
+ if(ret)
return true;
else
return false;
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/articles.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -121,8 +121,10 @@
if( $result == false )
return false;
- if ( $result->RecordCount() == 0)
+ if ( $result->RecordCount() == 0){
+ $result->Close();
return false;
+ }
$row = $result->FetchRow( $result );
$article = $this->mapRow( $row, $includeHiddenFields );
Modified: plog/trunk/class/dao/customfields/customfieldsvalues.class.php
===================================================================
--- plog/trunk/class/dao/customfields/customfieldsvalues.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/customfields/customfieldsvalues.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -59,7 +59,8 @@
$field = $this->mapRow( $row );
$fields[$field->getName()] = $field;
}
-
+ $result->Close();
+
return $fields;
}
Modified: plog/trunk/class/dao/referers.class.php
===================================================================
--- plog/trunk/class/dao/referers.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/referers.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -180,8 +180,10 @@
if( !$result )
return false;
- if( $result->RowCount() == 0 )
+ if( $result->RowCount() == 0 ){
+ $result->Close();
return false;
+ }
$row = $result->FetchRow();
$referrer = $this->_fillRefererInformation( $row );
Modified: plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -110,6 +110,7 @@
$usersBlogs[] = $blogs->mapRow( $row );
$ids[] = $row["id"];
}
+ $result->Close();
// and now check to which other blogs he or she belongs
$otherBlogs = "SELECT b.* FROM {$prefix}blogs b, {$prefix}users_permissions p
@@ -127,6 +128,7 @@
while( $row = $result->FetchRow($result)) {
$usersBlogs[] = $blogs->mapRow( $row );
}
+ $result->Close();
sort($usersBlogs);
Modified: plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -53,10 +53,10 @@
if( !$result )
return false;
- if( $result == false )
- return false;
+ $ret = ($result->RecordCount() == 1);
+ $result->Close();
- if( $result->RecordCount() == 1 )
+ if($ret)
return true;
else
return false;
@@ -80,7 +80,8 @@
return false;
$row = $result->FetchRow();
-
+ $result->Close();
+
return( $this->_mapUserInfoObject( $row ));
}
@@ -99,10 +100,13 @@
if( !$result )
return false;
- if( $result->RowCount() == 0 )
+ if( $result->RowCount() == 0 ){
+ $result->Close();
return false;
+ }
$row = $result->FetchRow();
+ $result->Close();
return( $this->_mapUserInfoObject( $row ));
}
@@ -127,6 +131,7 @@
return false;
$row = $result->FetchRow();
+ $result->Close();
// fetch the user permissions
//$perms = new UserPermissions();
@@ -233,6 +238,7 @@
while ($info = $result->FetchRow( $result ))
array_push( $users, $this->_mapUserInfoObject( $info ));
+ $result->Close();
return $users;
}
@@ -276,6 +282,7 @@
$result = $this->_dbc->Execute( $query );
$row = $result->FetchRow();
+ $result->Close();
return( $row["next_id"] );
}
@@ -366,10 +373,15 @@
if( !$result )
return false;
- if( $result->RowCount() == 0 )
- return false;
-
- return ($result->FetchRow());
+ if( $result->RowCount() == 0 ){
+ $result->Close();
+ return false;
+ }
+
+ $ret = $result->FetchRow();
+ $result->Close();
+
+ return $ret;
}
/**
@@ -401,6 +413,7 @@
return 0;
$row = $result->FetchRow();
+ $result->Close();
if( $row["total"] == "" )
$row["total"] = 0;
@@ -420,8 +433,9 @@
if( !$result )
return false;
-
- return( $result->RecordCount() > 0 );
+ $ret = ($result->RecordCount() > 0);
+ $result->Close();
+ return $ret;
}
}
?>
Modified: plog/trunk/class/dao/userdata/ploguserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/ploguserdataprovider.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/userdata/ploguserdataprovider.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -125,6 +125,7 @@
$this->_cache->setData( $user->getId(), CACHE_USERINFO, $user );
$this->_cache->setData( $user->getUsername(), CACHE_USERIDBYNAME, $user );
}
+ $result->Close();
return $users;
}
@@ -216,6 +217,7 @@
return false;
$row = $result->FetchRow();
+ $result->Close();
array_push( $users, $this->mapRow( $row ));
}
@@ -230,6 +232,7 @@
while( $row = $result2->FetchRow()) {
array_push( $users, $this->mapRow($row));
}
+ $result2->Close();
return $users;
}
@@ -278,7 +281,8 @@
while( $r_row = $r_result->FetchRow()) {
$galleryresources->deleteResource( $r_row["id"], $r_row["owner_id"] );
}
-
+ $r_result->Close();
+
// now delete album
$galleryalbums = new GalleryAlbums();
$al_query = "SELECT ga.id AS id, ga.owner_id as owner_id
@@ -292,7 +296,8 @@
while( $al_row = $al_result->FetchRow()) {
$galleryalbums->deleteAlbum( $al_row["id"], $al_row["owner_id"] );
}
-
+ $al_result->Close();
+
// check if the deleted user owns any blog, if they does, delete the blog
// the deleteBlog function will take care of deleting articles etc...
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
@@ -315,7 +320,8 @@
$filePath = $userfolder->getUserFolder( $b_row["id"] );
File::deleteDir( $filePath, true, false );
}
-
+ $b_result->Close();
+
// now we need to check if user belong to any other blog and have made any posts
// at the moment, we cannot dertermine which resource was posted by which user
// so when user is deleted, resource posted by him/her will stay intact in the blog
@@ -333,7 +339,8 @@
while( $a_row = $a_result->FetchRow()) {
$articles->deleteArticle( $a_row["id"], $a_row["user_id"], $a_row["blog_id"], true );
}
-
+ $a_result->Close();
+
// finally remove the user
$u_query = "SELECT * FROM ".$this->getPrefix()."users WHERE status = 2";
@@ -344,7 +351,8 @@
while( $u_row = $u_result->FetchRow()) {
$this->deleteUser( $u_row["id"] );
}
-
+ $u_result->Close();
+
return true;
}
@@ -382,10 +390,12 @@
$result = $this->Execute($query);
- if($result && $result->RecordCount() >= 1)
- return true;
- else
+ if(!$result)
return false;
+
+ $count = $result->RecordCount();
+ $result->Close();
+ return ($count >= 1);
}
/**
Modified: plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -70,7 +70,7 @@
}
// let's add the user to the lt userbase
elseif ( $result->RecordCount() == 1 ) {
-
+ $result->Close();
$pnUserdata = $this->getUserInfoFromPostNukeUser( $username );
$user = new UserInfo( $pnUserdata["pn_uname"],
@@ -94,7 +94,12 @@
$this->_PostNukeAddBlog($username, $newUserId);
return true;
- }
+ }
+ else{
+ // TODO: shouldn't ever happen?
+ $result->Close();
+ }
+
// return false if user authentication failed on both databases
return false;
@@ -116,7 +121,8 @@
return false;
$row = $result->FetchRow();
-
+ $result->Close();
+
return( $row );
}
@@ -235,6 +241,7 @@
$this->_cache->setData( $user->getId(), CACHE_USERINFO, $user );
$this->_cache->setData( $user->getUsername(), CACHE_USERIDBYNAME, $user );
}
+ $result->Close();
return $users;
}
@@ -326,6 +333,7 @@
return false;
$row = $result->FetchRow();
+ $result->Close();
array_push( $users, $this->mapRow( $row ));
}
@@ -340,6 +348,7 @@
while( $row = $result2->FetchRow()) {
array_push( $users, $this->mapRow($row));
}
+ $result2->Close();
return $users;
}
@@ -388,7 +397,8 @@
while( $r_row = $r_result->FetchRow()) {
$galleryresources->deleteResource( $r_row["id"], $r_row["owner_id"] );
}
-
+ $r_result->Close();
+
// now delete album
$galleryalbums = new GalleryAlbums();
$al_query = "SELECT ga.id AS id, ga.owner_id as owner_id
@@ -402,7 +412,8 @@
while( $al_row = $al_result->FetchRow()) {
$galleryalbums->deleteAlbum( $al_row["id"], $al_row["owner_id"] );
}
-
+ $al_result->Close();
+
// check if the deleted user owns any blog, if they does, delete the blog
// the deleteBlog function will take care of deleting articles etc...
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
@@ -425,7 +436,8 @@
$filePath = $userfolder->getUserFolder( $b_row["id"] );
File::deleteDir( $filePath, true, false );
}
-
+ $b_result->Close();
+
// now we need to check if user belong to any other blog and have made any posts
// at the moment, we cannot dertermine which resource was posted by which user
// so when user is deleted, resource posted by him/her will stay intact in the blog
@@ -443,7 +455,8 @@
while( $a_row = $a_result->FetchRow()) {
$articles->deleteArticle( $a_row["id"], $a_row["user_id"], $a_row["blog_id"], true );
}
-
+ $a_result->Close();
+
// finally remove the user
$u_query = "SELECT * FROM ".$this->getPrefix()."users WHERE status = 2";
@@ -454,7 +467,8 @@
while( $u_row = $u_result->FetchRow()) {
$this->deleteUser( $u_row["id"] );
}
-
+ $u_result->Close();
+
return true;
}
@@ -492,10 +506,13 @@
$result = $this->Execute($query);
- if($result && $result->RecordCount() >= 1)
- return true;
- else
+ if(!$result)
return false;
+
+ $count = $result->RecordCount();
+ $result->Close();
+
+ return ($count >= 1);
}
/**
Modified: plog/trunk/class/gallery/dao/galleryresourcequotas.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresourcequotas.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/gallery/dao/galleryresourcequotas.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -52,6 +52,7 @@
if( !$result )
return 0;
$row = $result->FetchRow();
+ $result->Close();
if( isset( $row["total_size"] ))
$quota = $row["total_size"];
else
Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php 2006-05-02 10:38:30 UTC (rev 3319)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php 2006-05-02 11:11:31 UTC (rev 3320)
@@ -115,10 +115,13 @@
if( !$result )
return false;
- if( $result->RecordCount() == 0 )
+ if( $result->RecordCount() == 0 ){
+ $result->Close();
return false;
+ }
$row = $result->FetchRow();
+ $result->Close();
$resource = $this->mapRow( $row );
$this->_cache->setData( $resource->getId(), CACHE_RESOURCES, $resource );
@@ -152,11 +155,14 @@
if( !$result )
return false;
- if( $result->RecordCount() == 0 )
+ if( $result->RecordCount() == 0 ){
+ $result->Close();
return false;
+ }
$row = $result->FetchRow();
- $resource = $this->mapRow( $row );
+ $result->Close();
+ $resource = $this->mapRow( $row );
$this->_cache->setData( $resource->getId(), CACHE_RESOURCES, $resource );
$this->_cache->setData( $resource->getFileName(), CACHE_RESOURCES_BY_NAME, $resource );
@@ -778,6 +784,7 @@
$result = $this->Execute( $query );
$row = $result->FetchRow();
+ $result->Close();
if( $row["total"] == 0 || $row["total"] == 1 )
return false;
else
More information about the pLog-svn
mailing list