diff options
38 files changed, 905 insertions, 570 deletions
diff --git a/.travis.yml b/.travis.yml index aea2b8ed0a..a246590bb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ before_script: script: - travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION - travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION + - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION ./ - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3.3' -a '$DB' = 'mysqli' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi" diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 044596073c..4f39e71c3c 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -879,6 +879,20 @@ ucp_agreement_terms_before * Since: 3.1.0-b3 * Purpose: Add content before the terms of agreement text at user registration +ucp_pm_viewmessage_avatar_after +=== +* Locations: + + styles/prosilver/template/ucp_pm_viewmessage.html +* Since: 3.1.0-RC3 +* Purpose: Add content right after the avatar when viewing a private message + +ucp_pm_viewmessage_avatar_before +=== +* Locations: + + styles/prosilver/template/ucp_pm_viewmessage.html +* Since: 3.1.0-RC3 +* Purpose: Add content right before the avatar when viewing a private message + ucp_pm_viewmessage_contact_fields_after === * Locations: @@ -1085,6 +1099,22 @@ viewtopic_print_head_append * Since: 3.1.0-a1 * Purpose: Add asset calls directly before the `</head>` tag of the Print Topic screen +viewtopic_body_avatar_after +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Since: 3.1.0-RC3 +* Purpose: Add content right after the avatar when viewing topics + +viewtopic_body_avatar_before +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Since: 3.1.0-RC3 +* Purpose: Add content right before the avatar when viewing topics + viewtopic_body_contact_fields_after === * Locations: diff --git a/phpBB/download/file.php b/phpBB/download/file.php index d4e0f04d2b..a521f413ed 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -11,10 +11,6 @@ * */ -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - /** * @ignore */ diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 7ff3212b72..905e981cdc 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -183,7 +183,10 @@ class auth_admin extends \phpbb\auth\auth } // Defining the user-function here to save some memory - $return_acl_fill = create_function('$value', 'return ' . $acl_fill . ';'); + $return_acl_fill = function () use ($acl_fill) + { + return $acl_fill; + }; // Actually fill the gaps if (sizeof($hold_ary)) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index ad5a359710..abf726581d 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -655,3 +655,30 @@ function validate_range($value_ary, &$error) } } } + +/** +* Inserts new config display_vars into an exisiting display_vars array +* at the given position. +* +* @param array $display_vars An array of existing config display vars +* @param array $add_config_vars An array of new config display vars +* @param array $where Where to place the new config vars, +* before or after an exisiting config, as an array +* of the form: array('after' => 'config_name') or +* array('before' => 'config_name'). +* @return array The array of config display vars +*/ +function phpbb_insert_config_array($display_vars, $add_config_vars, $where) +{ + if (is_array($where) && array_key_exists(current($where), $display_vars)) + { + $position = array_search(current($where), array_keys($display_vars)) + ((key($where) == 'before') ? 0 : 1); + $display_vars = array_merge( + array_slice($display_vars, 0, $position), + $add_config_vars, + array_slice($display_vars, $position) + ); + } + + return $display_vars; +} diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 397e6401ff..fe9bcdb9d1 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -489,6 +489,12 @@ class p_master $id = request_var('icat', ''); } + // Restore the backslashes in class names + if (strpos($id, '-') !== false) + { + $id = str_replace('-', '\\', $id); + } + if ($id && !is_numeric($id) && !$this->is_full_class($id)) { $id = $this->p_class . '_' . $id; @@ -616,7 +622,7 @@ class p_master } // Not being able to overwrite ;) - $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=' . $this->get_module_identifier($this->p_name, $this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } else { @@ -648,7 +654,7 @@ class p_master $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name']; } - $this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name, $this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } // Add url_extra parameter to u_action url @@ -901,7 +907,7 @@ class p_master else { // if the category has a name, then use it. - $u_title .= $this->get_module_identifier($item_ary['name'], $item_ary['id']); + $u_title .= $this->get_module_identifier($item_ary['name']); } // If the item is not a category append the mode if (!$item_ary['cat']) @@ -1106,26 +1112,24 @@ class p_master } /** - * If the basename contains a \ we dont use that for the URL. + * If the basename contains a \ we don't use that for the URL. * * Firefox is currently unable to correctly copy a urlencoded \ * so users will be unable to post links to modules. - * However we can still fallback to the id instead of the name, - * so we do that in this case. + * However we can replace them with dashes and re-replace them later * * @param string $basename Basename of the module - * @param int $id Id of the module - * @return mixed Identifier that should be used for + * @return string Identifier that should be used for * module link creation */ - protected function get_module_identifier($basename, $id) + protected function get_module_identifier($basename) { if (strpos($basename, '\\') === false) { return $basename; } - return $id; + return str_replace('\\', '-', $basename); } /** diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 98773d5b0e..b4ec0092e7 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -26,6 +26,7 @@ function mcp_front_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $module; + global $phpbb_dispatcher; // Latest 5 unapproved if ($module->loaded('queue')) @@ -80,6 +81,19 @@ function mcp_front_view($id, $mode, $action) } } + /** + * Alter list of posts and total as required + * + * @event core.mcp_front_view_queue_postid_list_after + * @var int total Number of unapproved posts + * @var array post_list List of unapproved posts + * @var array forum_list List of forums that contain the posts + * @var array forum_names Associative array with forum_id as key and it's corresponding forum_name as value + * @since 3.1.0-RC3 + */ + $vars = array('total', 'post_list', 'forum_list', 'forum_names'); + extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_queue_postid_list_after', compact($vars))); + if ($total) { $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 9f6125f256..92000c6ceb 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1114,6 +1114,7 @@ function mcp_fork_topic($topic_ids) $forum_id = request_var('f', 0); $redirect = request_var('redirect', build_url(array('action', 'quickmod'))); $additional_msg = $success_msg = ''; + $counter = array(); $s_hidden_fields = build_hidden_fields(array( 'topic_id_list' => $topic_ids, @@ -1306,9 +1307,20 @@ function mcp_fork_topic($topic_ids) 'post_edit_time' => (int) $row['post_edit_time'], 'post_edit_count' => (int) $row['post_edit_count'], 'post_edit_locked' => (int) $row['post_edit_locked'], - 'post_postcount' => 0, + 'post_postcount' => $row['post_postcount'], ); - + // Adjust post count only if the post can be incremented to the user counter + if ($row['post_postcount']) + { + if (isset($counter[$row['poster_id']])) + { + ++$counter[$row['poster_id']]; + } + else + { + $counter[$row['poster_id']] = 1; + } + } $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_post_id = $db->sql_nextid(); @@ -1428,6 +1440,18 @@ function mcp_fork_topic($topic_ids) WHERE forum_id = ' . $to_forum_id; $db->sql_query($sql); + if (!empty($counter)) + { + // Do only one query per user and not a query per post. + foreach ($counter as $user_id => $count) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_posts = user_posts + ' . (int) $count . ' + WHERE user_id = ' . (int) $user_id; + $db->sql_query($sql); + } + } + sync('topic', 'topic_id', $new_topic_id_list); sync('forum', 'forum_id', $to_forum_id); diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 37ce3c6fc3..54b31c642a 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -429,6 +429,29 @@ class mcp_queue OR t.topic_delete_user = 0) $limit_time_sql ORDER BY $sort_order_sql"; + + /** + * Alter sql query to get posts in queue to be accepted + * + * @event core.mcp_queue_get_posts_query_before + * @var string sql Associative array with the query to be executed + * @var array forum_list List of forums that contain the posts + * @var int visibility_const Integer with one of the possible ITEM_* constant values + * @var int topic_id If topic_id not equal to 0, the topic id to filter the posts to display + * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) + * @var string sort_order_sql String with the ORDER BY SQL code used in this query + * @since 3.1.0-RC3 + */ + $vars = array( + 'sql', + 'forum_list', + 'visibility_const', + 'topic_id', + 'limit_time_sql', + 'sort_order_sql', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_query_before', compact($vars))); + $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; @@ -478,6 +501,29 @@ class mcp_queue AND topic_delete_user <> 0 $limit_time_sql ORDER BY $sort_order_sql"; + + /** + * Alter sql query to get information on all topics in the list of forums provided. + * + * @event core.mcp_queue_get_posts_for_topics_query_before + * @var string sql String with the query to be executed + * @var array forum_list List of forums that contain the posts + * @var int visibility_const Integer with one of the possible ITEM_* constant values + * @var int topic_id topic_id in the page request + * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) + * @var string sort_order_sql String with the ORDER BY SQL code used in this query + * @since 3.1.0-RC3 + */ + $vars = array( + 'sql', + 'forum_list', + 'visibility_const', + 'topic_id', + 'limit_time_sql', + 'sort_order_sql', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_for_topics_query_before', compact($vars))); + $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $rowset = array(); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 517143792a..6a91033dbb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -13,10 +13,6 @@ $update_start_time = time(); -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - /** * @ignore */ diff --git a/phpBB/install/index.php b/phpBB/install/index.php index d443c537fa..395aff6c7d 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -11,10 +11,6 @@ * */ -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - /**#@+ * @ignore */ diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 28777a8d24..82ca0fc18d 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1063,6 +1063,14 @@ class install_update extends module $transfer->write_file($file_struct['filename'], $contents); } break; + + case 'deleted': + + if ($update_mode != 'download') + { + $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); + } + break; } } } diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php index 685cdc4e57..4c20ad916d 100644 --- a/phpBB/phpbb/cache/driver/base.php +++ b/phpBB/phpbb/cache/driver/base.php @@ -15,4 +15,217 @@ namespace phpbb\cache\driver; abstract class base implements \phpbb\cache\driver\driver_interface { + var $vars = array(); + var $is_modified = false; + + var $sql_rowset = array(); + var $sql_row_pointer = array(); + var $cache_dir = ''; + + /** + * {@inheritDoc} + */ + function purge() + { + // Purge all phpbb cache files + try + { + $iterator = new \DirectoryIterator($this->cache_dir); + } + catch (\Exception $e) + { + return; + } + + foreach ($iterator as $fileInfo) + { + if ($fileInfo->isDot()) + { + continue; + } + $filename = $fileInfo->getFilename(); + if ($fileInfo->isDir()) + { + $this->remove_dir($fileInfo->getPathname()); + } + else if (strpos($filename, 'container_') === 0 || + strpos($filename, 'url_matcher') === 0 || + strpos($filename, 'sql_') === 0 || + strpos($filename, 'data_') === 0) + { + $this->remove_file($fileInfo->getPathname()); + } + } + + unset($this->vars); + unset($this->sql_rowset); + unset($this->sql_row_pointer); + + $this->vars = array(); + $this->sql_rowset = array(); + $this->sql_row_pointer = array(); + + $this->is_modified = false; + } + + /** + * {@inheritDoc} + */ + function unload() + { + $this->save(); + unset($this->vars); + unset($this->sql_rowset); + unset($this->sql_row_pointer); + + $this->vars = array(); + $this->sql_rowset = array(); + $this->sql_row_pointer = array(); + } + + /** + * {@inheritDoc} + */ + function sql_load($query) + { + // Remove extra spaces and tabs + $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); + + if (($rowset = $this->_read('sql_' . md5($query))) === false) + { + return false; + } + + $query_id = sizeof($this->sql_rowset); + $this->sql_rowset[$query_id] = $rowset; + $this->sql_row_pointer[$query_id] = 0; + + return $query_id; + } + + /** + * {@inheritDoc} + */ + function sql_exists($query_id) + { + return isset($this->sql_rowset[$query_id]); + } + + /** + * {@inheritDoc} + */ + function sql_fetchrow($query_id) + { + if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + { + return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; + } + + return false; + } + + /** + * {@inheritDoc} + */ + function sql_fetchfield($query_id, $field) + { + if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + { + return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false; + } + + return false; + } + + /** + * {@inheritDoc} + */ + function sql_rowseek($rownum, $query_id) + { + if ($rownum >= sizeof($this->sql_rowset[$query_id])) + { + return false; + } + + $this->sql_row_pointer[$query_id] = $rownum; + return true; + } + + /** + * {@inheritDoc} + */ + function sql_freeresult($query_id) + { + if (!isset($this->sql_rowset[$query_id])) + { + return false; + } + + unset($this->sql_rowset[$query_id]); + unset($this->sql_row_pointer[$query_id]); + + return true; + } + + /** + * Removes/unlinks file + * + * @param string $filename Filename to remove + * @param bool $check Check file permissions + * @return bool True if the file was successfully removed, otherwise false + */ + function remove_file($filename, $check = false) + { + if (!function_exists('phpbb_is_writable')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/functions.' . $phpEx); + } + + if ($check && !phpbb_is_writable($this->cache_dir)) + { + // E_USER_ERROR - not using language entry - intended. + trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); + } + + return @unlink($filename); + } + + /** + * Remove directory + * + * @param string $dir Directory to remove + * + * @return null + */ + protected function remove_dir($dir) + { + try + { + $iterator = new \DirectoryIterator($dir); + } + catch (\Exception $e) + { + return; + } + + foreach ($iterator as $fileInfo) + { + if ($fileInfo->isDot()) + { + continue; + } + + if ($fileInfo->isDir()) + { + $this->remove_dir($fileInfo->getPathname()); + } + else + { + $this->remove_file($fileInfo->getPathname()); + } + } + + @rmdir($dir); + } } diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 2d538b739c..fd5bce4515 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -18,13 +18,7 @@ namespace phpbb\cache\driver; */ class file extends \phpbb\cache\driver\base { - var $vars = array(); var $var_expires = array(); - var $is_modified = false; - - var $sql_rowset = array(); - var $sql_row_pointer = array(); - var $cache_dir = ''; /** * Set cache path @@ -50,16 +44,9 @@ class file extends \phpbb\cache\driver\base */ function unload() { - $this->save(); - unset($this->vars); + parent::unload(); unset($this->var_expires); - unset($this->sql_rowset); - unset($this->sql_row_pointer); - - $this->vars = array(); $this->var_expires = array(); - $this->sql_rowset = array(); - $this->sql_row_pointer = array(); } /** @@ -166,8 +153,6 @@ class file extends \phpbb\cache\driver\base { if ($var_name[0] == '_') { - global $phpEx; - if (!$this->_exists($var_name)) { return false; @@ -203,85 +188,8 @@ class file extends \phpbb\cache\driver\base */ function purge() { - // Purge all phpbb cache files - try - { - $iterator = new \DirectoryIterator($this->cache_dir); - } - catch (\Exception $e) - { - return; - } - - foreach ($iterator as $fileInfo) - { - if ($fileInfo->isDot()) - { - continue; - } - $filename = $fileInfo->getFilename(); - if ($fileInfo->isDir()) - { - $this->remove_dir($fileInfo->getPathname()); - } - else if (strpos($filename, 'container_') === 0 || - strpos($filename, 'url_matcher') === 0 || - strpos($filename, 'sql_') === 0 || - strpos($filename, 'data_') === 0) - { - $this->remove_file($fileInfo->getPathname()); - } - } - - unset($this->vars); - unset($this->var_expires); - unset($this->sql_rowset); - unset($this->sql_row_pointer); - - $this->vars = array(); + parent::purge(); $this->var_expires = array(); - $this->sql_rowset = array(); - $this->sql_row_pointer = array(); - - $this->is_modified = false; - } - - /** - * Remove directory - * - * @param string $dir Directory to remove - * - * @return null - */ - protected function remove_dir($dir) - { - try - { - $iterator = new \DirectoryIterator($dir); - } - catch (\Exception $e) - { - return; - } - - foreach ($iterator as $fileInfo) - { - if ($fileInfo->isDot()) - { - continue; - } - - if ($fileInfo->isDir()) - { - $this->remove_dir($fileInfo->getPathname()); - } - else - { - $this->remove_file($fileInfo->getPathname()); - } - } - - @rmdir($dir); } /** @@ -392,26 +300,6 @@ class file extends \phpbb\cache\driver\base /** * {@inheritDoc} */ - function sql_load($query) - { - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - - if (($rowset = $this->_read('sql_' . md5($query))) === false) - { - return false; - } - - $query_id = sizeof($this->sql_rowset); - $this->sql_rowset[$query_id] = $rowset; - $this->sql_row_pointer[$query_id] = 0; - - return $query_id; - } - - /** - * {@inheritDoc} - */ function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) { // Remove extra spaces and tabs @@ -436,70 +324,6 @@ class file extends \phpbb\cache\driver\base } /** - * {@inheritDoc} - */ - function sql_exists($query_id) - { - return isset($this->sql_rowset[$query_id]); - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id) - { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) - { - return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchfield($query_id, $field) - { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) - { - return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, $query_id) - { - if ($rownum >= sizeof($this->sql_rowset[$query_id])) - { - return false; - } - - $this->sql_row_pointer[$query_id] = $rownum; - return true; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id) - { - if (!isset($this->sql_rowset[$query_id])) - { - return false; - } - - unset($this->sql_rowset[$query_id]); - unset($this->sql_row_pointer[$query_id]); - - return true; - } - - /** * Read cached data from a specified file * * @access private @@ -760,28 +584,4 @@ class file extends \phpbb\cache\driver\base return $return_value; } - - /** - * Removes/unlinks file - * - * @param string $filename Filename to remove - * @param bool $check Check file permissions - * @return bool True if the file was successfully removed, otherwise false - */ - function remove_file($filename, $check = false) - { - if (!function_exists('phpbb_is_writable')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } - - if ($check && !phpbb_is_writable($this->cache_dir)) - { - // E_USER_ERROR - not using language entry - intended. - trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); - } - - return @unlink($filename); - } } diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index 5dee375192..56308be8da 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -20,13 +20,6 @@ abstract class memory extends \phpbb\cache\driver\base { var $key_prefix; - var $vars = array(); - var $is_modified = false; - - var $sql_rowset = array(); - var $sql_row_pointer = array(); - var $cache_dir = ''; - /** * Set cache path */ @@ -71,21 +64,6 @@ abstract class memory extends \phpbb\cache\driver\base /** * {@inheritDoc} */ - function unload() - { - $this->save(); - unset($this->vars); - unset($this->sql_rowset); - unset($this->sql_row_pointer); - - $this->vars = array(); - $this->sql_rowset = array(); - $this->sql_row_pointer = array(); - } - - /** - * {@inheritDoc} - */ function save() { if (!$this->is_modified) @@ -147,47 +125,6 @@ abstract class memory extends \phpbb\cache\driver\base /** * {@inheritDoc} */ - function purge() - { - // Purge all phpbb cache files - $dir = @opendir($this->cache_dir); - - if (!$dir) - { - return; - } - - while (($entry = readdir($dir)) !== false) - { - if (strpos($entry, 'container_') !== 0 && - strpos($entry, 'url_matcher') !== 0 && - strpos($entry, 'sql_') !== 0 && - strpos($entry, 'data_') !== 0 && - strpos($entry, 'ctpl_') !== 0 && - strpos($entry, 'tpl_') !== 0) - { - continue; - } - - $this->remove_file($this->cache_dir . $entry); - } - closedir($dir); - - unset($this->vars); - unset($this->sql_rowset); - unset($this->sql_row_pointer); - - $this->vars = array(); - $this->sql_rowset = array(); - $this->sql_row_pointer = array(); - - $this->is_modified = false; - } - - - /** - * {@inheritDoc} - */ function destroy($var_name, $table = '') { if ($var_name == 'sql' && !empty($table)) @@ -262,26 +199,6 @@ abstract class memory extends \phpbb\cache\driver\base /** * {@inheritDoc} */ - function sql_load($query) - { - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = sizeof($this->sql_rowset); - - if (($result = $this->_read('sql_' . md5($query))) === false) - { - return false; - } - - $this->sql_rowset[$query_id] = $result; - $this->sql_row_pointer[$query_id] = 0; - - return $query_id; - } - - /** - * {@inheritDoc} - */ function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) { // Remove extra spaces and tabs @@ -338,94 +255,6 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * {@inheritDoc} - */ - function sql_exists($query_id) - { - return isset($this->sql_rowset[$query_id]); - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id) - { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) - { - return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchfield($query_id, $field) - { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) - { - return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, $query_id) - { - if ($rownum >= sizeof($this->sql_rowset[$query_id])) - { - return false; - } - - $this->sql_row_pointer[$query_id] = $rownum; - return true; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id) - { - if (!isset($this->sql_rowset[$query_id])) - { - return false; - } - - unset($this->sql_rowset[$query_id]); - unset($this->sql_row_pointer[$query_id]); - - return true; - } - - /** - * Removes/unlinks file - * - * @param string $filename Filename to remove - * @param bool $check Check file permissions - * @return bool True if the file was successfully removed, otherwise false - */ - function remove_file($filename, $check = false) - { - if (!function_exists('phpbb_is_writable')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } - - if ($check && !phpbb_is_writable($this->cache_dir)) - { - // E_USER_ERROR - not using language entry - intended. - trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); - } - - return @unlink($filename); - } - - /** * Check if a cache var exists * * @access protected diff --git a/phpBB/phpbb/config_php_file.php b/phpBB/phpbb/config_php_file.php index 1a562e470d..7445e7df22 100644 --- a/phpBB/phpbb/config_php_file.php +++ b/phpBB/phpbb/config_php_file.php @@ -71,59 +71,44 @@ class config_php_file /** * Returns an associative array containing the variables defined by the config file. * - * @return bool|array Return the content of the config file or false if the file does not exists. + * @return array Return the content of the config file or an empty array if the file does not exists. */ public function get_all() { - if (!$this->load_config_file()) - { - return false; - } + $this->load_config_file(); return $this->config_data; } /** - * Return the value of a variable defined into the config.php file and false if the variable does not exist. + * Return the value of a variable defined into the config.php file or null if the variable does not exist. * * @param string $variable The name of the variable - * @return mixed + * @return mixed Value of the variable or null if the variable is not defined. */ public function get($variable) { - if (!$this->load_config_file()) - { - return false; - } + $this->load_config_file(); - return isset($this->config_data[$variable]) ? $this->config_data[$variable] : false; + return isset($this->config_data[$variable]) ? $this->config_data[$variable] : null; } /** * Load the config file and store the information. * - * @return bool True if the file was correctly loaded, false otherwise. + * @return null */ protected function load_config_file() { - if (!$this->config_loaded) + if (!$this->config_loaded && file_exists($this->config_file)) { - if (file_exists($this->config_file)) - { - $this->defined_vars = get_defined_vars(); + $this->defined_vars = get_defined_vars(); - require($this->config_file); - $this->config_data = array_diff_key(get_defined_vars(), $this->defined_vars); + require($this->config_file); + $this->config_data = array_diff_key(get_defined_vars(), $this->defined_vars); - $this->config_loaded = true; - } - else - { - return false; - } + $this->config_loaded = true; } - - return true; } /** diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index efab34b701..948a6a218c 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -41,6 +41,12 @@ class resolver implements ControllerResolverInterface protected $template; /** + * Request type cast helper object + * @var \phpbb\request\type_cast_helper + */ + protected $type_cast_helper; + + /** * phpBB root path * @var string */ @@ -59,6 +65,7 @@ class resolver implements ControllerResolverInterface $this->user = $user; $this->container = $container; $this->template = $template; + $this->type_cast_helper = new \phpbb\request\type_cast_helper(); $this->phpbb_root_path = $phpbb_root_path; } @@ -138,7 +145,16 @@ class resolver implements ControllerResolverInterface { if (array_key_exists($param->name, $attributes)) { - $arguments[] = $attributes[$param->name]; + if (is_string($attributes[$param->name])) + { + $value = $attributes[$param->name]; + $this->type_cast_helper->set_var($value, $attributes[$param->name], 'string', true, false); + $arguments[] = $value; + } + else + { + $arguments[] = $attributes[$param->name]; + } } else if ($param->getClass() && $param->getClass()->isInstance($request)) { diff --git a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php index f5970e74b2..6335c75398 100644 --- a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php +++ b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php @@ -119,6 +119,7 @@ class soft_delete_mod_convert extends \phpbb\db\migration\migration { return new \phpbb\content_visibility( new \phpbb\auth\auth(), + $this->config, $this->db, new \phpbb\user(), $this->phpbb_root_path, diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 5d93eb8246..3567570137 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1816,7 +1816,8 @@ class tools $old_return_statements = $this->return_statements; $this->return_statements = true; - $indexes = $this->mssql_get_existing_indexes($table_name, $column_name); + $indexes = $this->get_existing_indexes($table_name, $column_name); + $indexes = array_merge($indexes, $this->get_existing_indexes($table_name, $column_name, true)); // Drop any indexes $recreate_indexes = array(); @@ -2038,7 +2039,7 @@ class tools break; case 'oracle': - $statements[] = 'ALTER TABLE ' . $table_name . 'add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; + $statements[] = 'ALTER TABLE ' . $table_name . ' add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; break; case 'sqlite': @@ -2274,10 +2275,23 @@ class tools } /** + * Removes table_name from the index_name if it is at the beginning + * + * @param $table_name + * @param $index_name + * @return string + */ + protected function strip_table_name_from_index_name($table_name, $index_name) + { + return (strpos(strtoupper($index_name), strtoupper($table_name)) === 0) ? substr($index_name, strlen($table_name) + 1) : $index_name; + } + + /** * Change column type (not name!) */ function sql_column_change($table_name, $column_name, $column_data, $inline = false) { + $original_column_data = $column_data; $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); $statements = array(); @@ -2289,12 +2303,14 @@ class tools $old_return_statements = $this->return_statements; $this->return_statements = true; - $indexes = $this->mssql_get_existing_indexes($table_name, $column_name); + $indexes = $this->get_existing_indexes($table_name, $column_name); + $unique_indexes = $this->get_existing_indexes($table_name, $column_name, true); // Drop any indexes - if (!empty($indexes)) + if (!empty($indexes) || !empty($unique_indexes)) { - foreach ($indexes as $index_name => $index_data) + $drop_indexes = array_merge(array_keys($indexes), array_keys($unique_indexes)); + foreach ($drop_indexes as $index_name) { $result = $this->sql_index_drop($table_name, $index_name); $statements = array_merge($statements, $result); @@ -2324,6 +2340,16 @@ class tools } } + if (!empty($unique_indexes)) + { + // Recreate unique indexes after we changed the column + foreach ($unique_indexes as $index_name => $index_data) + { + $result = $this->sql_create_unique_index($table_name, $index_name, $index_data); + $statements = array_merge($statements, $result); + } + } + $this->return_statements = $old_return_statements; break; @@ -2333,7 +2359,69 @@ class tools break; case 'oracle': - $statements[] = 'ALTER TABLE ' . $table_name . ' MODIFY ' . $column_name . ' ' . $column_data['column_type_sql']; + // We need the data here + $old_return_statements = $this->return_statements; + $this->return_statements = true; + + // Get list of existing indexes + $indexes = $this->get_existing_indexes($table_name, $column_name); + $unique_indexes = $this->get_existing_indexes($table_name, $column_name, true); + + // Drop any indexes + if (!empty($indexes) || !empty($unique_indexes)) + { + $drop_indexes = array_merge(array_keys($indexes), array_keys($unique_indexes)); + foreach ($drop_indexes as $index_name) + { + $result = $this->sql_index_drop($table_name, $this->strip_table_name_from_index_name($table_name, $index_name)); + $statements = array_merge($statements, $result); + } + } + + $temp_column_name = 'temp_' . substr(md5($column_name), 0, 25); + // Add a temporary table with the new type + $result = $this->sql_column_add($table_name, $temp_column_name, $original_column_data); + $statements = array_merge($statements, $result); + + // Copy the data to the new column + $statements[] = 'UPDATE ' . $table_name . ' SET ' . $temp_column_name . ' = ' . $column_name; + + // Drop the original column + $result = $this->sql_column_remove($table_name, $column_name); + $statements = array_merge($statements, $result); + + // Recreate the original column with the new type + $result = $this->sql_column_add($table_name, $column_name, $original_column_data); + $statements = array_merge($statements, $result); + + if (!empty($indexes)) + { + // Recreate indexes after we changed the column + foreach ($indexes as $index_name => $index_data) + { + $result = $this->sql_create_index($table_name, $this->strip_table_name_from_index_name($table_name, $index_name), $index_data); + $statements = array_merge($statements, $result); + } + } + + if (!empty($unique_indexes)) + { + // Recreate unique indexes after we changed the column + foreach ($unique_indexes as $index_name => $index_data) + { + $result = $this->sql_create_unique_index($table_name, $this->strip_table_name_from_index_name($table_name, $index_name), $index_data); + $statements = array_merge($statements, $result); + } + } + + // Copy the data to the original column + $statements[] = 'UPDATE ' . $table_name . ' SET ' . $column_name . ' = ' . $temp_column_name; + + // Drop the temporary column again + $result = $this->sql_column_remove($table_name, $temp_column_name); + $statements = array_merge($statements, $result); + + $this->return_statements = $old_return_statements; break; case 'postgres': @@ -2517,45 +2605,78 @@ class tools * * @param string $table_name * @param string $column_name + * @param bool $unique Should we get unique indexes or normal ones * @return array Array with Index name => columns */ - protected function mssql_get_existing_indexes($table_name, $column_name) + public function get_existing_indexes($table_name, $column_name, $unique = false) { - $existing_indexes = array(); - if ($this->mssql_is_sql_server_2000()) + switch ($this->sql_layer) { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND cols.name = '{$column_name}'"; + case 'mysql_40': + case 'mysql_41': + case 'postgres': + case 'sqlite': + case 'sqlite3': + // Not supported + throw new \Exception('DBMS is not supported'); + break; } - else + + $sql = ''; + $existing_indexes = array(); + + switch ($this->sql_layer) { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name - FROM sys.indexes ix - INNER JOIN sys.index_columns ixc - ON ixc.object_id = ix.object_id - AND ixc.index_id = ix.index_id - INNER JOIN sys.columns cols - ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id - WHERE ix.object_id = object_id('{$table_name}') - AND cols.name = '{$column_name}'"; + case 'mssql': + case 'mssqlnative': + if ($this->mssql_is_sql_server_2000()) + { + // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx + // Deprecated in SQL Server 2005 + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name + FROM sysindexes ix + INNER JOIN sysindexkeys ixc + ON ixc.id = ix.id + AND ixc.indid = ix.indid + INNER JOIN syscolumns cols + ON cols.colid = ixc.colid + AND cols.id = ix.id + WHERE ix.id = object_id('{$table_name}') + AND cols.name = '{$column_name}' + AND INDEXPROPERTY(ix.id, ix.name, 'IsUnique') = " . ($unique) ? '1' : '0'; + } + else + { + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name + FROM sys.indexes ix + INNER JOIN sys.index_columns ixc + ON ixc.object_id = ix.object_id + AND ixc.index_id = ix.index_id + INNER JOIN sys.columns cols + ON cols.column_id = ixc.column_id + AND cols.object_id = ix.object_id + WHERE ix.object_id = object_id('{$table_name}') + AND cols.name = '{$column_name}' + AND ix.is_unique = " . ($unique) ? '1' : '0'; + } + break; + + case 'oracle': + $sql = "SELECT ix.index_name AS phpbb_index_name, ix.uniqueness AS is_unique + FROM all_ind_columns ixc, all_indexes ix + WHERE ix.index_name = ixc.index_name + AND ixc.table_name = '" . strtoupper($table_name) . "' + AND ixc.column_name = '" . strtoupper($column_name) . "'"; + break; } $result = $this->db->sql_query($sql); - $existing_indexes = array(); while ($row = $this->db->sql_fetchrow($result)) { - $existing_indexes[$row['phpbb_index_name']] = array(); + if (!isset($row['is_unique']) || ($unique && $row['is_unique'] == 'UNIQUE') || (!$unique && $row['is_unique'] == 'NONUNIQUE')) + { + $existing_indexes[$row['phpbb_index_name']] = array(); + } } $this->db->sql_freeresult($result); @@ -2564,35 +2685,47 @@ class tools return array(); } - if ($this->mssql_is_sql_server_2000()) - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - } - else + switch ($this->sql_layer) { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sys.indexes ix - INNER JOIN sys.index_columns ixc - ON ixc.object_id = ix.object_id - AND ixc.index_id = ix.index_id - INNER JOIN sys.columns cols - ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id - WHERE ix.object_id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); + case 'mssql': + case 'mssqlnative': + if ($this->mssql_is_sql_server_2000()) + { + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name + FROM sysindexes ix + INNER JOIN sysindexkeys ixc + ON ixc.id = ix.id + AND ixc.indid = ix.indid + INNER JOIN syscolumns cols + ON cols.colid = ixc.colid + AND cols.id = ix.id + WHERE ix.id = object_id('{$table_name}') + AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); + } + else + { + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name + FROM sys.indexes ix + INNER JOIN sys.index_columns ixc + ON ixc.object_id = ix.object_id + AND ixc.index_id = ix.index_id + INNER JOIN sys.columns cols + ON cols.column_id = ixc.column_id + AND cols.object_id = ix.object_id + WHERE ix.object_id = object_id('{$table_name}') + AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); + } + break; + + case 'oracle': + $sql = "SELECT index_name AS phpbb_index_name, column_name AS phpbb_column_name + FROM all_ind_columns + WHERE table_name = '" . strtoupper($table_name) . "' + AND " . $this->db->sql_in_set('index_name', array_keys($existing_indexes)); + break; } $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) { $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php index 1051021ea7..edca8ee1af 100644 --- a/phpBB/phpbb/extension/metadata_manager.php +++ b/phpBB/phpbb/extension/metadata_manager.php @@ -330,27 +330,6 @@ class metadata_manager } /** - * Version validation helper - * - * @param string $string The string for comparing to a version - * @param string $current_version The version to compare to - * @return bool True/False if meets version requirements - */ - private function _validate_version($string, $current_version) - { - // Allow them to specify their own comparison operator (ex: <3.1.2, >=3.1.0) - $comparison_matches = false; - preg_match('#[=<>]+#', $string, $comparison_matches); - - if (!empty($comparison_matches)) - { - return version_compare($current_version, str_replace(array($comparison_matches[0], ' '), '', $string), $comparison_matches[0]); - } - - return version_compare($current_version, $string, '>='); - } - - /** * Outputs the metadata into the template * * @return null diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 6bf6af1b78..082bea22f1 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -34,7 +34,7 @@ <fieldset id="display-panel" class="fields2" role="tabpanel"> <dl> <dt><label for="posts_per_page">{L_POSTS_PER_PAGE}{L_COLON}</label><br /><span>{L_POSTS_PER_PAGE_EXPLAIN}</span></dt> - <dd><input class="inputbox autowidth" type="number" min="1" name="posts_per_page" id="posts_per_page" size="6" value="{POSTS_PER_PAGE}" /></dd> + <dd><input class="inputbox autowidth" type="number" min="0" name="posts_per_page" id="posts_per_page" size="6" value="{POSTS_PER_PAGE}" /></dd> </dl> <dl> <dt><label>{L_DISPLAY_POSTS}{L_COLON}</label></dt> diff --git a/phpBB/styles/prosilver/template/navbar_header.html b/phpBB/styles/prosilver/template/navbar_header.html index 68759c3c4c..41c5793320 100644 --- a/phpBB/styles/prosilver/template/navbar_header.html +++ b/phpBB/styles/prosilver/template/navbar_header.html @@ -43,7 +43,7 @@ <li class="small-icon icon-faq" <!-- IF not S_USER_LOGGED_IN -->data-skip-responsive="true"<!-- ELSE -->data-last-responsive="true"<!-- ENDIF -->><a href="{U_FAQ}" rel="help" title="{L_FAQ_EXPLAIN}" role="menuitem">{L_FAQ}</a></li> <!-- EVENT overall_header_navigation_append --> <!-- IF U_ACP --><li class="small-icon icon-acp" data-last-responsive="true"><a href="{U_ACP}" title="{L_ACP}" role="menuitem">{L_ACP_SHORT}</a></li><!-- ENDIF --> - <!-- IF U_MCP --><li class="small-icon icon-mcp" data-skip-responsive="true"><a href="{U_MCP}" title="{L_MCP}" role="menuitem">{L_MCP_SHORT}</a></li><!-- ENDIF --> + <!-- IF U_MCP --><li class="small-icon icon-mcp" data-last-responsive="true"><a href="{U_MCP}" title="{L_MCP}" role="menuitem">{L_MCP_SHORT}</a></li><!-- ENDIF --> <!-- IF S_REGISTERED_USER --> <li id="username_logged_in" class="rightside <!-- IF CURRENT_USER_AVATAR --> no-bulletin<!-- ENDIF -->" data-skip-responsive="true"> diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 489c1c901a..62993e9b4e 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -18,7 +18,14 @@ <div class="inner"> <dl class="postprofile" id="profile{MESSAGE_ID}"> - <dt class="<!-- IF RANK_TITLE or RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF -->"><!-- IF AUTHOR_AVATAR --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR}</a><!-- ENDIF -->{MESSAGE_AUTHOR_FULL}</dt> + <dt class="<!-- IF RANK_TITLE or RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF --> <!-- IF AUTHOR_AVATAR -->has-avatar<!-- ELSE -->no-avatar<!-- ENDIF -->"> + <div class="avatar-container"> + <!-- EVENT ucp_pm_viewmessage_avatar_before --> + <!-- IF AUTHOR_AVATAR --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR}</a><!-- ENDIF --> + <!-- EVENT ucp_pm_viewmessage_avatar_after --> + </div> + {MESSAGE_AUTHOR_FULL} + </dt> <!-- IF RANK_TITLE or RANK_IMG --><dd class="profile-rank">{RANK_TITLE}<!-- IF RANK_TITLE and RANK_IMG --><br /><!-- ENDIF -->{RANK_IMG}</dd><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index b764979f97..810c30ed15 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -124,10 +124,14 @@ <div class="inner"> <dl class="postprofile" id="profile{postrow.POST_ID}"<!-- IF postrow.S_POST_HIDDEN --> style="display: none;"<!-- ENDIF -->> - <dt class="<!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF -->"> - <!-- IF postrow.POSTER_AVATAR --> - <!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}" class="avatar">{postrow.POSTER_AVATAR}</a><!-- ELSE --><span class="avatar">{postrow.POSTER_AVATAR}</span><!-- ENDIF --> - <!-- ENDIF --> + <dt class="<!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF --> <!-- IF postrow.POSTER_AVATAR -->has-avatar<!-- ELSE -->no-avatar<!-- ENDIF -->"> + <div class="avatar-container"> + <!-- EVENT viewtopic_body_avatar_before --> + <!-- IF postrow.POSTER_AVATAR --> + <!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}" class="avatar">{postrow.POSTER_AVATAR}</a><!-- ELSE --><span class="avatar">{postrow.POSTER_AVATAR}</span><!-- ENDIF --> + <!-- ENDIF --> + <!-- EVENT viewtopic_body_avatar_after --> + </div> <!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF --> </dt> diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index d3594cc5bd..f6e490f82a 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -332,12 +332,8 @@ li.breadcrumbs span:first-child > a { .rtl .skiplink { /* invisible skip link, used for accessibility */ - position: relative; - width: 1px; - height: 1px; - overflow: hidden; - display: block; left: 0; + right: -999px; } .rtl a.feed-icon-forum { @@ -586,6 +582,10 @@ li.breadcrumbs span:first-child > a { margin-right: 8px; } +.rtl .postprofile .avatar { + float: right; +} + .rtl .online { background-position: 0 0; } @@ -1078,8 +1078,11 @@ li.breadcrumbs span:first-child > a { border-width: 0 0 1px 0; } + .rtl .postprofile dt, .rtl .postprofile dd.profile-rank, .rtl .search .postprofile dd { + margin: 0; + } + .rtl .postprofile .avatar { - float: right; margin-left: 5px; margin-right: 0; } diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 54d81406e8..45cb88890d 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -305,12 +305,6 @@ ol ol ul, ol ul ul, ul ol ul, ul ul ul { border-radius: 7px; } -.inner:after { - content: ''; - clear: both; - display: block; -} - .rowbg { margin: 5px 5px 2px 5px; } @@ -326,12 +320,6 @@ ul.linklist { margin: 0; } -ul.linklist:after { - content: ''; - display: block; - clear: both; -} - #cp-main .panel { padding: 5px 10px; } @@ -856,12 +844,6 @@ fieldset.fields1 dl.pmlist dd.recipients { margin-top: 2em; } -.action-bar:after { - clear: both; - content: ''; - display: block; -} - /* Pagination ---------------------------------------- */ .pagination { @@ -1130,6 +1112,20 @@ form > p.post-notice strong { background: transparent; } +/* Inner box-model clearing */ +.inner:after, +ul.linklist:after, +.action-bar:after, +.notification_text:after, +.tabs-container:after, +#tabs > ul:after, +#minitabs > ul:after, +.postprofile .avatar-container:after { + clear: both; + content: ''; + display: block; +} + .hidden { display: none; } @@ -1285,12 +1281,6 @@ form > p.post-notice strong { margin-left: 58px; } -.notification_text:after { - content: ''; - clear: both; - display: block; -} - /* Navbar specific list items ----------------------------------------*/ diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index a014f57d47..8b84545a2c 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -710,15 +710,22 @@ fieldset.polls dd div { margin-bottom: 10px; } +/* Post-profile avatars */ +.postprofile .has-avatar .avatar-container { + margin-bottom: 3px; + overflow: hidden; +} + .postprofile .avatar { display: block; - border: none; - margin-bottom: 3px; + float: left; + max-width: 100%; } .postprofile .avatar img { - max-width: 90%; + display: block; height: auto !important; + max-width: 100%; } dd.profile-warnings { diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css index 5149a16ec9..d3699c3012 100644 --- a/phpBB/styles/prosilver/theme/cp.css +++ b/phpBB/styles/prosilver/theme/cp.css @@ -96,12 +96,6 @@ ul.cplist { margin-bottom: 0px; } -.tabs-container:after { - clear: both; - content: ''; - display: block; -} - /* CP tabs shared ----------------------------------------*/ #tabs, #minitabs { @@ -115,12 +109,6 @@ ul.cplist { position: relative; } -#tabs > ul:after, #minitabs > ul:after { - clear: both; - content: ''; - display: block; -} - #tabs .tab, #minitabs .tab { display: inline-block; float: left; diff --git a/phpBB/styles/prosilver/theme/images/icon_print.gif b/phpBB/styles/prosilver/theme/images/icon_print.gif Binary files differindex e464e304ea..e464e304ea 100755..100644 --- a/phpBB/styles/prosilver/theme/images/icon_print.gif +++ b/phpBB/styles/prosilver/theme/images/icon_print.gif diff --git a/phpBB/styles/prosilver/theme/responsive.css b/phpBB/styles/prosilver/theme/responsive.css index 241b4d132e..b9cbd4cdfb 100644 --- a/phpBB/styles/prosilver/theme/responsive.css +++ b/phpBB/styles/prosilver/theme/responsive.css @@ -424,16 +424,22 @@ fieldset.polls dd.resultbar, fieldset.polls dd.poll_option_percent { margin: 0; } +.postprofile .has-avatar .avatar-container { + margin: 0; + overflow: inherit; +} + +.postprofile .avatar-container:after { + clear: none; +} + .postprofile .avatar { - display: block; - float: left; margin-right: 5px; } .postprofile .avatar img { width: auto !important; height: auto !important; - display: block; max-height: 32px; } diff --git a/phpBB/styles/prosilver/theme/tweaks.css b/phpBB/styles/prosilver/theme/tweaks.css index ea0c66d20a..851b3a6bb6 100644 --- a/phpBB/styles/prosilver/theme/tweaks.css +++ b/phpBB/styles/prosilver/theme/tweaks.css @@ -71,3 +71,8 @@ dd.option { .header-avatar img { height: 20px; } + +/* IE8 often can't handle max-width in %, so we use px instead */ +.postprofile .avatar img { + max-width: 150px; +} diff --git a/phpBB/styles/subsilver2/template/mcp_topic.html b/phpBB/styles/subsilver2/template/mcp_topic.html index 5bd762ec0b..cba473147e 100644 --- a/phpBB/styles/subsilver2/template/mcp_topic.html +++ b/phpBB/styles/subsilver2/template/mcp_topic.html @@ -55,7 +55,7 @@ </tr> <tr> <td class="row1" nowrap="nowrap"><span class="gen">{L_POSTS_PER_PAGE}</span><br /><span class="gensmall">{L_POSTS_PER_PAGE_EXPLAIN}</span></td> - <td class="row2" colspan="2"><input class="post" type="number" min="1" name="posts_per_page" size="6" value="{POSTS_PER_PAGE}" /></td> + <td class="row2" colspan="2"><input class="post" type="number" min="0" name="posts_per_page" size="6" value="{POSTS_PER_PAGE}" /></td> </tr> <tr> <td class="cat" colspan="3" align="center"><span class="gensmall">{L_DISPLAY_POSTS}{L_COLON}</span> {S_SELECT_SORT_DAYS} <span class="gensmall">{L_SORT_BY}</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" name="sort" value="{L_GO}" /></td> diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index c69be83a1e..0f34b50950 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -192,11 +192,15 @@ <td>{postrow.RANK_IMG}</td> </tr> <!-- ENDIF --> + + <!-- EVENT viewtopic_body_avatar_before --> <!-- IF postrow.POSTER_AVATAR --> <tr> <td>{postrow.POSTER_AVATAR}</td> </tr> <!-- ENDIF --> + <!-- EVENT viewtopic_body_avatar_after --> + <!-- IF not (postrow.ONLINE_IMG or postrow.RANK_TITLE or postrow.RANK_IMG or postrow.POSTER_AVATAR) --> <tr> <td></td> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1fdce5a6c3..50481302e6 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -539,8 +539,8 @@ $s_quickmod_action = append_sid( $quickmod_array = array( // 'key' => array('LANG_KEY', $userHasPermissions), - 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), - 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), + 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster']))), + 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id))), 'delete_topic' => array('DELETE_TOPIC', ($auth->acl_get('m_delete', $forum_id) || (($topic_data['topic_visibility'] != ITEM_DELETED) && $auth->acl_get('m_softdelete', $forum_id)))), 'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))), 'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED), diff --git a/tests/config_php_file_test.php b/tests/config_php_file_test.php index c2e4eb21c7..c319678108 100644 --- a/tests/config_php_file_test.php +++ b/tests/config_php_file_test.php @@ -17,6 +17,7 @@ class phpbb_config_php_file_test extends phpbb_test_case { $config_php = new \phpbb\config_php_file(dirname( __FILE__ ) . '/fixtures/', 'php'); $this->assertSame('bar', $config_php->get('foo')); + $this->assertNull($config_php->get('bar')); $this->assertSame(array('foo' => 'bar', 'foo_foo' => 'bar bar'), $config_php->get_all()); } @@ -25,6 +26,15 @@ class phpbb_config_php_file_test extends phpbb_test_case $config_php = new \phpbb\config_php_file(dirname( __FILE__ ) . '/fixtures/', 'php'); $config_php->set_config_file(dirname( __FILE__ ) . '/fixtures/config_other.php'); $this->assertSame('foo', $config_php->get('bar')); + $this->assertNull($config_php->get('foo')); $this->assertSame(array('bar' => 'foo', 'bar_bar' => 'foo foo'), $config_php->get_all()); } + + public function test_non_existent_file() + { + $config_php = new \phpbb\config_php_file(dirname( __FILE__ ) . '/fixtures/non_existent/', 'php'); + $this->assertNull($config_php->get('bar')); + $this->assertNull($config_php->get('foo')); + $this->assertSame(array(), $config_php->get_all()); + } } diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 6cc2f8ec0f..51f9daacfb 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -288,13 +288,13 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2')); // Create index over the column - $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_2')); - $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012_2', array('c_bug_12012_2', 'c_bool'))); - $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_2')); + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_2')); + $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'bug_12012_2', array('c_bug_12012_2', 'c_bool'))); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_2')); - $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_3')); - $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012_3', array('c_bug_12012_2'))); - $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_3')); + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_3')); + $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'bug_12012_3', array('c_bug_12012_2'))); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_3')); // Remove the column $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2')); diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php new file mode 100644 index 0000000000..bfcb05862e --- /dev/null +++ b/tests/functions/insert_config_array_test.php @@ -0,0 +1,142 @@ +<?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. +* +*/ + +class phpbb_functions_insert_config_array_test extends phpbb_test_case +{ + public function config_display_vars() + { + return array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ); + } + + public function insert_config_array_data() + { + return array( + array( // Add a new config after 1st array item + array('new_config_1' => array()), + array('after' => 'legend1'), + array( + 'legend1' => '', + 'new_config_1' => array(), + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // Add a new config after last array item + array('new_config_1' => array()), + array('after' => 'acp_config_5'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + 'new_config_1' => array(), + ), + ), + array( // Add a new config before 2nd array item + array('new_config_1' => array()), + array('before' => 'acp_config_1'), + array( + 'legend1' => '', + 'new_config_1' => array(), + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // Add a new config before last config item + array('new_config_1' => array()), + array('before' => 'acp_config_5'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'new_config_1' => array(), + 'acp_config_5' => array(), + ), + ), + array( // When an array key does not exist + array('new_config_1' => array()), + array('after' => 'foobar'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // When after|before is not used correctly (defaults to after) + array('new_config_1' => array()), + array('foobar' => 'acp_config_1'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'new_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + ), + ), + array( // Add a new config set after the last array item + array( + 'legend2' => array(), + 'new_config_1' => array(), + 'new_config_2' => array(), + 'new_config_3' => array(), + ), + array('after' => 'acp_config_5'), + array( + 'legend1' => '', + 'acp_config_1' => array(), + 'acp_config_2' => array(), + 'acp_config_3' => array(), + 'acp_config_4' => array(), + 'acp_config_5' => array(), + 'legend2' => array(), + 'new_config_1' => array(), + 'new_config_2' => array(), + 'new_config_3' => array(), + ), + ), + ); + } + + /** + * @dataProvider insert_config_array_data + */ + public function test_insert_config_array($new_config, $position, $expected) + { + $config_array = $this->config_display_vars(); + $new_config_array = phpbb_insert_config_array($config_array, $new_config, $position); + + $this->assertSame($expected, $new_config_array); + } +} diff --git a/travis/check-executable-files.sh b/travis/check-executable-files.sh new file mode 100755 index 0000000000..4d420add1c --- /dev/null +++ b/travis/check-executable-files.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# 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. +# +set -e + +DB=$1 +TRAVIS_PHP_VERSION=$2 +root="$3" +path="${root}phpBB/" + +if [ "$TRAVIS_PHP_VERSION" == "5.3.3" -a "$DB" == "mysqli" ] +then + # Check the permissions of the files + + # The following variables MUST NOT contain any wildcard + # Directories to skip + directories_skipped="-path ${path}develop -o -path ${path}vendor" + + # Files to skip + files_skipped="-false" + + # Files which have to be executable + executable_files="-path ${path}bin/*" + + incorrect_files=$( \ + find ${path} \ + '(' \ + '(' \ + ${directories_skipped} \ + ')' \ + -a -type d -prune -a -type f \ + ')' -o \ + '(' \ + -type f -a \ + -not '(' \ + ${files_skipped} \ + ')' -a \ + '(' \ + '(' \ + '(' \ + ${executable_files} \ + ')' -a \ + -not -perm +100 \ + ')' -o \ + '(' \ + -not '(' \ + ${executable_files} \ + ')' -a \ + -perm +111 \ + ')' \ + ')' \ + ')' \ + ) + + if [ "${incorrect_files}" != '' ] + then + echo "The following files do not have proper permissions:"; + ls -la ${incorrect_files} + exit 1; + fi +fi |