Db: fetch less binary data
This commit is contained in:
parent
b65c9f4d4a
commit
eecb3cddf0
|
@ -60,7 +60,7 @@ $url = $this->url()->without('checksum')->without('show');
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= $this->translate('Checksum') ?></th>
|
<th><?= $this->translate('Checksum') ?></th>
|
||||||
<td><?= bin2hex($this->entry->checksum) ?></td>
|
<td><?= $this->entry->checksum ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?php if (! empty($this->output)): ?>
|
<?php if (! empty($this->output)): ?>
|
||||||
|
|
|
@ -181,14 +181,19 @@ class Db extends DbConnection
|
||||||
|
|
||||||
public function fetchActivityLogEntryById($id)
|
public function fetchActivityLogEntryById($id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT * FROM director_activity_log WHERE id = ' . (int) $id;
|
$sql = 'SELECT id, object_type, object_name, action_name,'
|
||||||
|
. ' old_properties, new_properties, author, change_time,'
|
||||||
|
. ' %s AS checksum, %s AS parent_checksum'
|
||||||
|
. ' FROM director_activity_log WHERE id = %d';
|
||||||
|
|
||||||
$result = $this->db()->fetchRow($sql);
|
$sql = sprintf(
|
||||||
if (is_resource($result->checksum)) {
|
$sql,
|
||||||
$result->checksum = stream_get_contents($result->checksum);
|
$this->dbHexFunc('checksum'),
|
||||||
}
|
$this->dbHexFunc('parent_checksum'),
|
||||||
|
$id
|
||||||
|
);
|
||||||
|
|
||||||
return $result;
|
return $this->db()->fetchRow($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchActivityLogChecksumById($id, $binary = true)
|
public function fetchActivityLogChecksumById($id, $binary = true)
|
||||||
|
@ -222,31 +227,21 @@ class Db extends DbConnection
|
||||||
$checksum = new Zend_Db_Expr("\\x" . bin2hex($checksum));
|
$checksum = new Zend_Db_Expr("\\x" . bin2hex($checksum));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT * FROM director_activity_log WHERE checksum = ?';
|
$sql = 'SELECT id, object_type, object_name, action_name'
|
||||||
$ret = $this->db()->fetchRow($sql, $checksum);
|
. ' old_properties, new_properties, author, change_time'
|
||||||
|
. ' %s AS checksum, %s AS parent_checksum'
|
||||||
|
. ' FROM director_activity_log WHERE checksum = ?';
|
||||||
|
|
||||||
if (is_resource($ret->checksum)) {
|
return $this->db()->fetchRow($sql, $checksum);
|
||||||
$ret->checksum = stream_get_contents($ret->checksum);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_resource($ret->parent_checksum)) {
|
|
||||||
$ret->checksum = stream_get_contents($ret->parent_checksum);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastActivityChecksum()
|
public function getLastActivityChecksum()
|
||||||
{
|
{
|
||||||
if ($this->isPgsql()) {
|
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, "
|
||||||
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(ENCODE(checksum, 'hex')) AS checksum"
|
. $this->dbHexFunc('checksum')
|
||||||
. " FROM director_activity_log ORDER BY id DESC LIMIT 1) a"
|
. " AS checksum"
|
||||||
. " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
|
. " FROM director_activity_log ORDER BY id DESC LIMIT 1) a"
|
||||||
} else {
|
. " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
|
||||||
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(HEX(checksum)) AS checksum"
|
|
||||||
. " FROM director_activity_log ORDER BY id DESC LIMIT 1) a"
|
|
||||||
. " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->db()->fetchOne($select);
|
return $this->db()->fetchOne($select);
|
||||||
}
|
}
|
||||||
|
@ -670,6 +665,15 @@ class Db extends DbConnection
|
||||||
return $this->getDbType() === 'pgsql';
|
return $this->getDbType() === 'pgsql';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function dbHexFunc($column)
|
||||||
|
{
|
||||||
|
if ($this->isPgsql()) {
|
||||||
|
return sprintf("LOWER(ENCODE(%s, 'hex'))", $column);
|
||||||
|
} else {
|
||||||
|
return sprintf("LOWER(HEX(%s))", $column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getUncollectedDeployments()
|
public function getUncollectedDeployments()
|
||||||
{
|
{
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
|
|
Loading…
Reference in New Issue