8000 chg: [internal] Include SQL query in case of failed execution by JakubOnderka · Pull Request #10095 · MISP/MISP · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chg: [internal] Include SQL query in case of failed execution #10095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/Model/AppModel.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ public function __construct($id = false, $table = null, $ds = null)
}
}

public function isAcceptedDatabaseError($errorMessage)
/**
* @param string $errorMessage
* @return bool
*/
private function isAcceptedDatabaseError($errorMessage)
{
if ($this->isMysql()) {
$errorDuplicateColumn = 'SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name';
Expand Down
19 changes: 15 additions & 4 deletions app/Model/Datasource/Database/MysqlExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ class MysqlExtended extends Mysql
'text' => PDO::PARAM_STR
];

public function __construct($config = null, $autoConnect = true)
{
parent::__construct($config, $autoConnect);
// Enable full debug when benchmarking is enabled
if (Configure::read('Plugin.Benchmarking_enable')) {
$this->fullDebug = true;
}
}

/**
* Output SHA1 as binary, that is faster and uses less memory
* @param string $value
Expand Down Expand Up @@ -151,17 +160,19 @@ private function __buildIgnoreIndexHint($ignoreIndexHint = null): ?string
public function execute($sql, $options = [], $params = [])
{
$log = $options['log'] ?? $this->fullDebug;
if (Configure::read('Plugin.Benchmarking_enable')) {
$log = true;
}
if ($log) {
$t = microtime(true);
$this->_result = $this->_execute($sql, $params);
$this->took = round((microtime(true) - $t) * 1000);
$this->numRows = $this->affected = $this->lastAffected();
$this->logQuery($sql, $params);
} else {
$this->_result = $this->_execute($sql, $params);
try {
$this->_result = $this->_execute($sql, $params);
} catch (PDOException $e) {
// code must be zero as PDOException uses string error code that cannot be used in exception constructor
throw new PDOException($e->getMessage() . ' when executing SQL ' . $sql, 0, $e);
}
$this->_queriesCnt++;
}

Expand Down
1 change: 1 addition & 0 deletions app/Model/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ public function removeGalaxyClusterTags(array $user, array $data, $dataType = 'E
$conditions['GalaxyCluster.tag_name'] = $possibleGalaxyClusterTag;
$galaxyClusterTags = $this->GalaxyCluster->find('column', [
'conditions' => $conditions,
'contains' => ['Galaxy'],
'fields' => ['GalaxyCluster.tag_name'],
]);

Expand Down
0