diff options
Diffstat (limited to 'phpBB/phpbb')
67 files changed, 824 insertions, 686 deletions
diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php index 65249275d4..38755ccf99 100644 --- a/phpBB/phpbb/auth/auth.php +++ b/phpBB/phpbb/auth/auth.php @@ -208,9 +208,12 @@ class auth /** * Get forums with the specified permission setting - * if the option is prefixed with !, then the result becomes negated * - * @param bool $clean set to true if only values needs to be returned which are set/unset + * @param string $opt The permission name to lookup. If prefixed with !, the result is negated. + * @param bool $clean set to true if only values needs to be returned which are set/unset + * + * @return array Contains the forum ids with the specified permission set to true. + This is a nested array: array => forum_id => permission => true */ function acl_getf($opt, $clean = false) { diff --git a/phpBB/phpbb/auth/provider/apache.php b/phpBB/phpbb/auth/provider/apache.php index 4f44efe9af..9137a77210 100644 --- a/phpBB/phpbb/auth/provider/apache.php +++ b/phpBB/phpbb/auth/provider/apache.php @@ -28,13 +28,13 @@ class apache extends \phpbb\auth\provider\base /** * Apache Authentication Constructor * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\config\config $config - * @param \phpbb\passwords\manager $passwords_manager - * @param \phpbb\request\request $request - * @param \phpbb\user $user - * @param string $phpbb_root_path - * @param string $php_ext + * @param \phpbb\db\driver\driver_interface $db Database object + * @param \phpbb\config\config $config Config object + * @param \phpbb\passwords\manager $passwords_manager Passwords Manager object + * @param \phpbb\request\request $request Request object + * @param \phpbb\user $user User object + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request $request, \phpbb\user $user, $phpbb_root_path, $php_ext) { diff --git a/phpBB/phpbb/auth/provider/ldap.php b/phpBB/phpbb/auth/provider/ldap.php index e7764b754b..d32e7504eb 100644 --- a/phpBB/phpbb/auth/provider/ldap.php +++ b/phpBB/phpbb/auth/provider/ldap.php @@ -29,10 +29,10 @@ class ldap extends \phpbb\auth\provider\base /** * LDAP Authentication Constructor * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\config\config $config - * @param \phpbb\passwords\manager $passwords_manager - * @param \phpbb\user $user + * @param \phpbb\db\driver\driver_interface $db Database object + * @param \phpbb\config\config $config Config object + * @param \phpbb\passwords\manager $passwords_manager Passwords manager object + * @param \phpbb\user $user User object */ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\user $user) { diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index c43004f340..f5ba50451a 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -19,6 +19,31 @@ namespace phpbb\avatar\driver; class upload extends \phpbb\avatar\driver\driver { /** + * @var \phpbb\mimetype\guesser + */ + protected $mimetype_guesser; + + /** + * Construct a driver object + * + * @param \phpbb\config\config $config phpBB configuration + * @param string $phpbb_root_path Path to the phpBB root + * @param string $php_ext PHP file extension + * @param \phpbb_path_helper $path_helper phpBB path helper + * @param \phpbb\mimetype\guesser $mimetype_guesser Mimetype guesser + * @param \phpbb\cache\driver\driver_interface $cache Cache driver + */ + public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\mimetype\guesser $mimetype_guesser, \phpbb\cache\driver\driver_interface $cache = null) + { + $this->config = $config; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->path_helper = $path_helper; + $this->mimetype_guesser = $mimetype_guesser; + $this->cache = $cache; + } + + /** * {@inheritdoc} */ public function get_data($row, $ignore_config = false) @@ -70,7 +95,7 @@ class upload extends \phpbb\avatar\driver\driver if (!empty($upload_file['name'])) { - $file = $upload->form_upload('avatar_upload_file'); + $file = $upload->form_upload('avatar_upload_file', $this->mimetype_guesser); } else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) { @@ -100,7 +125,7 @@ class upload extends \phpbb\avatar\driver\driver return false; } - $file = $upload->remote_upload($url); + $file = $upload->remote_upload($url, $this->mimetype_guesser); } else { 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 b32af32d25..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/cache/service.php b/phpBB/phpbb/cache/service.php index d6bf150384..56727c2ad5 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -47,7 +47,7 @@ class service protected $phpbb_root_path; /** - * PHP extension. + * PHP file extension. * * @var string */ @@ -60,7 +60,7 @@ class service * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db Database connection * @param string $phpbb_root_path Root path - * @param string $php_ext PHP extension + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\cache\driver\driver_interface $driver, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext) { @@ -168,18 +168,12 @@ class service { if ($row['rank_special']) { - $ranks['special'][$row['rank_id']] = array( - 'rank_title' => $row['rank_title'], - 'rank_image' => $row['rank_image'] - ); + unset($row['rank_min']); + $ranks['special'][$row['rank_id']] = $row; } else { - $ranks['normal'][] = array( - 'rank_title' => $row['rank_title'], - 'rank_min' => $row['rank_min'], - 'rank_image' => $row['rank_image'] - ); + $ranks['normal'][$row['rank_id']] = $row; } } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/composer.json b/phpBB/phpbb/composer.json new file mode 100644 index 0000000000..513d7e4559 --- /dev/null +++ b/phpBB/phpbb/composer.json @@ -0,0 +1,27 @@ +{ + "name": "phpbb/phpbb-core", + "description": "Collection of core phpBB libraries", + "type": "library", + "keywords": ["phpbb", "forum"], + "homepage": "https://www.phpbb.com", + "license": "GPL-2.0", + "authors": [ + { + "name": "phpBB Limited", + "email": "operations@phpbb.com", + "homepage": "https://www.phpbb.com/go/authors" + } + ], + "support": { + "issues": "https://tracker.phpbb.com", + "forum": "https://www.phpbb.com/community/", + "wiki": "https://wiki.phpbb.com", + "irc": "irc://irc.freenode.org/phpbb" + }, + "autoload": { + "classmap": [""] + }, + "require": { + "php": ">=5.3.3" + } +} 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/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php index 0c25075ce8..b4d7438b66 100644 --- a/phpBB/phpbb/console/command/config/increment.php +++ b/phpBB/phpbb/console/command/config/increment.php @@ -41,7 +41,7 @@ class increment extends command 'dynamic', 'd', InputOption::VALUE_NONE, - $this->user-lang('CLI_CONFIG_CANNOT_CACHED') + $this->user->lang('CLI_CONFIG_CANNOT_CACHED') ) ; } diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index cca4975aa6..59ff11e9b7 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -40,12 +40,12 @@ class enable extends command if ($this->manager->is_enabled($name)) { $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); - $output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name) . '</error>'); + $output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name) . '</info>'); return 0; } else { - $output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name) . '</info>'); + $output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name) . '</error>'); return 1; } } diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 1f50032f26..8bd537586e 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -38,6 +38,12 @@ class content_visibility protected $auth; /** + * config object + * @var \phpbb\config\config + */ + protected $config; + + /** * phpBB root path * @var string */ @@ -53,6 +59,7 @@ class content_visibility * Constructor * * @param \phpbb\auth\auth $auth Auth object + * @param \phpbb\config\config $config Config object * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\user $user User object * @param string $phpbb_root_path Root path @@ -62,9 +69,10 @@ class content_visibility * @param string $topics_table Topics table name * @param string $users_table Users table name */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) { $this->auth = $auth; + $this->config = $config; $this->db = $db; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; @@ -562,7 +570,7 @@ class content_visibility * Add post to topic and forum statistics * * @param $data array Contains information from the topics table about given topic - * @param $sql_data array Populated with the SQL changes, may be empty at call time + * @param &$sql_data array Populated with the SQL changes, may be empty at call time * @return null */ public function add_post_to_statistic($data, &$sql_data) @@ -576,90 +584,68 @@ class content_visibility $sql_data[$this->users_table] = (($sql_data[$this->users_table]) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts + 1'; } - set_config_count('num_posts', 1, true); + $this->config->increment('num_posts', 1, false); } /** * Remove post from topic and forum statistics * * @param $data array Contains information from the topics table about given topic - * @param $sql_data array Populated with the SQL changes, may be empty at call time + * @param &$sql_data array Populated with the SQL changes, may be empty at call time * @return null */ public function remove_post_from_statistic($data, &$sql_data) { - $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1'; - $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1'; + if ($data['post_visibility'] == ITEM_APPROVED) + { + $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1'; + $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1'; - if ($data['post_postcount']) + if ($data['post_postcount']) + { + $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; + } + + $this->config->increment('num_posts', -1, false); + } + else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) { - $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; + $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1'; + $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1'; + } + else if ($data['post_visibility'] == ITEM_DELETED) + { + $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_softdeleted = forum_posts_softdeleted - 1'; + $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_softdeleted = topic_posts_softdeleted - 1'; } - - set_config_count('num_posts', -1, true); } /** * Remove topic from forum statistics * - * @param $topic_id int The topic to act on - * @param $forum_id int Forum where the topic is found - * @param $topic_row array Contains information from the topic, may be empty at call time - * @param $sql_data array Populated with the SQL changes, may be empty at call time + * @param $data array Post and topic data + * @param &$sql_data array Populated with the SQL changes, may be empty at call time * @return null */ - public function remove_topic_from_statistic($topic_id, $forum_id, &$topic_row, &$sql_data) + public function remove_topic_from_statistic($data, &$sql_data) { - // Do we need to grab some topic informations? - if (!sizeof($topic_row)) + if ($data['topic_visibility'] == ITEM_APPROVED) { - $sql = 'SELECT topic_type, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_visibility - FROM ' . $this->topics_table . ' - WHERE topic_id = ' . (int) $topic_id; - $result = $this->db->sql_query($sql); - $topic_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - } + $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; - // If this is an edited topic or the first post the topic gets completely disapproved later on... - $sql_data[$this->forums_table] = (($sql_data[$this->forums_table]) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_topics_approved = forum_topics_approved - 1'; - $sql_data[$this->forums_table] .= ', forum_posts_approved = forum_posts_approved - ' . $topic_row['topic_posts_approved']; - $sql_data[$this->forums_table] .= ', forum_posts_unapproved = forum_posts_unapproved - ' . $topic_row['topic_posts_unapproved']; - $sql_data[$this->forums_table] .= ', forum_posts_softdeleted = forum_posts_softdeleted - ' . $topic_row['topic_posts_softdeleted']; - - set_config_count('num_topics', -1, true); - set_config_count('num_posts', $topic_row['topic_posts_approved'] * (-1), true); - - // Get user post count information - $sql = 'SELECT poster_id, COUNT(post_id) AS num_posts - FROM ' . $this->posts_table . ' - WHERE topic_id = ' . (int) $topic_id . ' - AND post_postcount = 1 - AND post_visibility = ' . ITEM_APPROVED . ' - GROUP BY poster_id'; - $result = $this->db->sql_query($sql); - - $postcounts = array(); - while ($row = $this->db->sql_fetchrow($result)) + if ($data['post_postcount']) + { + $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; + } + } + else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) { - $postcounts[(int) $row['num_posts']][] = (int) $row['poster_id']; + $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; } - $this->db->sql_freeresult($result); - - // Decrement users post count - foreach ($postcounts as $num_posts => $poster_ids) + else if ($data['topic_visibility'] == ITEM_DELETED) { - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = 0 - WHERE user_posts < ' . $num_posts . ' - AND ' . $this->db->sql_in_set('user_id', $poster_ids); - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = user_posts - ' . $num_posts . ' - WHERE user_posts >= ' . $num_posts . ' - AND ' . $this->db->sql_in_set('user_id', $poster_ids); - $this->db->sql_query($sql); + $sql_data[FORUMS_TABLE] .= 'forum_posts_softdeleted = forum_posts_softdeleted - 1, forum_topics_softdeleted = forum_topics_softdeleted - 1'; } + } } diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index e330fb5b6d..dd89d0504a 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -50,7 +50,7 @@ class helper protected $phpbb_root_path; /** - * PHP extension + * PHP file extension * @var string */ protected $php_ext; @@ -65,7 +65,7 @@ class helper * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object * @param string $phpbb_root_path phpBB root path - * @param string $php_ext PHP extension + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext) { @@ -82,9 +82,11 @@ class helper /** * Automate setting up the page and creating the response object. * - * @param string $handle The template handle to render + * @param string $template_file The template handle to render * @param string $page_title The title of the page to output * @param int $status_code The status code to be sent to the page header + * @param bool $display_online_list Do we display online users list + * * @return Response object containing rendered page */ public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false) 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/cron/manager.php b/phpBB/phpbb/cron/manager.php index b0601e641a..5c8ac04b77 100644 --- a/phpBB/phpbb/cron/manager.php +++ b/phpBB/phpbb/cron/manager.php @@ -35,6 +35,8 @@ class manager * Constructor. Loads all available tasks. * * @param array|\Traversable $tasks Provides an iterable set of task names + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP file extension */ public function __construct($tasks, $phpbb_root_path, $php_ext) { diff --git a/phpBB/phpbb/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php index 032ba1d2cc..b47939ccbe 100644 --- a/phpBB/phpbb/cron/task/core/prune_all_forums.php +++ b/phpBB/phpbb/cron/task/core/prune_all_forums.php @@ -31,7 +31,7 @@ class prune_all_forums extends \phpbb\cron\task\base * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext The PHP file extension * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db The db connection */ diff --git a/phpBB/phpbb/cron/task/core/prune_forum.php b/phpBB/phpbb/cron/task/core/prune_forum.php index 8da0048baa..ba68565197 100644 --- a/phpBB/phpbb/cron/task/core/prune_forum.php +++ b/phpBB/phpbb/cron/task/core/prune_forum.php @@ -41,7 +41,7 @@ class prune_forum extends \phpbb\cron\task\base implements \phpbb\cron\task\para * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext PHP file extension * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db The db connection */ diff --git a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php index 83a2460454..97a4b0ea86 100644 --- a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php +++ b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php @@ -43,7 +43,7 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext PHP file extension * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db The db connection * @param \phpbb\log\log $log The phpBB log system diff --git a/phpBB/phpbb/cron/task/core/queue.php b/phpBB/phpbb/cron/task/core/queue.php index 553e424bd0..796a96d7f5 100644 --- a/phpBB/phpbb/cron/task/core/queue.php +++ b/phpBB/phpbb/cron/task/core/queue.php @@ -26,7 +26,7 @@ class queue extends \phpbb\cron\task\base * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext PHP file extension * @param \phpbb\config\config $config The config */ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config) diff --git a/phpBB/phpbb/cron/task/core/tidy_database.php b/phpBB/phpbb/cron/task/core/tidy_database.php index ec058b4a50..949bba8012 100644 --- a/phpBB/phpbb/cron/task/core/tidy_database.php +++ b/phpBB/phpbb/cron/task/core/tidy_database.php @@ -26,7 +26,7 @@ class tidy_database extends \phpbb\cron\task\base * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext The PHP file extension * @param \phpbb\config\config $config The config */ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config) diff --git a/phpBB/phpbb/cron/task/core/tidy_search.php b/phpBB/phpbb/cron/task/core/tidy_search.php index 2c30274dfa..ce16b3f988 100644 --- a/phpBB/phpbb/cron/task/core/tidy_search.php +++ b/phpBB/phpbb/cron/task/core/tidy_search.php @@ -31,7 +31,7 @@ class tidy_search extends \phpbb\cron\task\base * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext The PHP file extension * @param \phpbb\auth\auth $auth The auth * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db The db connection diff --git a/phpBB/phpbb/cron/task/core/tidy_warnings.php b/phpBB/phpbb/cron/task/core/tidy_warnings.php index 058288222c..7b67eae6ef 100644 --- a/phpBB/phpbb/cron/task/core/tidy_warnings.php +++ b/phpBB/phpbb/cron/task/core/tidy_warnings.php @@ -28,7 +28,7 @@ class tidy_warnings extends \phpbb\cron\task\base * Constructor. * * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension + * @param string $php_ext PHP file extension * @param \phpbb\config\config $config The config */ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config) diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index 11399282d3..8a4a8b1f0c 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -29,6 +29,8 @@ class wrapper * Wraps a task $task, which must implement cron_task interface. * * @param \phpbb\cron\task\task $task The cron task to wrap. + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext) { diff --git a/phpBB/phpbb/datetime.php b/phpBB/phpbb/datetime.php index 9c9292a8e4..e674707883 100644 --- a/phpBB/phpbb/datetime.php +++ b/phpBB/phpbb/datetime.php @@ -38,9 +38,9 @@ class datetime extends \DateTime * Constructs a new instance of \phpbb\datetime, expanded to include an argument to inject * the user context and modify the timezone to the users selected timezone if one is not set. * + * @param user $user object for context. * @param string $time String in a format accepted by strtotime(). * @param \DateTimeZone $timezone Time zone of the time. - * @param user $user object for context. */ public function __construct($user, $time = 'now', \DateTimeZone $timezone = null) { diff --git a/phpBB/phpbb/db/migration/data/v310/rename_too_long_indexes.php b/phpBB/phpbb/db/migration/data/v310/rename_too_long_indexes.php new file mode 100644 index 0000000000..8d2a15d8ea --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/rename_too_long_indexes.php @@ -0,0 +1,38 @@ +<?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\v310; + +class rename_too_long_indexes extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array('\phpbb\db\migration\data\v30x\release_3_0_0'); + } + + public function update_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'search_wordmatch' => array( + 'unq_mtch', + ), + ), + 'add_unique_index' => array( + $this->table_prefix . 'search_wordmatch' => array( + 'un_mtch' => array('word_id', 'post_id', 'title_match'), + ), + ), + ); + } +} 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/migration/data/v310/topic_sort_username.php b/phpBB/phpbb/db/migration/data/v310/topic_sort_username.php new file mode 100644 index 0000000000..527da20590 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/topic_sort_username.php @@ -0,0 +1,44 @@ +<?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\v310; + +class topic_sort_username extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\dev'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'topics' => array( + 'topic_first_poster_name' => array('VCHAR_UNI:255', '', 'true_sort'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'topics' => array( + 'topic_first_poster_name' => array('VCHAR_UNI:255', ''), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index d2df27613a..5cfbc5ca00 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -105,6 +105,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface * @param string $auth_option The name of the permission (auth) option * @param bool $global True for checking a global permission setting, * False for a local permission setting + * @param int|false $copy_from If set, contains the id of the permission from which to copy the new one. * @return null */ public function add($auth_option, $global = true, $copy_from = false) @@ -243,7 +244,9 @@ class permission implements \phpbb\db\migration\tool\tool_interface * Add a new permission role * * @param string $role_name The new role name - * @param sting $role_type The type (u_, m_, a_) + * @param string $role_type The type (u_, m_, a_) + * @param string $role_description Description of the new role + * * @return null */ public function role_add($role_name, $role_type, $role_description = '') diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index ae0c695aa2..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': @@ -2104,7 +2105,7 @@ class tools $statements = array(); $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) - if (strlen($table_name . $index_name) - strlen($table_prefix) > 24) + if (strlen($table_name . '_' . $index_name) - strlen($table_prefix) > 24) { $max_length = strlen($table_prefix) + 24; trigger_error("Index name '{$table_name}_$index_name' on table '$table_name' is too long. The maximum is $max_length characters.", E_USER_ERROR); @@ -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/event/kernel_request_subscriber.php b/phpBB/phpbb/event/kernel_request_subscriber.php index 323dabb84c..ee9f29a59d 100644 --- a/phpBB/phpbb/event/kernel_request_subscriber.php +++ b/phpBB/phpbb/event/kernel_request_subscriber.php @@ -28,7 +28,7 @@ class kernel_request_subscriber implements EventSubscriberInterface protected $manager; /** - * PHP extension + * PHP file extension * @var string */ protected $php_ext; @@ -44,7 +44,7 @@ class kernel_request_subscriber implements EventSubscriberInterface * * @param \phpbb\extension\manager $manager Extension manager object * @param string $root_path Root path - * @param string $php_ext PHP extension + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\extension\manager $manager, $root_path, $php_ext) { diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index cbbd7bc622..288fb7d19c 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -40,6 +40,7 @@ class base implements \phpbb\extension\extension_interface * * @param ContainerInterface $container Container object * @param \phpbb\finder $extension_finder + * @param \phpbb\db\migrator $migrator * @param string $extension_name Name of this extension (from ext.manager) * @param string $extension_path Relative path to this extension */ @@ -54,6 +55,14 @@ class base implements \phpbb\extension\extension_interface } /** + * {@inheritdoc} + */ + public function is_enableable() + { + return true; + } + + /** * Single enable step that installs any included migrations * * @param mixed $old_state State returned by previous call of this method diff --git a/phpBB/phpbb/extension/extension_interface.php b/phpBB/phpbb/extension/extension_interface.php index cc8b8be980..6a6b6adb8f 100644 --- a/phpBB/phpbb/extension/extension_interface.php +++ b/phpBB/phpbb/extension/extension_interface.php @@ -20,6 +20,13 @@ namespace phpbb\extension; interface extension_interface { /** + * Indicate whether or not the extension can be enabled. + * + * @return bool + */ + public function is_enableable(); + + /** * enable_step is executed on enabling an extension until it returns false. * * Calls to this function can be made in subsequent requests, when the diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 4a12e9ec8c..76f0e3558e 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -178,6 +178,12 @@ class manager $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; $extension = $this->get_extension($name); + + if (!$extension->is_enableable()) + { + return false; + } + $state = $extension->enable_step($old_state); $active = ($state === false); 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/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php index 9741b752af..198134cdcf 100644 --- a/phpBB/phpbb/feed/helper.php +++ b/phpBB/phpbb/feed/helper.php @@ -36,7 +36,7 @@ class helper * @param \phpbb\config\config $config Config object * @param \phpbb\user $user User object * @param string $phpbb_root_path Root path - * @param string $phpEx PHP extension + * @param string $phpEx PHP file extension */ public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path, $phpEx) { diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index c522c3273f..2af8b50b54 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -245,9 +245,9 @@ class log implements \phpbb\log\log_interface break; case 'mod': - $forum_id = (int) $additional_data['forum_id']; + $forum_id = isset($additional_data['forum_id']) ? (int) $additional_data['forum_id'] : 0; unset($additional_data['forum_id']); - $topic_id = (int) $additional_data['topic_id']; + $topic_id = isset($additional_data['topic_id']) ? (int) $additional_data['topic_id'] : 0; unset($additional_data['topic_id']); $sql_ary += array( 'log_type' => LOG_MOD, diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 9c83e8dd73..f3ad7f5f41 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -20,7 +20,7 @@ class content_guesser extends guesser_base */ public function is_supported() { - return function_exists('mime_content_type'); + return function_exists('mime_content_type') && is_callable('mime_content_type'); } /** diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 87b164b561..773a1f822a 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -99,6 +99,7 @@ class guesser * Guess mimetype of supplied file * * @param string $file Path to file + * @param string $file_name The real file name * * @return string Guess for mimetype of file */ diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 74ef980445..5e4bab1530 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -68,12 +68,14 @@ class manager * @param \phpbb\user_loader $user_loader * @param \phpbb\config\config $config * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\cache\service $cache * @param \phpbb\user $user * @param string $phpbb_root_path * @param string $php_ext * @param string $notification_types_table * @param string $notifications_table * @param string $user_notifications_table + * * @return \phpbb\notification\manager */ public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) @@ -832,7 +834,7 @@ class manager * Delete all notifications older than a certain time * * @param int $timestamp Unix timestamp to delete all notifications that were created before - * @param bool $only_unread True (default) to only prune read notifications + * @param bool $only_read True (default) to only prune read notifications */ public function prune_notifications($timestamp, $only_read = true) { diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php index a6735dc793..22c9076adc 100644 --- a/phpBB/phpbb/notification/type/approve_post.php +++ b/phpBB/phpbb/notification/type/approve_post.php @@ -67,7 +67,8 @@ class approve_post extends \phpbb\notification\type\post /** * Find the users who want to receive notifications * - * @param array $post Data from + * @param array $post Data from submit_post + * @param array $options Options for finding users for notification * * @return array */ @@ -80,14 +81,7 @@ class approve_post extends \phpbb\notification\type\post $users = array(); $users[$post['poster_id']] = array(''); - $auth_read = $this->auth->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array( + return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array( 'item_type' => self::$notification_option['id'], ))); } diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php index 459a0ec348..77e53a0064 100644 --- a/phpBB/phpbb/notification/type/approve_topic.php +++ b/phpBB/phpbb/notification/type/approve_topic.php @@ -67,7 +67,8 @@ class approve_topic extends \phpbb\notification\type\topic /** * Find the users who want to receive notifications * - * @param array $post Data from + * @param array $post Data from submit_post + * @param array $options Options for finding users for notification * * @return array */ @@ -80,14 +81,7 @@ class approve_topic extends \phpbb\notification\type\topic $users = array(); $users[$post['poster_id']] = array(''); - $auth_read = $this->auth->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array( + return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array( 'item_type' => self::$notification_option['id'], ))); } diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 910f51b3a6..4ead06071e 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -161,6 +161,8 @@ abstract class base implements \phpbb\notification\type\type_interface * Magic method to set data on this notification * * @param mixed $name + * @param mixed $value + * * @return null */ public function __set($name, $value) @@ -174,7 +176,6 @@ abstract class base implements \phpbb\notification\type\type_interface * * Primarily for testing * - * @param string $name * @return mixed */ public function __toString() @@ -532,4 +533,37 @@ abstract class base implements \phpbb\notification\type\type_interface WHERE ' . $where; $this->db->sql_query($sql); } + + /** + * Get a list of users that are authorised to receive notifications + * + * @param array $users Array of users that have subscribed to a notification + * @param int $forum_id Forum ID of the forum + * @param array $options Array of notification options + * @param bool $sort Whether the users array should be sorted. Default: false + * @return array Array of users that are authorised recipients + */ + protected function get_authorised_recipients($users, $forum_id, $options, $sort = false) + { + if (empty($users)) + { + return array(); + } + + $users = array_unique($users); + + if ($sort) + { + sort($users); + } + + $auth_read = $this->auth->acl_get_list($users, 'f_read', $forum_id); + + if (empty($auth_read)) + { + return array(); + } + + return $this->check_user_notification_options($auth_read[$forum_id]['f_read'], $options); + } } diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php index f4870e8a52..21180b3b53 100644 --- a/phpBB/phpbb/notification/type/bookmark.php +++ b/phpBB/phpbb/notification/type/bookmark.php @@ -59,7 +59,8 @@ class bookmark extends \phpbb\notification\type\post /** * Find the users who want to receive notifications * - * @param array $post Data from + * @param array $post Data from submit_post + * @param array $options Options for finding users for notification * * @return array */ @@ -82,21 +83,13 @@ class bookmark extends \phpbb\notification\type\post } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } - sort($users); + $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); - $auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']); - - if (empty($auth_read)) + if (empty($notify_users)) { return array(); } - $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php index 4f54e93e06..8445ca4b22 100644 --- a/phpBB/phpbb/notification/type/pm.php +++ b/phpBB/phpbb/notification/type/pm.php @@ -72,7 +72,8 @@ class pm extends \phpbb\notification\type\base /** * Find the users who want to receive notifications * - * @param array $pm Data from + * @param array $pm Data from submit_pm + * @param array $options Options for finding users for notification * * @return array */ @@ -178,7 +179,7 @@ class pm extends \phpbb\notification\type\base * Function for preparing the data for insertion in an SQL query * (The service handles insertion) * - * @param array $post Data from submit_post + * @param array $pm Data from submit_post * @param array $pre_create_data Data from pre_create_insert_array() * * @return array Array of data ready to be inserted into the database diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index ee3a253e0f..1eba4a6a88 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -86,7 +86,8 @@ class post extends \phpbb\notification\type\base /** * Find the users who want to receive notifications * - * @param array $post Data from + * @param array $post Data from submit_post + * @param array $options Options for finding users for notification * * @return array */ @@ -122,23 +123,13 @@ class post extends \phpbb\notification\type\base } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } + $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); - $users = array_unique($users); - sort($users); - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']); - - if (empty($auth_read)) + if (empty($notify_users)) { return array(); } - $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* diff --git a/phpBB/phpbb/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php index b893ad0d15..3bb1028619 100644 --- a/phpBB/phpbb/notification/type/post_in_queue.php +++ b/phpBB/phpbb/notification/type/post_in_queue.php @@ -70,6 +70,7 @@ class post_in_queue extends \phpbb\notification\type\post * Find the users who want to receive notifications * * @param array $post Data from the post + * @param array $options Options for finding users for notification * * @return array */ diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index 7c61b76b58..5c3c822ec2 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -66,7 +66,8 @@ class quote extends \phpbb\notification\type\post /** * Find the users who want to receive notifications * - * @param array $post Data from + * @param array $post Data from submit_post + * @param array $options Options for finding users for notification * * @return array */ @@ -101,28 +102,13 @@ class quote extends \phpbb\notification\type\post } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } - sort($users); - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - - return $notify_users; + return $this->get_authorised_recipients($users, $post['forum_id'], $options, true); } /** * Update a notification * - * @param array $data Data specific for this type that will be updated + * @param array $post Data specific for this type that will be updated */ public function update_notifications($post) { diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php index 2eb802eb4b..14a328e104 100644 --- a/phpBB/phpbb/notification/type/report_pm.php +++ b/phpBB/phpbb/notification/type/report_pm.php @@ -94,6 +94,7 @@ class report_pm extends \phpbb\notification\type\pm * (copied from post_in_queue) * * @param array $post Data from the post + * @param array $options Options for finding users for notification * * @return array */ diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index ed40df67f3..de7bf74a97 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -52,7 +52,8 @@ class report_pm_closed extends \phpbb\notification\type\pm /** * Find the users who want to receive notifications * - * @param array $pm Data from + * @param array $pm Data from submit_pm + * @param array $options Options for finding users for notification * * @return array */ diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index 024c8d9d42..bec59df9d5 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -76,6 +76,7 @@ class report_post extends \phpbb\notification\type\post_in_queue * Find the users who want to receive notifications * * @param array $post Data from the post + * @param array $options Options for finding users for notification * * @return array */ diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index a979af1fb0..cd1400f8fa 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -59,7 +59,8 @@ class report_post_closed extends \phpbb\notification\type\post /** * Find the users who want to receive notifications * - * @param array $post Data from + * @param array $post Data from submit_post + * @param array $options Options for finding users for notification * * @return array */ diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index a512a12f20..af199fb765 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -87,6 +87,7 @@ class topic extends \phpbb\notification\type\base * Find the users who want to receive notifications * * @param array $topic Data from the topic + * @param array $options Options for finding users for notification * * @return array */ @@ -110,19 +111,7 @@ class topic extends \phpbb\notification\type\base } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $topic['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], $options); + return $this->get_authorised_recipients($users, $topic['forum_id'], $options); } /** diff --git a/phpBB/phpbb/notification/type/topic_in_queue.php b/phpBB/phpbb/notification/type/topic_in_queue.php index 2d54a68648..aef1487d77 100644 --- a/phpBB/phpbb/notification/type/topic_in_queue.php +++ b/phpBB/phpbb/notification/type/topic_in_queue.php @@ -70,6 +70,7 @@ class topic_in_queue extends \phpbb\notification\type\topic * Find the users who want to receive notifications * * @param array $topic Data from the topic + * @param array $options Options for finding users for notification * * @return array */ diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index a8592eac6c..38dbbab51e 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -46,7 +46,7 @@ class path_helper * @param \phpbb\filesystem $filesystem * @param \phpbb\request\request_interface $request * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP extension (php) + * @param string $php_ext PHP file extension * @param mixed $adm_relative_path Relative path admin path to adm/ root */ public function __construct(\phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, \phpbb\request\request_interface $request, $phpbb_root_path, $php_ext, $adm_relative_path = null) diff --git a/phpBB/phpbb/profilefields/type/type_googleplus.php b/phpBB/phpbb/profilefields/type/type_googleplus.php index df1bcc7f4b..887baa3de1 100644 --- a/phpBB/phpbb/profilefields/type/type_googleplus.php +++ b/phpBB/phpbb/profilefields/type/type_googleplus.php @@ -18,6 +18,14 @@ class type_googleplus extends type_string /** * {@inheritDoc} */ + public function get_name() + { + return $this->user->lang('FIELD_GOOGLEPLUS'); + } + + /** + * {@inheritDoc} + */ public function get_service_name() { return 'profilefields.type.googleplus'; diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index 2dd13fa480..ec770f9467 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -189,8 +189,8 @@ interface type_interface /** * Allows manipulating the intended variables if needed * - * @param string $key Name of the option * @param int $step Step on which the option is hidden + * @param string $key Name of the option * @param string $action Currently performed action (create|edit) * @param array $field_data Array with data for this field * @return mixed Final value of the option diff --git a/phpBB/phpbb/search/base.php b/phpBB/phpbb/search/base.php index 9395b6a273..30781975d8 100644 --- a/phpBB/phpbb/search/base.php +++ b/phpBB/phpbb/search/base.php @@ -85,8 +85,12 @@ class base /** * Retrieves cached search results * - * @param int &$result_count will contain the number of all results for the search (not only for the current page) - * @param array &$id_ary is filled with the ids belonging to the requested page that are stored in the cache + * @param string $search_key an md5 string generated from all the passed search options to identify the results + * @param int &$result_count will contain the number of all results for the search (not only for the current page) + * @param array &$id_ary is filled with the ids belonging to the requested page that are stored in the cache + * @param int &$start indicates the first index of the page + * @param int $per_page number of ids each page is supposed to contain + * @param string $sort_dir is either a or d representing ASC and DESC * * @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE */ @@ -160,8 +164,16 @@ class base /** * Caches post/topic ids * - * @param array &$id_ary contains a list of post or topic ids that shall be cached, the first element + * @param string $search_key an md5 string generated from all the passed search options to identify the results + * @param string $keywords contains the keywords as entered by the user + * @param array $author_ary an array of author ids, if the author should be ignored during the search the array is empty + * @param int $result_count contains the number of all results for the search (not only for the current page) + * @param array &$id_ary contains a list of post or topic ids that shall be cached, the first element * must have the absolute index $start in the result set. + * @param int $start indicates the first index of the page + * @param string $sort_dir is either a or d representing ASC and DESC + * + * @return null */ function save_ids($search_key, $keywords, $author_ary, $result_count, &$id_ary, $start, $sort_dir) { diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index d4e7de31e5..1a0aba096f 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -73,6 +73,12 @@ class fulltext_mysql extends \phpbb\search\base * Creates a new \phpbb\search\fulltext_mysql, which is used as a search backend * * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $phpEx PHP file extension + * @param \phpbb\auth\auth $auth Auth object + * @param \phpbb\config\config $config Config object + * @param \phpbb\db\driver\driver_interface Database object + * @param \phpbb\user $user User object */ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) { diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index b3e7f51f87..b6af371d13 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -86,6 +86,12 @@ class fulltext_postgres extends \phpbb\search\base * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend * * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $phpEx PHP file extension + * @param \phpbb\auth\auth $auth Auth object + * @param \phpbb\config\config $config Config object + * @param \phpbb\db\driver\driver_interface Database object + * @param \phpbb\user $user User object */ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) { diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index 78c11f1180..79d68d2ae1 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -119,6 +119,12 @@ class fulltext_sphinx * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend * * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $phpEx PHP file extension + * @param \phpbb\auth\auth $auth Auth object + * @param \phpbb\config\config $config Config object + * @param \phpbb\db\driver\driver_interface Database object + * @param \phpbb\user $user User object */ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) { diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 59b7ec2029..5a0d7c0031 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1062,11 +1062,13 @@ class session * Check for banned user * * Checks whether the supplied user is banned by id, ip or email. If no parameters - * are passed to the method pre-existing session data is used. If $return is false - * this routine does not return on finding a banned user, it outputs a relevant - * message and stops execution. + * are passed to the method pre-existing session data is used. * - * @param string|array $user_ips Can contain a string with one IP or an array of multiple IPs + * @param int|false $user_id The user id + * @param mixed $user_ips Can contain a string with one IP or an array of multiple IPs + * @param string|false $user_email The user email + * @param bool $return If $return is false this routine does not return on finding a banned user, + * it outputs a relevant message and stops execution. */ function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) { @@ -1254,12 +1256,14 @@ class session /** * Check if ip is blacklisted - * This should be called only where absolutly necessary + * This should be called only where absolutely necessary * * Only IPv4 (rbldns does not support AAAA records/IPv6 lookups) * * @author satmd (from the php manual) - * @param string $mode register/post - spamcop for example is ommitted for posting + * @param string $mode register/post - spamcop for example is ommitted for posting + * @param string|false $ip the IPv4 address to check + * * @return false if ip is not blacklisted, else an array([checked server], [lookup]) */ function check_dnsbl($mode, $ip = false) diff --git a/phpBB/phpbb/template/asset.php b/phpBB/phpbb/template/asset.php index 5a01ee3a93..67dbd7b357 100644 --- a/phpBB/phpbb/template/asset.php +++ b/phpBB/phpbb/template/asset.php @@ -24,6 +24,7 @@ class asset * Constructor * * @param string $url URL + * @param \phpbb\path_helper $path_helper Path helper object */ public function __construct($url, \phpbb\path_helper $path_helper) { diff --git a/phpBB/phpbb/template/twig/definition.php b/phpBB/phpbb/template/twig/definition.php index 39653f6d26..cb3c953692 100644 --- a/phpBB/phpbb/template/twig/definition.php +++ b/phpBB/phpbb/template/twig/definition.php @@ -25,6 +25,8 @@ class definition * Get a DEFINE'd variable * * @param string $name + * @param array $arguments + * * @return mixed Null if not found */ public function __call($name, $arguments) diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php index 8d25153e14..476ffd935e 100644 --- a/phpBB/phpbb/template/twig/environment.php +++ b/phpBB/phpbb/template/twig/environment.php @@ -36,11 +36,10 @@ class environment extends \Twig_Environment /** * Constructor * - * @param \phpbb\config\config $phpbb_config - * @param \phpbb\path_helper - * @param \phpbb\extension\manager - * @param string $phpbb_root_path - * @param \Twig_LoaderInterface $loader + * @param \phpbb\config\config $phpbb_config The phpBB configuration + * @param \phpbb\path_helper $path_helper phpBB path helper + * @param \phpbb\extension\manager $extension_manager phpBB extension manager + * @param \Twig_LoaderInterface $loader Twig loader interface * @param array $options Array of options to pass to Twig */ public function __construct($phpbb_config, \phpbb\path_helper $path_helper, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index 8f523684dd..3a983491b9 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -162,7 +162,6 @@ class extension extends \Twig_Extension * (e.g. in the ACP, L_TITLE) * If not, we return the result of $user->lang() * - * @param string $lang name * @return string */ function lang() diff --git a/phpBB/phpbb/tree/tree_interface.php b/phpBB/phpbb/tree/tree_interface.php index 8238a072ff..5df01a89cf 100644 --- a/phpBB/phpbb/tree/tree_interface.php +++ b/phpBB/phpbb/tree/tree_interface.php @@ -18,7 +18,7 @@ interface tree_interface /** * Inserts an item into the database table and into the tree. * - * @param array $item The item to be added + * @param array $additional_data The item to be added * @return array Array with item data as set in the database */ public function insert(array $additional_data); |