diff options
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/attachment/delete.php | 56 | ||||
-rw-r--r-- | phpBB/phpbb/cron/task/core/prune_all_forums.php | 23 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php | 37 | ||||
-rw-r--r-- | phpBB/phpbb/event/md_exporter.php | 11 | ||||
-rw-r--r-- | phpBB/phpbb/install/helper/database.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/notification/manager.php | 31 | ||||
-rw-r--r-- | phpBB/phpbb/notification/method/board.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/request/request.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/request/type_cast_helper.php | 65 | ||||
-rw-r--r-- | phpBB/phpbb/request/type_cast_helper_interface.php | 14 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_sphinx.php | 6 |
11 files changed, 117 insertions, 132 deletions
diff --git a/phpBB/phpbb/attachment/delete.php b/phpBB/phpbb/attachment/delete.php index 922f24b5dc..3c98e21587 100644 --- a/phpBB/phpbb/attachment/delete.php +++ b/phpBB/phpbb/attachment/delete.php @@ -104,6 +104,8 @@ class delete $this->set_sql_constraints($mode); + $sql_id = $this->sql_id; + /** * Perform additional actions before collecting data for attachment(s) deletion * @@ -122,11 +124,21 @@ class delete ); extract($this->dispatcher->trigger_event('core.delete_attachments_collect_data_before', compact($vars))); + $this->sql_id = $sql_id; + unset($sql_id); + // Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled) $this->collect_attachment_info($resync); // Delete attachments from database - $this->delete_attachments_from_db(); + $this->delete_attachments_from_db($mode, $ids, $resync); + + $sql_id = $this->sql_id; + $post_ids = $this->post_ids; + $topic_ids = $this->topic_ids; + $message_ids = $this->message_ids; + $physical = $this->physical; + $num_deleted = $this->num_deleted; /** * Perform additional actions after attachment(s) deletion from the database @@ -156,13 +168,21 @@ class delete ); extract($this->dispatcher->trigger_event('core.delete_attachments_from_database_after', compact($vars))); + $this->sql_id = $sql_id; + $this->post_ids = $post_ids; + $this->topic_ids = $topic_ids; + $this->message_ids = $message_ids; + $this->physical = $physical; + $this->num_deleted = $num_deleted; + unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical, $num_deleted); + if (!$this->num_deleted) { return 0; } // Delete attachments from filesystem - $this->remove_from_filesystem(); + $this->remove_from_filesystem($mode, $ids, $resync); // If we do not resync, we do not need to adjust any message, post, topic or user entries if (!$resync) @@ -288,8 +308,14 @@ class delete /** * Delete attachments from database table */ - protected function delete_attachments_from_db() + protected function delete_attachments_from_db($mode, $ids, $resync) { + $sql_id = $this->sql_id; + $post_ids = $this->post_ids; + $topic_ids = $this->topic_ids; + $message_ids = $this->message_ids; + $physical = $this->physical; + /** * Perform additional actions before attachment(s) deletion * @@ -316,6 +342,13 @@ class delete ); extract($this->dispatcher->trigger_event('core.delete_attachments_before', compact($vars))); + $this->sql_id = $sql_id; + $this->post_ids = $post_ids; + $this->topic_ids = $topic_ids; + $this->message_ids = $message_ids; + $this->physical = $physical; + unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical); + // Delete attachments $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $this->db->sql_in_set($this->sql_id, $this->ids); @@ -329,7 +362,7 @@ class delete /** * Delete attachments from filesystem */ - protected function remove_from_filesystem() + protected function remove_from_filesystem($mode, $ids, $resync) { $space_removed = $files_removed = 0; @@ -348,6 +381,13 @@ class delete } } + $sql_id = $this->sql_id; + $post_ids = $this->post_ids; + $topic_ids = $this->topic_ids; + $message_ids = $this->message_ids; + $physical = $this->physical; + $num_deleted = $this->num_deleted; + /** * Perform additional actions after attachment(s) deletion from the filesystem * @@ -380,6 +420,14 @@ class delete ); extract($this->dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars))); + $this->sql_id = $sql_id; + $this->post_ids = $post_ids; + $this->topic_ids = $topic_ids; + $this->message_ids = $message_ids; + $this->physical = $physical; + $this->num_deleted = $num_deleted; + unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical, $num_deleted); + if ($space_removed || $files_removed) { $this->config->increment('upload_dir_size', $space_removed * (-1), false); diff --git a/phpBB/phpbb/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php index b47939ccbe..5005f5b894 100644 --- a/phpBB/phpbb/cron/task/core/prune_all_forums.php +++ b/phpBB/phpbb/cron/task/core/prune_all_forums.php @@ -55,21 +55,26 @@ class prune_all_forums extends \phpbb\cron\task\base include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext); } - $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq - FROM ' . FORUMS_TABLE . " - WHERE enable_prune = 1 - AND prune_next < " . time(); + $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, enable_shadow_prune, prune_shadow_days, prune_shadow_freq, prune_shadow_next, forum_flags, prune_freq + FROM ' . FORUMS_TABLE; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - if ($row['prune_days']) + if ($row['enable_prune'] && $row['prune_next'] < time()) { - auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']); - } + if ($row['prune_days']) + { + auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']); + } - if ($row['prune_viewed']) + if ($row['prune_viewed']) + { + auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']); + } + } + if ($row['enable_shadow_prune'] && $row['prune_shadow_next'] < time() && $row['prune_shadow_days']) { - auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']); + auto_prune($row['forum_id'], 'shadow', $row['forum_flags'], $row['prune_shadow_days'], $row['prune_shadow_freq']); } } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php b/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php new file mode 100644 index 0000000000..afcecf2ef0 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class forum_topics_per_page_type extends \phpbb\db\migration\migration +{ + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v323', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_topics_per_page' => array('USINT', 0), + ), + ), + ); + } + +} diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index bec91d04f4..085b20c234 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -439,16 +439,9 @@ class md_exporter $event_list = array(); $file_content = file_get_contents($this->path . $file); - $events = explode('<!-- EVENT ', $file_content); - // Remove the code before the first event - array_shift($events); - foreach ($events as $event) - { - $event = explode(' -->', $event, 2); - $event_list[] = array_shift($event); - } + preg_match_all('/(?:{%|<!--) EVENT (.*) (?:%}|-->)/U', $file_content, $event_list); - return $event_list; + return $event_list[1]; } /** diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 21af652f9d..fa5a10c6fc 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -76,7 +76,7 @@ class database 'LABEL' => 'Oracle', 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', - 'DELIM' => '/', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\oracle', 'AVAILABLE' => true, '2.0.x' => false, diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index ac6bb3c6da..52c650df5d 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -899,32 +899,19 @@ class manager */ public function get_notification_type_id($notification_type_name) { - $notification_type_ids = $this->cache->get('notification_type_ids'); - - $this->db->sql_transaction('begin'); - - if ($notification_type_ids === false) + $sql = 'SELECT notification_type_id, notification_type_name + FROM ' . $this->notification_types_table; + $result = $this->db->sql_query($sql, 604800); // cache for one week + while ($row = $this->db->sql_fetchrow($result)) { - $notification_type_ids = array(); - - $sql = 'SELECT notification_type_id, notification_type_name - FROM ' . $this->notification_types_table; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id']; - } - $this->db->sql_freeresult($result); - - $this->cache->put('notification_type_ids', $notification_type_ids); + $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id']; } + $this->db->sql_freeresult($result); if (!isset($notification_type_ids[$notification_type_name])) { if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name])) { - $this->db->sql_transaction('rollback'); - throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name)); } @@ -934,13 +921,13 @@ class manager )); $this->db->sql_query($sql); + // expose new notification type ID for this request $notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid(); - $this->cache->put('notification_type_ids', $notification_type_ids); + // destroy cache, we have a new addition which we have to to load next time + $this->cache->destroy('sql', $this->notification_types_table); } - $this->db->sql_transaction('commit'); - return $notification_type_ids[$notification_type_name]; } diff --git a/phpBB/phpbb/notification/method/board.php b/phpBB/phpbb/notification/method/board.php index 931b252daa..faa53576e0 100644 --- a/phpBB/phpbb/notification/method/board.php +++ b/phpBB/phpbb/notification/method/board.php @@ -394,6 +394,6 @@ class board extends \phpbb\notification\method\base WHERE notification_type_id = ' . (int) $notification_type_id; $this->db->sql_query($sql); - $this->cache->destroy('notification_type_ids'); + $this->cache->destroy('sql', $this->notification_types_table); } } diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php index 00be8fd381..a0267d1370 100644 --- a/phpBB/phpbb/request/request.php +++ b/phpBB/phpbb/request/request.php @@ -150,8 +150,6 @@ class request implements \phpbb\request\request_interface return; } - $this->type_cast_helper->add_magic_quotes($value); - // setting to null means unsetting if ($value === null) { diff --git a/phpBB/phpbb/request/type_cast_helper.php b/phpBB/phpbb/request/type_cast_helper.php index 96e66950ca..912494998d 100644 --- a/phpBB/phpbb/request/type_cast_helper.php +++ b/phpBB/phpbb/request/type_cast_helper.php @@ -18,69 +18,6 @@ namespace phpbb\request; */ class type_cast_helper implements \phpbb\request\type_cast_helper_interface { - - /** - * @var string Whether slashes need to be stripped from input - */ - protected $strip; - - /** - * Initialises the type cast helper class. - * All it does is find out whether magic quotes are turned on. - */ - public function __construct() - { - if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) - { - $this->strip = false; - } - else - { - $this->strip = (@get_magic_quotes_gpc()) ? true : false; - } - } - - /** - * Recursively applies addslashes to a variable. - * - * @param mixed &$var Variable passed by reference to which slashes will be added. - */ - public function addslashes_recursively(&$var) - { - if (is_string($var)) - { - $var = addslashes($var); - } - else if (is_array($var)) - { - $var_copy = $var; - $var = array(); - foreach ($var_copy as $key => $value) - { - if (is_string($key)) - { - $key = addslashes($key); - } - $var[$key] = $value; - - $this->addslashes_recursively($var[$key]); - } - } - } - - /** - * Recursively applies addslashes to a variable if magic quotes are turned on. - * - * @param mixed &$var Variable passed by reference to which slashes will be added. - */ - public function add_magic_quotes(&$var) - { - if ($this->strip) - { - $this->addslashes_recursively($var); - } - } - /** * Set variable $result to a particular type. * @@ -129,8 +66,6 @@ class type_cast_helper implements \phpbb\request\type_cast_helper_interface $result = preg_replace('/[\x80-\xFF]/', '?', $result); } } - - $result = ($this->strip) ? stripslashes($result) : $result; } } diff --git a/phpBB/phpbb/request/type_cast_helper_interface.php b/phpBB/phpbb/request/type_cast_helper_interface.php index 2cb28d021f..9671573bf1 100644 --- a/phpBB/phpbb/request/type_cast_helper_interface.php +++ b/phpBB/phpbb/request/type_cast_helper_interface.php @@ -19,20 +19,6 @@ namespace phpbb\request; interface type_cast_helper_interface { /** - * Recursively applies addslashes to a variable. - * - * @param mixed &$var Variable passed by reference to which slashes will be added. - */ - public function addslashes_recursively(&$var); - - /** - * Recursively applies addslashes to a variable if magic quotes are turned on. - * - * @param mixed &$var Variable passed by reference to which slashes will be added. - */ - public function add_magic_quotes(&$var); - - /** * Set variable $result to a particular type. * * @param mixed &$result The variable to fill diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index e2eeb5f7f3..2c2eb84dc7 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -292,7 +292,6 @@ class fulltext_sphinx AND p.post_id >= $start AND p.post_id <= $end'), array('sql_query_post', ''), array('sql_query_post_index', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = $maxid WHERE counter_id = 1'), - array('sql_query_info', 'SELECT * FROM ' . POSTS_TABLE . ' WHERE post_id = $id'), array('sql_attr_uint', 'forum_id'), array('sql_attr_uint', 'topic_id'), array('sql_attr_uint', 'poster_id'), @@ -333,7 +332,6 @@ class fulltext_sphinx array('morphology', 'none'), array('stopwords', ''), array('min_word_len', '2'), - array('charset_type', 'utf-8'), array('charset_table', 'U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF'), array('min_prefix_len', '0'), array('min_infix_len', '0'), @@ -346,14 +344,12 @@ class fulltext_sphinx array('mem_limit', $this->config['fulltext_sphinx_indexer_mem_limit'] . 'M'), ), 'searchd' => array( - array('compat_sphinxql_magics' , '0'), array('listen' , ($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost') . ':' . ($this->config['fulltext_sphinx_port'] ? $this->config['fulltext_sphinx_port'] : '9312')), array('log', $this->config['fulltext_sphinx_data_path'] . 'log/searchd.log'), array('query_log', $this->config['fulltext_sphinx_data_path'] . 'log/sphinx-query.log'), array('read_timeout', '5'), array('max_children', '30'), array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'), - array('max_matches', (string) SPHINX_MAX_MATCHES), array('binlog_path', $this->config['fulltext_sphinx_data_path']), ), ); @@ -648,7 +644,7 @@ class fulltext_sphinx $this->sphinx->SetFilter('deleted', array(0)); - $this->sphinx->SetLimits($start, (int) $per_page, SPHINX_MAX_MATCHES); + $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES); $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); // Could be connection to localhost:9312 failed (errno=111, |