Fix that pgsql privileges were tested in case of mysql

refs #7163
This commit is contained in:
Johannes Meyer 2014-11-04 15:51:11 +01:00
parent 69b38768cf
commit 0db658b7f3
1 changed files with 7 additions and 3 deletions

View File

@ -625,14 +625,18 @@ EOD;
array $context = null, array $context = null,
$username = null $username = null
) { ) {
$mysqlPrivileges = array_intersect($privileges, array_keys($this->mysqlGrantContexts));
list($_, $host) = explode('@', $this->query('select current_user()')->fetchColumn()); list($_, $host) = explode('@', $this->query('select current_user()')->fetchColumn());
$grantee = "'" . ($username === null ? $this->config['username'] : $username) . "'@'" . $host . "'"; $grantee = "'" . ($username === null ? $this->config['username'] : $username) . "'@'" . $host . "'";
$privilegeCondition = 'privilege_type IN (' . join(',', array_map(array($this, 'quote'), $privileges)) . ')'; $privilegeCondition = sprintf(
'privilege_type IN (%s)',
join(',', array_map(array($this, 'quote'), $mysqlPrivileges))
);
if (isset($this->config['dbname'])) { if (isset($this->config['dbname'])) {
$dbPrivileges = array(); $dbPrivileges = array();
$tablePrivileges = array(); $tablePrivileges = array();
foreach (array_intersect($privileges, array_keys($this->mysqlGrantContexts)) as $privilege) { foreach ($mysqlPrivileges as $privilege) {
if (false === empty($context) && $this->mysqlGrantContexts[$privilege] & static::TABLE_LEVEL) { if (false === empty($context) && $this->mysqlGrantContexts[$privilege] & static::TABLE_LEVEL) {
$tablePrivileges[] = $privilege; $tablePrivileges[] = $privilege;
} elseif ($this->mysqlGrantContexts[$privilege] & static::DATABASE_LEVEL) { } elseif ($this->mysqlGrantContexts[$privilege] & static::DATABASE_LEVEL) {
@ -681,7 +685,7 @@ EOD;
. ' AND ' . $privilegeCondition . ($requireGrants ? " AND is_grantable = 'YES'" : ''), . ' AND ' . $privilegeCondition . ($requireGrants ? " AND is_grantable = 'YES'" : ''),
array(':grantee' => $grantee) array(':grantee' => $grantee)
); );
return (int) $query->fetchObject()->matches === count($privileges); return (int) $query->fetchObject()->matches === count($mysqlPrivileges);
} }
/** /**