diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 961088a381..f88dbd480c 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -690,7 +690,29 @@ $sql = 'UPDATE ' . SOME_TABLE . '
$db->sql_query($sql);
-
The $db->sql_build_array()
function supports the following modes: INSERT
(example above), INSERT_SELECT
(building query for INSERT INTO table (...) SELECT value, column ...
statements), MULTI_INSERT
(for returning extended inserts), UPDATE
(example above) and SELECT
(for building WHERE statement [AND logic]).
+ The $db->sql_build_array()
function supports the following modes: INSERT
(example above), INSERT_SELECT
(building query for INSERT INTO table (...) SELECT value, column ...
statements), UPDATE
(example above) and SELECT
(for building WHERE statement [AND logic]).
+
+ sql_multi_insert():
+
+ If you want to insert multiple statements at once, please use the separate sql_multi_insert()
method. An example:
+
+
+$sql_ary = array();
+
+$sql_ary[] = array(
+ 'somedata' => $my_string_1,
+ 'otherdata' => $an_int_1,
+ 'moredata' => $another_int_1,
+);
+
+$sql_ary[] = array(
+ 'somedata' => $my_string_2,
+ 'otherdata' => $an_int_2,
+ 'moredata' => $another_int_2,
+);
+
+$db->sql_multi_insert(SOME_TABLE, $sql_ary);
+
sql_in_set():
@@ -2201,6 +2223,13 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
+
Revision 8596+
+
+
+ - Removed sql_build_array('MULTI_INSERT'... statements.
+ - Added sql_multi_insert() explanation.
+
+
Revision 1.31
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 4082edf24a..b88873df46 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -34,7 +34,7 @@ class dbal
var $query_hold = '';
var $html_hold = '';
var $sql_report = '';
-
+
var $persistency = false;
var $user = '';
var $server = '';
@@ -47,7 +47,7 @@ class dbal
var $sql_error_sql = '';
// Holding the error information - only populated if sql_error_triggered is set
var $sql_error_returned = array();
-
+
// Holding transaction count
var $transactions = 0;
@@ -146,7 +146,7 @@ class dbal
{
$this->sql_freeresult($query_id);
}
-
+
return $this->_sql_close();
}
@@ -188,7 +188,7 @@ class dbal
return $result;
}
-
+
return false;
}
@@ -303,7 +303,7 @@ class dbal
* Build sql statement from array for insert/update/select statements
*
* Idea for this from Ikonboard
- * Possible query values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT
+ * Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT
*
*/
function sql_build_array($query, $assoc_ary = false)
@@ -336,24 +336,7 @@ class dbal
}
else if ($query == 'MULTI_INSERT')
{
- $ary = array();
- foreach ($assoc_ary as $id => $sql_ary)
- {
- // If by accident the sql array is only one-dimensional we build a normal insert statement
- if (!is_array($sql_ary))
- {
- return $this->sql_build_array('INSERT', $assoc_ary);
- }
-
- $values = array();
- foreach ($sql_ary as $key => $var)
- {
- $values[] = $this->_sql_validate_value($var);
- }
- $ary[] = '(' . implode(', ', $values) . ')';
- }
-
- $query = ' (' . implode(', ', array_keys($assoc_ary[0])) . ') VALUES ' . implode(', ', $ary);
+ trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR);
}
else if ($query == 'UPDATE' || $query == 'SELECT')
{
@@ -438,7 +421,25 @@ class dbal
if ($this->multi_insert)
{
- $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('MULTI_INSERT', $sql_ary));
+ $ary = array();
+ foreach ($sql_ary as $id => $_sql_ary)
+ {
+ // If by accident the sql array is only one-dimensional we build a normal insert statement
+ if (!is_array($_sql_ary))
+ {
+ $query = $this->sql_build_array('INSERT', $sql_ary);
+ break;
+ }
+
+ $values = array();
+ foreach ($_sql_ary as $key => $var)
+ {
+ $values[] = $this->_sql_validate_value($var);
+ }
+ $ary[] = '(' . implode(', ', $values) . ')';
+ }
+
+ $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary));
}
else
{
@@ -703,7 +704,7 @@ class dbal
-
+
' . $this->html_hold . '
@@ -731,24 +732,24 @@ class dbal
case 'start':
$this->query_hold = $query;
$this->html_hold = '';
-
+
$this->_sql_report($mode, $query);
$this->curtime = explode(' ', microtime());
$this->curtime = $this->curtime[0] + $this->curtime[1];
break;
-
+
case 'add_select_row':
$html_table = func_get_arg(2);
$row = func_get_arg(3);
-
+
if (!$html_table && sizeof($row))
{
$html_table = true;
$this->html_hold .= '
';
-
+
foreach (array_keys($row) as $val)
{
$this->html_hold .= '' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . ' | ';
@@ -764,7 +765,7 @@ class dbal
$this->html_hold .= '' . (($val) ? $val : ' ') . ' | ';
}
$this->html_hold .= '
';
-
+
return $html_table;
break;
@@ -795,7 +796,7 @@ class dbal
break;
default:
-
+
$this->_sql_report($mode, $query);
break;
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php
index 801480df95..487384ff8a 100644
--- a/phpBB/includes/diff/diff.php
+++ b/phpBB/includes/diff/diff.php
@@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
}
/**
-* Code from pear.php.net, Text_Diff-0.2.1 (beta) package
+* Code from pear.php.net, Text_Diff-1.0.0 package
* http://pear.php.net/package/Text_Diff/
*
* Modified by phpBB Group to meet our coding standards
@@ -26,6 +26,9 @@ if (!defined('IN_PHPBB'))
* General API for generating and formatting diffs - the differences between
* two sequences of strings.
*
+* Copyright 2004 Geoffrey T. Dairiki
+* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
+*
* @package diff
* @author Geoffrey T. Dairiki
*/
@@ -45,7 +48,7 @@ class diff
*/
function __construct(&$from_content, &$to_content, $preserve_cr = true)
{
- $diff_engine = &new diff_engine();
+ $diff_engine = new diff_engine();
$this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr);
}
@@ -62,7 +65,7 @@ class diff
*
* Example:
*
- * $diff = &new diff($lines1, $lines2);
+ * $diff = new diff($lines1, $lines2);
* $rev = $diff->reverse();
*
*
@@ -285,7 +288,7 @@ class diff_op
var $orig;
var $final;
- function reverse()
+ function &reverse()
{
trigger_error('[diff] Abstract method', E_USER_ERROR);
}
@@ -413,7 +416,7 @@ class diff3 extends diff
*/
function diff3(&$orig, &$final1, &$final2)
{
- $diff_engine = &new diff_engine();
+ $diff_engine = new diff_engine();
$diff_1 = $diff_engine->diff($orig, $final1);
$diff_2 = $diff_engine->diff($orig, $final2);
@@ -548,7 +551,7 @@ class diff3 extends diff
function _diff3(&$edits1, &$edits2)
{
$edits = array();
- $bb = &new diff3_block_builder();
+ $bb = new diff3_block_builder();
$e1 = current($edits1);
$e2 = current($edits2);
@@ -565,7 +568,7 @@ class diff3 extends diff
}
$ncopy = min($e1->norig(), $e2->norig());
- $edits[] = &new diff3_op_copy(array_slice($e1->orig, 0, $ncopy));
+ $edits[] = new diff3_op_copy(array_slice($e1->orig, 0, $ncopy));
if ($e1->norig() > $ncopy)
{
@@ -759,7 +762,7 @@ class diff3_block_builder
}
else
{
- $edit = &new diff3_op($this->orig, $this->final1, $this->final2);
+ $edit = new diff3_op($this->orig, $this->final1, $this->final2);
$this->_init();
return $edit;
}
diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php
index 576839ea60..ebf1469d67 100644
--- a/phpBB/includes/diff/engine.php
+++ b/phpBB/includes/diff/engine.php
@@ -17,21 +17,20 @@ if (!defined('IN_PHPBB'))
}
/**
-* Code from pear.php.net, Text_Diff-0.2.1 (beta) package
-* http://pear.php.net/package/Text_Diff/
+* Code from pear.php.net, Text_Diff-1.0.0 package
+* http://pear.php.net/package/Text_Diff/ (native engine)
*
* Modified by phpBB Group to meet our coding standards
* and being able to integrate into phpBB
*
-* Class used internally by Diff to actually compute the diffs. This class is
-* implemented using native PHP code.
+* Class used internally by Text_Diff to actually compute the diffs. This
+* class is implemented using native PHP code.
*
* The algorithm used here is mostly lifted from the perl module
* Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
* http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip
*
-* More ideas are taken from:
-* http://www.ics.uci.edu/~eppstein/161/960229.html
+* More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html
*
* Some ideas (and a bit of code) are taken from analyze.c, of GNU
* diffutils-2.7, which can be found at:
@@ -41,6 +40,8 @@ if (!defined('IN_PHPBB'))
* Geoffrey T. Dairiki . The original PHP version of this
* code was written by him, and is used/adapted with his permission.
*
+* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
+*
* @author Geoffrey T. Dairiki
* @package diff
*
@@ -251,7 +252,7 @@ class diff_engine
}
}
- $x1 = $xoff + (int)(($numer + ($xlim-$xoff)*$chunk) / $nchunks);
+ $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
for (; $x < $x1; $x++)
{
@@ -262,7 +263,8 @@ class diff_engine
}
$matches = $ymatches[$line];
- foreach ($matches as $y)
+ reset($matches);
+ while (list(, $y) = each($matches))
{
if (empty($this->in_seq[$y]))
{
@@ -273,7 +275,7 @@ class diff_engine
}
// no reset() here
- while (list($junk, $y) = each($matches))
+ while (list(, $y) = each($matches))
{
if ($y > $this->seq[$k - 1])
{
diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php
index 7d5cd9e5d3..1fc5320db9 100644
--- a/phpBB/includes/diff/renderer.php
+++ b/phpBB/includes/diff/renderer.php
@@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
}
/**
-* Code from pear.php.net, Text_Diff-0.2.1 (beta) package
+* Code from pear.php.net, Text_Diff-1.0.0 package
* http://pear.php.net/package/Text_Diff/
*
* Modified by phpBB Group to meet our coding standards
@@ -28,6 +28,8 @@ if (!defined('IN_PHPBB'))
* This class renders the diff in classic diff format. It is intended that
* this class be customized via inheritance, to obtain fancier outputs.
*
+* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
+*
* @package diff
*/
class diff_renderer
@@ -105,7 +107,7 @@ class diff_renderer
unset($diff3);
- $diff = &new diff($diff_1, $diff_2);
+ $diff = new diff($diff_1, $diff_2);
}
$nlead = $this->_leading_context_lines;
@@ -116,19 +118,24 @@ class diff_renderer
foreach ($diffs as $i => $edit)
{
+ // If these are unchanged (copied) lines, and we want to keep leading or trailing context lines, extract them from the copy block.
if (is_a($edit, 'diff_op_copy'))
{
+ // Do we have any diff blocks yet?
if (is_array($block))
{
+ // How many lines to keep as context from the copy block.
$keep = ($i == sizeof($diffs) - 1) ? $ntrail : $nlead + $ntrail;
if (sizeof($edit->orig) <= $keep)
{
+ // We have less lines in the block than we want for context => keep the whole block.
$block[] = $edit;
}
else
{
if ($ntrail)
{
+ // Create a new block with as many lines as we need for the trailing context.
$context = array_slice($edit->orig, 0, $ntrail);
$block[] = &new diff_op_copy($context);
}
@@ -137,12 +144,15 @@ class diff_renderer
$block = false;
}
}
+ // Keep the copy block as the context for the next block.
$context = $edit->orig;
}
else
{
+ // Don't we have any diff blocks yet?
if (!is_array($block))
{
+ // Extract context lines from the preceding copy block.
$context = array_slice($context, sizeof($context) - $nlead);
$x0 = $xi - sizeof($context);
$y0 = $yi - sizeof($context);
@@ -219,6 +229,16 @@ class diff_renderer
$ybeg .= ',' . ($ybeg + $ylen - 1);
}
+ // this matches the GNU Diff behaviour
+ if ($xlen && !$ylen)
+ {
+ $ybeg--;
+ }
+ else if (!$xlen)
+ {
+ $xbeg--;
+ }
+
return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
}
@@ -449,11 +469,11 @@ class diff_renderer_inline extends diff_renderer
$splitted_text_1 = $this->_split_on_words($text1, $nl);
$splitted_text_2 = $this->_split_on_words($text2, $nl);
- $diff = &new diff($splitted_text_1, $splitted_text_2);
+ $diff = new diff($splitted_text_1, $splitted_text_2);
unset($splitted_text_1, $splitted_text_2);
// Get the diff in inline format.
- $renderer = &new diff_renderer_inline(array_merge($this->get_params(), array('split_level' => 'words')));
+ $renderer = new diff_renderer_inline(array_merge($this->get_params(), array('split_level' => 'words')));
// Run the diff and get the output.
return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index ed448ed5f7..ee39bde5dd 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -356,6 +356,11 @@ function phpbb_hash($password)
/**
* Check for correct password
+*
+* @param string $password The password in plain text
+* @param string $hash The stored password hash
+*
+* @return bool Returns true if the password is correct, false if not.
*/
function phpbb_check_hash($password, $hash)
{
diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php
index 310b061b90..3af7881043 100644
--- a/phpBB/includes/functions_jabber.php
+++ b/phpBB/includes/functions_jabber.php
@@ -399,13 +399,11 @@ class jabber
$second_time = isset($this->session['id']);
$this->session['id'] = $xml['stream:stream'][0]['@']['id'];
- /** Currently commented out due to problems with some jabber server - reason unknown
if ($second_time)
{
// If we are here for the second time after TLS, we need to continue logging in
- $this->login();
- return;
- }*/
+ return $this->login();
+ }
// go on with authentication?
if (isset($this->features['stream:features'][0]['#']['bind']) || !empty($this->session['tls']))
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index e59ecca30a..d4b966c1df 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -1432,7 +1432,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
}
- $sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
+ $sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 14c21714d5..4fac6ddd68 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -1837,7 +1837,7 @@ class user extends session
if ((@include $language_filename) === false)
{
- trigger_error('Language file ' . basename($language_filename) . ' couldn\'t be opened.', E_USER_ERROR);
+ trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR);
}
}
else if ($use_db)
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 8c4ddb1505..b7139bd724 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -176,6 +176,7 @@ $sql_array = array(
'FROM' => array(
FORUMS_TABLE => 'f',
+ TOPICS_TABLE => 't',
)
);
@@ -239,7 +240,6 @@ else
}
$sql_array['WHERE'] .= ')';
-$sql_array['FROM'][TOPICS_TABLE] = 't';
// Join to forum table on topic forum_id unless topic forum_id is zero
// whereupon we join on the forum_id passed as a parameter ... this