Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix sqlite deleteRepository case - Use better error message and log S…
Browse files Browse the repository at this point in the history
…QL error. Fix #779
  • Loading branch information
cdujeu committed Dec 30, 2014
1 parent d6fb94f commit bf3c0a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Expand Up @@ -1516,7 +1516,7 @@ public function switchAction($action, $httpVars, $fileVars)
}
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
AJXP_XMLWriter::sendMessage(null, $mess[427]);
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.59"], null);
AJXP_XMLWriter::reloadDataNode();
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/action.share/class.ShareStore.php
Expand Up @@ -316,7 +316,7 @@ public function deleteShare($type, $element)
$this->testUserCanEditShare($repo->getOwner());
$res = ConfService::deleteRepository($element);
if ($res == -1) {
throw new Exception($mess["ajxp_conf.51"]);
throw new Exception($mess[427]);
}
if($this->sqlSupported){
if(isSet($share)){
Expand All @@ -339,7 +339,7 @@ public function deleteShare($type, $element)
$this->testUserCanEditShare($repo->getOwner());
$res = ConfService::deleteRepository($repoId);
if ($res == -1) {
throw new Exception($mess["ajxp_conf.51"]);
throw new Exception($mess[427]);
}
// Silently delete corresponding role if it exists
AuthService::deleteRole("AJXP_SHARED-".$repoId);
Expand Down
21 changes: 9 additions & 12 deletions core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -442,17 +442,19 @@ public function saveRepository($repositoryObject, $update = false)
public function deleteRepository($repositoryId)
{
try {
$result = dibi::query('DELETE FROM [ajxp_repo] WHERE [uuid] = %s', $repositoryId);
$result_opts = dibi::query('DELETE FROM [ajxp_repo_options] WHERE [uuid] = %s', $repositoryId);
$result_opts_rights = dibi::query('DELETE FROM [ajxp_user_rights] WHERE [repo_uuid] = %s',$repositoryId); //jcg
dibi::query('DELETE FROM [ajxp_repo] WHERE [uuid] = %s', $repositoryId);
dibi::query('DELETE FROM [ajxp_repo_options] WHERE [uuid] = %s', $repositoryId);
dibi::query('DELETE FROM [ajxp_user_rights] WHERE [repo_uuid] = %s',$repositoryId);

switch ($this->sqlDriver["driver"]) {
case "sqlite":
case "sqlite3":
case "postgre":
dibi::nativeQuery("SET bytea_output=escape");
$children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [searchable_repositories] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
break;
case "sqlite":
case "sqlite3":
$children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [searchable_repositories] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
break;
case "mysql":
$children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [serial_role] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
break;
Expand All @@ -467,15 +469,10 @@ public function deleteRepository($repositoryId)
}

} catch (DibiException $e) {
$this->logError(__FUNCTION__, $e->getMessage());
return -1;
}

// Deleting a non-existent repository also qualifies as an error jcg Call to a member function getAffectedRows() on a non-object
/*
if (false === $result->getAffectedRows()) {
return -1;
}
*/
return 1;
}

public function getUserChildren( $userId )
Expand Down

0 comments on commit bf3c0a5

Please sign in to comment.