[geeklog-cvs] geeklog: Check if table is in $_TABLES array during plugin unins...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Jun 1 10:19:18 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/b041ebd68789
changeset: 7077:b041ebd68789
user:      Dirk Haun <dirk at haun-online.de>
date:      Mon Jun 01 15:58:59 2009 +0200
description:
Check if table is in $_TABLES array during plugin uninstall

diffstat:

 system/lib-plugins.php |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (56 lines):

diff -r 513cf4019e90 -r b041ebd68789 system/lib-plugins.php
--- a/system/lib-plugins.php	Mon Jun 01 15:14:41 2009 +0200
+++ b/system/lib-plugins.php	Mon Jun 01 15:58:59 2009 +0200
@@ -242,21 +242,26 @@
         }
 
         // removing tables
-        for ($i=0; $i < count($remvars['tables']); $i++) {
-            COM_errorLog ("Dropping table {$_TABLES[$remvars['tables'][$i]]}", 1);
-            DB_query ("DROP TABLE {$_TABLES[$remvars['tables'][$i]]}", 1    );
-            COM_errorLog ('...success', 1);
+        $num_tables = count($remvars['tables']);
+        for ($i = 0; $i < $num_tables; $i++) {
+            if (isset($_TABLES[$remvars['tables'][$i]])) {
+                COM_errorLog("Dropping table {$_TABLES[$remvars['tables'][$i]]}", 1);
+                DB_query("DROP TABLE {$_TABLES[$remvars['tables'][$i]]}", 1);
+                COM_errorLog('...success', 1);
+            }
         }
 
         // removing variables
-        for ($i = 0; $i < count($remvars['vars']); $i++) {
+        $num_vars = count($remvars['vars']);
+        for ($i = 0; $i < $num_vars; $i++) {
             COM_errorLog ("Removing variable {$remvars['vars'][$i]}", 1);
             DB_delete($_TABLES['vars'], 'name', $remvars['vars'][$i]);
             COM_errorLog ('...success', 1);
         }
 
         // removing groups
-        for ($i = 0; $i < count($remvars['groups']); $i++) {
+        $num_groups = count($remvars['groups']);
+        for ($i = 0; $i < $num_groups; $i++) {
             $grp_id = DB_getItem ($_TABLES['groups'], 'grp_id',
                                   "grp_name = '{$remvars['groups'][$i]}'");
             if (!empty($grp_id)) {
@@ -270,7 +275,8 @@
         }
 
         // removing features
-        for ($i = 0; $i < count($remvars['features']); $i++) {
+        $num_features = count($remvars['features']);
+        for ($i = 0; $i < $num_features; $i++) {
             $access_id = DB_getItem ($_TABLES['features'], 'ft_id',
                                     "ft_name = '{$remvars['features'][$i]}'");
             if (!empty($access_id)) {
@@ -314,7 +320,8 @@
         COM_errorLog ('...success', 1);
 
         // uninstall php-blocks
-        for ($i = 0; $i < count($remvars['php_blocks']); $i++) {
+        $num_blocks = count($remvars['php_blocks']);
+        for ($i = 0; $i < $num_blocks; $i++) {
             DB_delete($_TABLES['blocks'], array('type',     'phpblockfn'),
                                           array('phpblock', $remvars['php_blocks'][$i]));
         }



More information about the geeklog-cvs mailing list