mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 06:18:52 +00:00
- fixed [code=php]
- optimized db/mysql.php a little bit git-svn-id: file:///svn/phpbb/trunk@5037 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1e334fca0e
commit
cf54570f6c
4 changed files with 32 additions and 26 deletions
|
@ -57,9 +57,9 @@ class sql_db
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->open_queries))
|
if (sizeof($this->open_queries))
|
||||||
{
|
{
|
||||||
foreach ($this->open_queries as $query_id)
|
foreach ($this->open_queries as $i_query_id => $query_id)
|
||||||
{
|
{
|
||||||
@mysql_free_result($query_id);
|
@mysql_free_result($query_id);
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,11 @@ class sql_db
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
// DEBUG
|
// EXPLAIN only in extra debug mode
|
||||||
$this->sql_report('start', $query);
|
if (defined('DEBUG_EXTRA'))
|
||||||
|
{
|
||||||
|
$this->sql_report('start', $query);
|
||||||
|
}
|
||||||
|
|
||||||
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
|
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
|
||||||
|
|
||||||
|
@ -125,22 +128,24 @@ class sql_db
|
||||||
$this->sql_error($query);
|
$this->sql_error($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
if (defined('DEBUG_EXTRA'))
|
||||||
$this->sql_report('stop', $query);
|
{
|
||||||
|
$this->sql_report('stop', $query);
|
||||||
|
}
|
||||||
|
|
||||||
if ($cache_ttl && method_exists($cache, 'sql_save'))
|
if ($cache_ttl && method_exists($cache, 'sql_save'))
|
||||||
{
|
{
|
||||||
|
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||||
$cache->sql_save($query, $this->query_result, $cache_ttl);
|
$cache->sql_save($query, $this->query_result, $cache_ttl);
|
||||||
// mysql_free_result happened within sql_save()
|
// mysql_free_result called within sql_save()
|
||||||
}
|
}
|
||||||
elseif (preg_match('/^SELECT/', $query))
|
else if (strpos($query, 'SELECT') !== false && $this->query_result)
|
||||||
{
|
{
|
||||||
$this->open_queries[] = $this->query_result;
|
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (defined('DEBUG_EXTRA'))
|
||||||
{
|
{
|
||||||
// DEBUG
|
|
||||||
$this->sql_report('fromcache', $query);
|
$this->sql_report('fromcache', $query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +263,9 @@ class sql_db
|
||||||
$query_id = $this->query_result;
|
$query_id = $this->query_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method_exists($cache, 'sql_fetchrow') && $cache->sql_exists($query_id))
|
// This method is called too often... do not waste memory by calling/checking unneeded things
|
||||||
|
// if (method_exists($cache, 'sql_fetchrow') && $cache->sql_exists($query_id))
|
||||||
|
if (isset($cache->sql_rowset[$query_id]))
|
||||||
{
|
{
|
||||||
return $cache->sql_fetchrow($query_id);
|
return $cache->sql_fetchrow($query_id);
|
||||||
}
|
}
|
||||||
|
@ -345,17 +352,13 @@ class sql_db
|
||||||
$query_id = $this->query_result;
|
$query_id = $this->query_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($query_id)
|
if (isset($this->open_queries[(int) $query_id]))
|
||||||
{
|
{
|
||||||
// If it is not found within the open queries, we try to free a cached result. ;)
|
unset($this->open_queries[(int) $query_id]);
|
||||||
if (!(array_search($query_id, $this->open_queries) > 0))
|
return @mysql_free_result($query_id);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unset($this->open_queries[array_search($query_id, $this->open_queries)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($query_id) ? @mysql_free_result($query_id) : false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sql_escape($msg)
|
function sql_escape($msg)
|
||||||
|
@ -367,8 +370,8 @@ class sql_db
|
||||||
{
|
{
|
||||||
if (!$this->return_on_error)
|
if (!$this->return_on_error)
|
||||||
{
|
{
|
||||||
$this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
|
$this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
|
||||||
$this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']);
|
$this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
|
||||||
|
|
||||||
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mysql_error() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
|
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mysql_error() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
|
||||||
|
|
||||||
|
@ -388,7 +391,6 @@ class sql_db
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
function sql_report($mode, $query = '')
|
function sql_report($mode, $query = '')
|
||||||
{
|
{
|
||||||
if (empty($_GET['explain']))
|
if (empty($_GET['explain']))
|
||||||
|
|
|
@ -1389,7 +1389,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
|
||||||
if (defined('DEBUG_EXTRA'))
|
if (defined('DEBUG_EXTRA'))
|
||||||
{
|
{
|
||||||
// Remove me
|
// Remove me
|
||||||
if (!strstr($errfile, '/cache/') && !strstr($errfile, 'mysql.php') && !strstr($errfile, 'template.php'))
|
if (!strstr($errfile, '/cache/') && !strstr($errfile, 'template.php'))
|
||||||
{
|
{
|
||||||
echo "<b>PHP Notice</b>: in file <b>$errfile</b> on line <b>$errline</b>: <b>$msg_text</b><br>";
|
echo "<b>PHP Notice</b>: in file <b>$errfile</b> on line <b>$errline</b>: <b>$msg_text</b><br>";
|
||||||
}
|
}
|
||||||
|
@ -1533,7 +1533,7 @@ function page_header($page_title = '')
|
||||||
$reading_sql
|
$reading_sql
|
||||||
AND u.user_id = s.session_user_id
|
AND u.user_id = s.session_user_id
|
||||||
ORDER BY u.username ASC, s.session_ip ASC";
|
ORDER BY u.username ASC, s.session_ip ASC";
|
||||||
$result = $db->sql_query($sql, false);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
@ -1579,6 +1579,7 @@ function page_header($page_title = '')
|
||||||
|
|
||||||
$prev_session_ip = $row['session_ip'];
|
$prev_session_ip = $row['session_ip'];
|
||||||
}
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (!$online_userlist)
|
if (!$online_userlist)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,7 +162,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||||
$forum_unread[$parent_id] = true;
|
$forum_unread[$parent_id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult();
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// Handle marking posts
|
// Handle marking posts
|
||||||
if ($mark_read == 'forums')
|
if ($mark_read == 'forums')
|
||||||
|
|
|
@ -234,6 +234,9 @@ class bbcode_firstpass extends bbcode
|
||||||
ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var));
|
ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Because highlight_string is specialcharing the text (but we already did this before), we have to reverse this in order to get correct results
|
||||||
|
$code = strtr($code, array_flip(get_html_translation_table(HTML_ENTITIES)));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
highlight_string($code);
|
highlight_string($code);
|
||||||
$code = ob_get_contents();
|
$code = ob_get_contents();
|
||||||
|
|
Loading…
Add table
Reference in a new issue