mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
Merge pull request #2637 from Nicofuma/ticket/12387
[ticket/12387] Cleanup *_free_result call and remove @ on that call * Nicofuma/ticket/12387: [ticket/12387] Fix a call to sql_freeresult in full_text_native [ticket/12387] Fix \phpbb\db\driver\mysqli::sql_freeresult [ticket/12387] Use the hash as query_id for caching [ticket/12387] Remove unnecessary checks [ticket/12387] mssql_query return true if a select query returns 0 row [ticket/12387] Cleanup *_free_result call and remove @ on that call
This commit is contained in:
@@ -75,9 +75,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']));
|
||||
}
|
||||
@@ -85,7 +86,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))
|
||||
@@ -120,9 +120,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'];
|
||||
|
||||
@@ -131,7 +132,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;
|
||||
@@ -203,6 +203,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
@@ -246,9 +251,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;
|
||||
}
|
||||
|
||||
@@ -272,7 +277,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +305,17 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
return @mysqli_free_result($query_id);
|
||||
if (!$query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($query_id === true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return mysqli_free_result($query_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,12 +414,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)
|
||||
{
|
||||
@@ -419,7 +434,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']))
|
||||
@@ -437,8 +452,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)
|
||||
{
|
||||
@@ -456,14 +471,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];
|
||||
|
Reference in New Issue
Block a user