From 36071ded9d37f38d446d17013b90dff9da94245b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 31 May 2014 12:56:44 +0200 Subject: [ticket/12639] Delete entry in admin-log leads to mysql-error PHPBB3-12639 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log/log.php') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 453cb740bb..6217a7fe46 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -393,14 +393,14 @@ class log implements \phpbb\log\log_interface $sql_where = 'WHERE log_type = ' . $log_type; foreach ($conditions as $field => $field_value) { - $sql_where .= ' AND '; - if ($field == 'keywords') { $sql_where .= $this->generate_sql_keyword($field_value, '', ''); } else { + $sql_where .= ' AND '; + if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) { $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; -- cgit v1.2.1 From 9c497a7b462a24b980912af669a44bfb82f5bdc2 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 31 May 2014 13:34:04 +0200 Subject: [ticket/12639] Add a test case with an empty keywords list PHPBB3-12639 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log/log.php') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 6217a7fe46..0dce9306df 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -395,7 +395,7 @@ class log implements \phpbb\log\log_interface { if ($field == 'keywords') { - $sql_where .= $this->generate_sql_keyword($field_value, '', ''); + $sql_where .= $this->generate_sql_keyword($field_value, '', ' AND'); } else { -- cgit v1.2.1 From f980fed5d26e2a7d2e1c139da7e1d8be7c1523e3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 2 Jun 2014 23:35:35 +0200 Subject: [ticket/12639] Handle $conditions['keywords'] outside of the loop PHPBB3-12639 --- phpBB/phpbb/log/log.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'phpBB/phpbb/log/log.php') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0dce9306df..d2c946d28b 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -391,28 +391,29 @@ class log implements \phpbb\log\log_interface } $sql_where = 'WHERE log_type = ' . $log_type; + + if (isset($conditions['keywords'])) + { + $sql_where .= $this->generate_sql_keyword($conditions['keywords'], '', ' AND'); + + unset($conditions['keywords']); + } + foreach ($conditions as $field => $field_value) { - if ($field == 'keywords') + $sql_where .= ' AND '; + + if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) + { + $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; + } + else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) { - $sql_where .= $this->generate_sql_keyword($field_value, '', ' AND'); + $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); } else { - $sql_where .= ' AND '; - - if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) - { - $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; - } - else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) - { - $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); - } - else - { - $sql_where .= $field . ' = ' . $field_value; - } + $sql_where .= $field . ' = ' . $field_value; } } -- cgit v1.2.1 From fb46e42ab3393f3899c0aa8b6b4482214ec1d275 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 20:22:22 +0200 Subject: [ticket/12639] Add a space in the code generated by generate_sql_keyword() PHPBB3-12639 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log/log.php') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index d2c946d28b..10efe5fd1c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -394,7 +394,7 @@ class log implements \phpbb\log\log_interface if (isset($conditions['keywords'])) { - $sql_where .= $this->generate_sql_keyword($conditions['keywords'], '', ' AND'); + $sql_where .= $this->generate_sql_keyword($conditions['keywords'], ''); unset($conditions['keywords']); } @@ -782,7 +782,7 @@ class log implements \phpbb\log\log_interface } } - $sql_keywords = $statement_operator . ' ('; + $sql_keywords = ' ' . $statement_operator . ' ('; if (!empty($operations)) { $sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR '; -- cgit v1.2.1