[evolvis-commits] r15862: Improve error handling when deleting a project. =?UTF-8?Q?=E2=86=B5=20Remove=20now=20useles?==?UTF-8?Q?s=20stripslashes?=/ addslashes
mirabilos at evolvis.org
mirabilos at evolvis.org
Tue Mar 1 00:33:49 CET 2011
Author: mirabilos
Date: 2011-03-01 00:33:49 +0100 (Tue, 01 Mar 2011)
New Revision: 15862
Modified:
trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php
Log:
Improve error handling when deleting a project.
Remove now useless stripslashes/addslashes
Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php 2011-02-28 23:33:45 UTC (rev 15861)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php 2011-02-28 23:33:49 UTC (rev 15862)
@@ -1347,9 +1347,8 @@
return false;
}
$inserted = array();
- $tags_array = explode('[;,]', $tags);
+ $tags_array = preg_split('/[;,]/', $tags);
foreach ($tags_array as $tag) {
- $tag = stripslashes($tag);
$tag = preg_replace('/[\t\r\n]/', ' ', $tag);
// Allowed caracteres: [A-Z][a-z][0-9] -_&'#+.
if (preg_match('/[^[:alnum:]| |\-|_|\&|\'|#|\+|\.]/', $tag)) {
@@ -1358,7 +1357,6 @@
return false;
}
$tag = trim($tag);
- $tag = addslashes($tag);
if ($tag == '' || array_search($tag, $inserted) !== false) continue;
$sql='INSERT INTO project_tags (group_id,name) VALUES ($1, $2)';
$res=db_query_params($sql, array($this->getID(), $tag));
@@ -1438,7 +1436,6 @@
continue;
}
$f_arr[$i]->delete(1,1);
-//echo 'ForumFactory'.db_error();
}
//
// Delete Subprojects
@@ -1451,7 +1448,6 @@
continue;
}
$pg_arr[$i]->delete(1,1);
-//echo 'ProjectGroupFactory'.db_error();
}
//
// Delete FRS Packages
@@ -1475,6 +1471,12 @@
$news_group=&group_get_object(forge_get_config('news_group'));
$res = db_query_params ('SELECT forum_id FROM news_bytes WHERE group_id=$1',
array ($this->getID())) ;
+ if (!$res) {
+ $this->setError(_('Error Deleting News: ').db_error());
+ db_rollback();
+ return false;
+ }
+
for ($i=0; $i<db_numrows($res); $i++) {
$Forum = new Forum($news_group,db_result($res,$i,'forum_id'));
if (!$Forum->delete(1,1)) {
@@ -1483,40 +1485,74 @@
}
$res = db_query_params ('DELETE FROM news_bytes WHERE group_id=$1',
array ($this->getID())) ;
+ if (!$res) {
+ $this->setError(_('Error Deleting News: ').db_error());
+ db_rollback();
+ return false;
+ }
//
// Delete docs
//
$res = db_query_params ('DELETE FROM doc_data WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'doc_data'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Documents: ').db_error());
+ db_rollback();
+ return false;
+ }
+
$res = db_query_params ('DELETE FROM doc_groups WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'doc_groups'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Documents: ').db_error());
+ db_rollback();
+ return false;
+ }
//
// Delete Tags
//
$res=db_query_params('DELETE FROM project_tags WHERE group_id=$1', array($this->getID()));
+ if (!$res) {
+ $this->setError(_('Error Deleting Tags: ').db_error());
+ db_rollback();
+ return false;
+ }
//
// Delete group history
//
$res = db_query_params ('DELETE FROM group_history WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'group_history'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Project History: ').db_error());
+ db_rollback();
+ return false;
+ }
+
//
// Delete group plugins
//
$res = db_query_params ('DELETE FROM group_plugin WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'group_plugin'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Project Plugins: ').db_error());
+ db_rollback();
+ return false;
+ }
+
//
// Delete group cvs stats
//
$res = db_query_params ('DELETE FROM stats_cvs_group WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'stats_cvs_group'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting SCM Statistics: ').db_error());
+ db_rollback();
+ return false;
+ }
+
//
// Delete Surveys
//
@@ -1528,7 +1564,6 @@
continue;
}
$s_arr[$i]->delete();
-//echo 'SurveyFactory'.db_error();
}
//
// Delete SurveyQuestions
@@ -1541,7 +1576,6 @@
continue;
}
$sq_arr[$i]->delete();
-//echo 'SurveyQuestionFactory'.db_error();
}
//
// Delete Mailing List Factory
@@ -1556,29 +1590,55 @@
if (!$ml_arr[$i]->delete(1,1)) {
$this->setError(_('Could not properly delete the mailing list'));
}
-//echo 'MailingListFactory'.db_error();
}
//
// Delete trove
//
$res = db_query_params ('DELETE FROM trove_group_link WHERE group_id=$1',
array ($this->getID())) ;
+ if (!$res) {
+ $this->setError(_('Error Deleting Trove: ').db_error());
+ db_rollback();
+ return false;
+ }
+
$res = db_query_params ('DELETE FROM trove_agg WHERE group_id=$1',
array ($this->getID())) ;
+ if (!$res) {
+ $this->setError(_('Error Deleting Trove: ').db_error());
+ db_rollback();
+ return false;
+ }
+
//
// Delete counters
//
$res = db_query_params ('DELETE FROM project_sums_agg WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'project_sums_agg'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Counters: ').db_error());
+ db_rollback();
+ return false;
+ }
+
$res = db_query_params ('INSERT INTO deleted_groups (unix_group_name,delete_date,isdeleted) VALUES ($1, $2, $3)',
array ($this->getUnixName(),
time(),
0)) ;
-//echo 'InsertIntoDeleteQueue'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Project: ').db_error());
+ db_rollback();
+ return false;
+ }
+
$res = db_query_params ('DELETE FROM groups WHERE group_id=$1',
array ($this->getID())) ;
-//echo 'DeleteGroup'.db_error();
+ if (!$res) {
+ $this->setError(_('Error Deleting Project: ').db_error());
+ db_rollback();
+ return false;
+ }
+
db_commit();
if (!$res) {
return false;
@@ -2030,7 +2090,7 @@
for ($i=0; $i<$rows; $i++) {
- $member =& user_get_object(db_result($member_res,$i,'user_id'));
+ $member = user_get_object(db_result($member_res,$i,'user_id'));
$roleId = db_result($member_res,$i,'role_id');
if (!$member || !is_object($member)) {
More information about the evolvis-commits
mailing list