diff options
Diffstat (limited to 'phpBB/phpbb')
24 files changed, 373 insertions, 143 deletions
diff --git a/phpBB/phpbb/cache/driver/apc.php b/phpBB/phpbb/cache/driver/apc.php index a28d91c00a..77b7b11181 100644 --- a/phpBB/phpbb/cache/driver/apc.php +++ b/phpBB/phpbb/cache/driver/apc.php @@ -18,9 +18,7 @@ class apc extends \phpbb\cache\driver\memory var $extension = 'apc'; /** - * Purge cache data - * - * @return null + * {@inheritDoc} */ function purge() { diff --git a/phpBB/phpbb/cache/driver/driver_interface.php b/phpBB/phpbb/cache/driver/driver_interface.php index 0715a4b934..8444028115 100644 --- a/phpBB/phpbb/cache/driver/driver_interface.php +++ b/phpBB/phpbb/cache/driver/driver_interface.php @@ -18,46 +18,73 @@ interface driver_interface { /** * Load global cache + * + * @return mixed False if an error was encountered, otherwise the data type of the cached data */ public function load(); /** * Unload cache object + * + * @return null */ public function unload(); /** * Save modified objects + * + * @return null */ public function save(); /** * Tidy cache + * + * @return null */ public function tidy(); /** * Get saved cache object + * + * @param string $var_name Cache key + * @return mixed False if an error was encountered, otherwise the saved cached object */ public function get($var_name); /** * Put data into cache + * + * @param string $var_name Cache key + * @param mixed $var Cached data to store + * @param int $ttl Time-to-live of cached data + * @return null */ public function put($var_name, $var, $ttl = 0); /** * Purge cache data + * + * @return null */ public function purge(); /** * Destroy cache data + * + * @param string $var_name Cache key + * @param string $table Table name + * @return null */ public function destroy($var_name, $table = ''); /** * Check if a given cache entry exists + * + * @param string $var_name Cache key + * + * @return bool True if cache file exists and has not expired. + * False otherwise. */ public function _exists($var_name); diff --git a/phpBB/phpbb/cache/driver/eaccelerator.php b/phpBB/phpbb/cache/driver/eaccelerator.php index 2629cb53e5..d1ad69ef6d 100644 --- a/phpBB/phpbb/cache/driver/eaccelerator.php +++ b/phpBB/phpbb/cache/driver/eaccelerator.php @@ -22,9 +22,7 @@ class eaccelerator extends \phpbb\cache\driver\memory var $serialize_header = '#phpbb-serialized#'; /** - * Purge cache data - * - * @return null + * {@inheritDoc} */ function purge() { @@ -39,10 +37,8 @@ class eaccelerator extends \phpbb\cache\driver\memory } /** - * Perform cache garbage collection - * - * @return null - */ + * {@inheritDoc} + */ function tidy() { eaccelerator_gc(); diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 6686da6953..a57a805193 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -33,7 +33,7 @@ class file extends \phpbb\cache\driver\base } /** - * Load global cache + * {@inheritDoc} */ function load() { @@ -41,7 +41,7 @@ class file extends \phpbb\cache\driver\base } /** - * Unload cache object + * {@inheritDoc} */ function unload() { @@ -58,7 +58,7 @@ class file extends \phpbb\cache\driver\base } /** - * Save modified objects + * {@inheritDoc} */ function save() { @@ -93,7 +93,7 @@ class file extends \phpbb\cache\driver\base } /** - * Tidy cache + * {@inheritDoc} */ function tidy() { @@ -155,7 +155,7 @@ class file extends \phpbb\cache\driver\base } /** - * Get saved cache object + * {@inheritDoc} */ function get($var_name) { @@ -177,7 +177,7 @@ class file extends \phpbb\cache\driver\base } /** - * Put data into cache + * {@inheritDoc} */ function put($var_name, $var, $ttl = 31536000) { @@ -194,7 +194,7 @@ class file extends \phpbb\cache\driver\base } /** - * Purge cache data + * {@inheritDoc} */ function purge() { @@ -280,7 +280,7 @@ class file extends \phpbb\cache\driver\base } /** - * Destroy cache data + * {@inheritDoc} */ function destroy($var_name, $table = '') { @@ -359,7 +359,7 @@ class file extends \phpbb\cache\driver\base } /** - * Check if a given cache entry exist + * {@inheritDoc} */ function _exists($var_name) { @@ -385,7 +385,7 @@ class file extends \phpbb\cache\driver\base } /** - * Load cached sql query + * {@inheritDoc} */ function sql_load($query) { @@ -431,7 +431,7 @@ class file extends \phpbb\cache\driver\base } /** - * Ceck if a given sql query exist in cache + * {@inheritDoc} */ function sql_exists($query_id) { @@ -439,7 +439,7 @@ class file extends \phpbb\cache\driver\base } /** - * Fetch row from cache (database) + * {@inheritDoc} */ function sql_fetchrow($query_id) { @@ -452,7 +452,7 @@ class file extends \phpbb\cache\driver\base } /** - * Fetch a field from the current row of a cached database result (database) + * {@inheritDoc} */ function sql_fetchfield($query_id, $field) { @@ -465,7 +465,7 @@ class file extends \phpbb\cache\driver\base } /** - * Seek a specific row in an a cached database result (database) + * {@inheritDoc} */ function sql_rowseek($rownum, $query_id) { @@ -479,7 +479,7 @@ class file extends \phpbb\cache\driver\base } /** - * Free memory used for a cached database result (database) + * {@inheritDoc} */ function sql_freeresult($query_id) { @@ -758,6 +758,10 @@ class file extends \phpbb\cache\driver\base /** * 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) { diff --git a/phpBB/phpbb/cache/driver/memcache.php b/phpBB/phpbb/cache/driver/memcache.php index c725ec0fb0..eb3fced973 100644 --- a/phpBB/phpbb/cache/driver/memcache.php +++ b/phpBB/phpbb/cache/driver/memcache.php @@ -56,9 +56,7 @@ class memcache extends \phpbb\cache\driver\memory } /** - * Unload the cache resources - * - * @return null + * {@inheritDoc} */ function unload() { @@ -68,9 +66,7 @@ class memcache extends \phpbb\cache\driver\memory } /** - * Purge cache data - * - * @return null + * {@inheritDoc} */ function purge() { diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index 292024212b..b618b0f3e6 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -50,7 +50,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Load global cache + * {@inheritDoc} */ function load() { @@ -66,7 +66,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Unload cache object + * {@inheritDoc} */ function unload() { @@ -81,7 +81,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Save modified objects + * {@inheritDoc} */ function save() { @@ -96,7 +96,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Tidy cache + * {@inheritDoc} */ function tidy() { @@ -106,7 +106,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Get saved cache object + * {@inheritDoc} */ function get($var_name) { @@ -126,7 +126,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Put data into cache + * {@inheritDoc} */ function put($var_name, $var, $ttl = 2592000) { @@ -142,7 +142,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Purge cache data + * {@inheritDoc} */ function purge() { @@ -183,7 +183,7 @@ abstract class memory extends \phpbb\cache\driver\base /** - * Destroy cache data + * {@inheritDoc} */ function destroy($var_name, $table = '') { @@ -237,7 +237,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Check if a given cache entry exist + * {@inheritDoc} */ function _exists($var_name) { @@ -257,7 +257,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Load cached sql query + * {@inheritDoc} */ function sql_load($query) { @@ -335,7 +335,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Ceck if a given sql query exist in cache + * {@inheritDoc} */ function sql_exists($query_id) { @@ -343,7 +343,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Fetch row from cache (database) + * {@inheritDoc} */ function sql_fetchrow($query_id) { @@ -356,7 +356,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Fetch a field from the current row of a cached database result (database) + * {@inheritDoc} */ function sql_fetchfield($query_id, $field) { @@ -369,7 +369,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Seek a specific row in an a cached database result (database) + * {@inheritDoc} */ function sql_rowseek($rownum, $query_id) { @@ -383,7 +383,7 @@ abstract class memory extends \phpbb\cache\driver\base } /** - * Free memory used for a cached database result (database) + * {@inheritDoc} */ function sql_freeresult($query_id) { @@ -400,6 +400,10 @@ abstract class memory extends \phpbb\cache\driver\base /** * 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) { diff --git a/phpBB/phpbb/cache/driver/null.php b/phpBB/phpbb/cache/driver/null.php index ea535ca1e1..8af63eb725 100644 --- a/phpBB/phpbb/cache/driver/null.php +++ b/phpBB/phpbb/cache/driver/null.php @@ -23,7 +23,7 @@ class null extends \phpbb\cache\driver\base } /** - * Load global cache + * {@inheritDoc} */ function load() { @@ -31,21 +31,21 @@ class null extends \phpbb\cache\driver\base } /** - * Unload cache object + * {@inheritDoc} */ function unload() { } /** - * Save modified objects + * {@inheritDoc} */ function save() { } /** - * Tidy cache + * {@inheritDoc} */ function tidy() { @@ -54,7 +54,7 @@ class null extends \phpbb\cache\driver\base } /** - * Get saved cache object + * {@inheritDoc} */ function get($var_name) { @@ -62,28 +62,28 @@ class null extends \phpbb\cache\driver\base } /** - * Put data into cache + * {@inheritDoc} */ function put($var_name, $var, $ttl = 0) { } /** - * Purge cache data + * {@inheritDoc} */ function purge() { } /** - * Destroy cache data + * {@inheritDoc} */ function destroy($var_name, $table = '') { } /** - * Check if a given cache entry exist + * {@inheritDoc} */ function _exists($var_name) { @@ -91,7 +91,7 @@ class null extends \phpbb\cache\driver\base } /** - * Load cached sql query + * {@inheritDoc} */ function sql_load($query) { @@ -107,7 +107,7 @@ class null extends \phpbb\cache\driver\base } /** - * Ceck if a given sql query exist in cache + * {@inheritDoc} */ function sql_exists($query_id) { @@ -115,7 +115,7 @@ class null extends \phpbb\cache\driver\base } /** - * Fetch row from cache (database) + * {@inheritDoc} */ function sql_fetchrow($query_id) { @@ -123,7 +123,7 @@ class null extends \phpbb\cache\driver\base } /** - * Fetch a field from the current row of a cached database result (database) + * {@inheritDoc} */ function sql_fetchfield($query_id, $field) { @@ -131,7 +131,7 @@ class null extends \phpbb\cache\driver\base } /** - * Seek a specific row in an a cached database result (database) + * {@inheritDoc} */ function sql_rowseek($rownum, $query_id) { @@ -139,7 +139,7 @@ class null extends \phpbb\cache\driver\base } /** - * Free memory used for a cached database result (database) + * {@inheritDoc} */ function sql_freeresult($query_id) { diff --git a/phpBB/phpbb/cache/driver/redis.php b/phpBB/phpbb/cache/driver/redis.php index 2b6f9bf36d..2f2a32a12d 100644 --- a/phpBB/phpbb/cache/driver/redis.php +++ b/phpBB/phpbb/cache/driver/redis.php @@ -92,9 +92,7 @@ class redis extends \phpbb\cache\driver\memory } /** - * Unload the cache resources - * - * @return null + * {@inheritDoc} */ function unload() { @@ -104,9 +102,7 @@ class redis extends \phpbb\cache\driver\memory } /** - * Purge cache data - * - * @return null + * {@inheritDoc} */ function purge() { diff --git a/phpBB/phpbb/cache/driver/wincache.php b/phpBB/phpbb/cache/driver/wincache.php index 1f040e9ab2..d0f636d9cb 100644 --- a/phpBB/phpbb/cache/driver/wincache.php +++ b/phpBB/phpbb/cache/driver/wincache.php @@ -18,9 +18,7 @@ class wincache extends \phpbb\cache\driver\memory var $extension = 'wincache'; /** - * Purge cache data - * - * @return null + * {@inheritDoc} */ function purge() { diff --git a/phpBB/phpbb/cache/driver/xcache.php b/phpBB/phpbb/cache/driver/xcache.php index 4d0d683b3d..6c9323ec83 100644 --- a/phpBB/phpbb/cache/driver/xcache.php +++ b/phpBB/phpbb/cache/driver/xcache.php @@ -33,9 +33,7 @@ class xcache extends \phpbb\cache\driver\memory } /** - * Purge cache data - * - * @return null + * {@inheritDoc} */ function purge() { diff --git a/phpBB/phpbb/class_loader.php b/phpBB/phpbb/class_loader.php index 37b62fff24..ee9767148b 100644 --- a/phpBB/phpbb/class_loader.php +++ b/phpBB/phpbb/class_loader.php @@ -142,7 +142,13 @@ class class_loader */ public function load_class($class) { - $class = '\\' . $class; + // In general $class is not supposed to contain a leading backslash, + // but sometimes it does. See tickets PHP-50731 and HHVM-1840. + if ($class[0] !== '\\') + { + $class = '\\' . $class; + } + if (substr($class, 0, strlen($this->namespace)) === $this->namespace) { $path = $this->resolve_path($class); diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 10fdbb1375..54c30c93fc 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -77,9 +77,9 @@ class helper * @param int $status_code The status code to be sent to the page header * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200) + public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false) { - page_header($page_title); + page_header($page_title, $display_online_list); $this->template->set_filenames(array( 'body' => $template_file, diff --git a/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php new file mode 100644 index 0000000000..ab5b1a535b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php @@ -0,0 +1,77 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class acp_prune_users_module extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_CAT_USERS'"; + $result = $this->db->sql_query($sql); + $acp_cat_users_id = (int) $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + $sql = 'SELECT parent_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_basename = 'acp_prune' + AND module_mode = 'users'"; + $result = $this->db->sql_query($sql); + $acp_prune_users_parent = (int) $this->db->sql_fetchfield('parent_id'); + $this->db->sql_freeresult($result); + + // Skip migration if "Users" category has been deleted + // or the module has already been moved to that category + return !$acp_cat_users_id || $acp_cat_users_id === $acp_prune_users_parent; + } + + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\beta1'); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'move_prune_users_module'))), + ); + } + + public function move_prune_users_module() + { + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_basename = 'acp_prune' + AND module_mode = 'users'"; + $result = $this->db->sql_query($sql); + $acp_prune_users_id = (int) $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_CAT_USERS'"; + $result = $this->db->sql_query($sql); + $acp_cat_users_id = (int) $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + if (!class_exists('\acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); + } + $module_manager = new \acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($acp_prune_users_id, $acp_cat_users_id); + } +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_location_cleanup.php b/phpBB/phpbb/db/migration/data/v310/profilefield_location_cleanup.php new file mode 100644 index 0000000000..54ff2a31eb --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_location_cleanup.php @@ -0,0 +1,47 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_location_cleanup extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_from'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_location', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_from', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_from' => array('VCHAR_UNI:100', ''), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 3a7207e743..8631c11d0e 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -467,9 +467,6 @@ class tools // Determine if we have created a PRIMARY KEY in the earliest $primary_key_gen = false; - // Determine if the table must be created with TEXTIMAGE - $create_textimage = false; - // Determine if the table requires a sequence $create_sequence = false; @@ -486,6 +483,15 @@ class tools break; } + if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative') + { + if (!isset($table_data['PRIMARY_KEY'])) + { + $table_data['COLUMNS']['mssqlindex'] = array('UINT', null, 'auto_increment'); + $table_data['PRIMARY_KEY'] = 'mssqlindex'; + } + } + // Iterate through the columns to create a table foreach ($table_data['COLUMNS'] as $column_name => $column_data) { @@ -516,12 +522,6 @@ class tools $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; } - // create textimage DDL based off of the existance of certain column types - if (!$create_textimage) - { - $create_textimage = isset($prepared_column['textimage']) && $prepared_column['textimage']; - } - // create sequence DDL based off of the existance of auto incrementing columns if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) { @@ -536,13 +536,9 @@ class tools switch ($this->sql_layer) { case 'firebird': - $table_sql .= "\n);"; - $statements[] = $table_sql; - break; - case 'mssql': case 'mssqlnative': - $table_sql .= "\n) ON [PRIMARY]" . (($create_textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : ''); + $table_sql .= "\n);"; $statements[] = $table_sql; break; } @@ -1850,22 +1846,49 @@ class tools case 'mssql': case 'mssqlnative': - // remove default cosntraints first - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) - SET @drop_default_name = - (SELECT so.name FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')) - IF @drop_default_name <> '' - BEGIN - SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' - EXEC(@cmd) - END"; + $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // Remove default constraints + if ($row['mssql_version'][0] == '8') // SQL Server 2000 + { + // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx + // Deprecated in SQL Server 2005 + $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) + SET @drop_default_name = + (SELECT so.name FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')) + IF @drop_default_name <> '' + BEGIN + SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' + EXEC(@cmd) + END"; + } + else + { + $sql = "SELECT dobj.name AS def_name + FROM sys.columns col + LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') + WHERE col.object_id = object_id('{$table_name}') + AND col.name = '{$column_name}' + AND dobj.name IS NOT NULL"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; + } + } + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; @@ -2069,7 +2092,7 @@ class tools $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; $sql .= '[' . implode("],\n\t\t[", $column) . ']'; - $sql .= ') ON [PRIMARY]'; + $sql .= ')'; $statements[] = $sql; break; @@ -2167,7 +2190,7 @@ class tools case 'mssql': case 'mssqlnative': - $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; + $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; } @@ -2220,7 +2243,7 @@ class tools case 'mssql': case 'mssqlnative': - $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; + $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; } @@ -2352,23 +2375,48 @@ class tools if (!empty($column_data['default'])) { + $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + // Using TRANSACT-SQL for this statement because we do not want to have colliding data if statements are executed at a later stage - $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) - SET @drop_default_name = - (SELECT so.name FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')) - IF @drop_default_name <> '' - BEGIN - SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' - EXEC(@cmd) - END - SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' - EXEC(@cmd)"; + if ($row['mssql_version'][0] == '8') // SQL Server 2000 + { + $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) + SET @drop_default_name = + (SELECT so.name FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')) + IF @drop_default_name <> '' + BEGIN + SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' + EXEC(@cmd) + END + SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' + EXEC(@cmd)"; + } + else + { + $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) + SET @drop_default_name = + (SELECT dobj.name FROM sys.columns col + LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') + WHERE col.object_id = object_id('{$table_name}') + AND col.name = '{$column_name}' + AND dobj.name IS NOT NULL) + IF @drop_default_name <> '' + BEGIN + SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' + EXEC(@cmd) + END + SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' + EXEC(@cmd)"; + } } break; diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/extension/finder.php index c9c16ae6d5..6cc6e1808a 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -475,14 +475,19 @@ class finder } $directory_pattern = '#' . $directory_pattern . '#'; - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST); + $iterator = new \RecursiveIteratorIterator( + new \phpbb\recursive_dot_prefix_filter_iterator( + new \RecursiveDirectoryIterator( + $path, + \FilesystemIterator::SKIP_DOTS + ) + ), + \RecursiveIteratorIterator::SELF_FIRST + ); + foreach ($iterator as $file_info) { $filename = $file_info->getFilename(); - if ($filename == '.' || $filename == '..') - { - continue; - } if ($file_info->isDir() == $is_dir) { diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php index 66cdb86513..c90445ee09 100644 --- a/phpBB/phpbb/extension/metadata_manager.php +++ b/phpBB/phpbb/extension/metadata_manager.php @@ -196,7 +196,7 @@ class metadata_manager $fields = array( 'name' => '#^[a-zA-Z0-9_\x7f-\xff]{2,}/[a-zA-Z0-9_\x7f-\xff]{2,}$#', 'type' => '#^phpbb-extension$#', - 'licence' => '#.+#', + 'license' => '#.+#', 'version' => '#.+#', ); @@ -351,7 +351,7 @@ class metadata_manager 'META_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '', 'META_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '', 'META_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '', - 'META_LICENCE' => htmlspecialchars($this->metadata['licence']), + 'META_LICENSE' => htmlspecialchars($this->metadata['license']), 'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '', 'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(), diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 62edc6a77f..68b023e244 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -308,7 +308,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - extract($this->dispatcher->trigger_event('core.add_log', $vars)); + extract($this->dispatcher->trigger_event('core.add_log', compact($vars))); // We didn't find a log_type, so we don't save it in the database. if (!isset($sql_ary['log_type'])) @@ -406,7 +406,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - extract($this->dispatcher->trigger_event('core.get_logs_modify_type', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_modify_type', compact($vars))); if ($log_type === false) { @@ -502,7 +502,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('row', 'log_entry_data'); - extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', compact($vars))); $log[$i] = $log_entry_data; @@ -561,7 +561,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list'); - extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', compact($vars))); if (sizeof($topic_id_list)) { diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php index 5e6fdd2523..003998677d 100644 --- a/phpBB/phpbb/notification/type/bookmark.php +++ b/phpBB/phpbb/notification/type/bookmark.php @@ -75,7 +75,7 @@ class bookmark extends \phpbb\notification\type\post $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $users[] = $row['user_id']; + $users[] = (int) $row['user_id']; } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 140c0ad82a..f973becc3b 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -103,7 +103,7 @@ class post extends \phpbb\notification\type\base $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $users[] = $row['user_id']; + $users[] = (int) $row['user_id']; } $this->db->sql_freeresult($result); @@ -115,7 +115,7 @@ class post extends \phpbb\notification\type\base $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $users[] = $row['user_id']; + $users[] = (int) $row['user_id']; } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index e8527261d8..745430e114 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -94,7 +94,7 @@ class quote extends \phpbb\notification\type\post $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $users[] = $row['user_id']; + $users[] = (int) $row['user_id']; } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 98f086a50b..635d05bccd 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -103,7 +103,7 @@ class topic extends \phpbb\notification\type\base $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $users[] = $row['user_id']; + $users[] = (int) $row['user_id']; } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php b/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php new file mode 100644 index 0000000000..6ef63ec906 --- /dev/null +++ b/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package extension +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb; + +/** +* Class recursive_dot_prefix_filter_iterator +* +* This filter ignores directories starting with a dot. +* When searching for php classes and template files of extensions +* we don't need to look inside these directories. +* +* @package phpbb +*/ +class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator +{ + public function accept() + { + $filename = $this->current()->getFilename(); + return !$this->current()->isDir() || $filename[0] !== '.'; + } +} diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 6c060e21ea..b9b3896606 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -631,18 +631,20 @@ class user extends \phpbb\session else if ($this->lang_name == basename($config['default_lang'])) { // Fall back to the English Language + $reset_lang_name = $this->lang_name; $this->lang_name = 'en'; $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name); + $this->lang_name = $reset_lang_name; } else if ($this->lang_name == $this->data['user_lang']) { // Fall back to the board default language + $reset_lang_name = $this->lang_name; $this->lang_name = basename($config['default_lang']); $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name); + $this->lang_name = $reset_lang_name; } - // Reset the lang name - $this->lang_name = (file_exists($lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); return; } |