1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 15:01:33 +02:00

[ticket/12387] Cleanup *_free_result call and remove @ on that call

PHPBB3-12387
This commit is contained in:
Tristan Darricau
2014-06-22 18:08:38 +02:00
parent afe9d3c3f3
commit 2276c1c0f2
10 changed files with 231 additions and 137 deletions

View File

@@ -71,9 +71,10 @@ class mysqli extends \phpbb\db\driver\mysql_base
if (version_compare($this->sql_server_info(true), '5.0.2', '>='))
{
$result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode');
if ($result !== null)
if ($result)
{
$row = @mysqli_fetch_assoc($result);
$row = mysqli_fetch_assoc($result);
mysqli_free_result($result);
$modes = array_map('trim', explode(',', $row['sql_mode']));
}
@@ -81,7 +82,6 @@ class mysqli extends \phpbb\db\driver\mysql_base
{
$modes = array();
}
@mysqli_free_result($result);
// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
if (!in_array('TRADITIONAL', $modes))
@@ -116,9 +116,10 @@ class mysqli extends \phpbb\db\driver\mysql_base
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)
{
$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version');
if ($result !== null)
if ($result)
{
$row = @mysqli_fetch_assoc($result);
$row = mysqli_fetch_assoc($result);
mysqli_free_result($result);
$this->sql_server_version = $row['version'];
@@ -127,7 +128,6 @@ class mysqli extends \phpbb\db\driver\mysql_base
$cache->put('mysqli_version', $this->sql_server_version);
}
}
@mysqli_free_result($result);
}
return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
@@ -191,6 +191,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
$this->sql_report('stop', $query);
}
if (!$this->query_result)
{
return false;
}
if ($cache && $cache_ttl)
{
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
@@ -234,9 +239,9 @@ class mysqli extends \phpbb\db\driver\mysql_base
return $cache->sql_fetchrow($query_id);
}
if ($query_id !== false && $query_id !== null)
if ($query_id)
{
$result = @mysqli_fetch_assoc($query_id);
$result = mysqli_fetch_assoc($query_id);
return $result !== null ? $result : false;
}
@@ -260,7 +265,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
return $cache->sql_rowseek($rownum, $query_id);
}
return ($query_id !== false) ? @mysqli_data_seek($query_id, $rownum) : false;
return ($query_id) ? @mysqli_data_seek($query_id, $rownum) : false;
}
/**
@@ -288,7 +293,12 @@ class mysqli extends \phpbb\db\driver\mysql_base
return $cache->sql_freeresult($query_id);
}
return @mysqli_free_result($query_id);
if (!$this->query_result)
{
return false;
}
return mysqli_free_result($query_id);
}
/**
@@ -387,12 +397,12 @@ class mysqli extends \phpbb\db\driver\mysql_base
if ($result = @mysqli_query($this->db_connect_id, "EXPLAIN $explain_query"))
{
while ($row = @mysqli_fetch_assoc($result))
while ($row = mysqli_fetch_assoc($result))
{
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
}
mysqli_free_result($result);
}
@mysqli_free_result($result);
if ($html_table)
{
@@ -407,7 +417,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
if ($result = @mysqli_query($this->db_connect_id, 'SHOW PROFILE ALL;'))
{
$this->html_hold .= '<br />';
while ($row = @mysqli_fetch_assoc($result))
while ($row = mysqli_fetch_assoc($result))
{
// make <unknown> HTML safe
if (!empty($row['Source_function']))
@@ -425,8 +435,8 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
}
mysqli_free_result($result);
}
@mysqli_free_result($result);
if ($html_table)
{
@@ -444,14 +454,14 @@ class mysqli extends \phpbb\db\driver\mysql_base
$endtime = $endtime[0] + $endtime[1];
$result = @mysqli_query($this->db_connect_id, $query);
if ($result !== null)
if ($result)
{
while ($void = @mysqli_fetch_assoc($result))
while ($void = mysqli_fetch_assoc($result))
{
// Take the time spent on parsing rows into account
}
mysqli_free_result($result);
}
@mysqli_free_result($result);
$splittime = explode(' ', microtime());
$splittime = $splittime[0] + $splittime[1];