diff options
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/cache/driver/file.php | 4 | ||||
| -rw-r--r-- | phpBB/phpbb/cache/service.php | 12 | ||||
| -rw-r--r-- | phpBB/phpbb/composer.json | 27 | ||||
| -rw-r--r-- | phpBB/phpbb/content_visibility.php | 41 | ||||
| -rw-r--r-- | phpBB/phpbb/db/migration/data/v310/rename_too_long_indexes.php | 38 | ||||
| -rw-r--r-- | phpBB/phpbb/db/tools.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/extension/metadata_manager.php | 21 | 
7 files changed, 102 insertions, 43 deletions
| diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index b32af32d25..2d538b739c 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -208,7 +208,7 @@ class file extends \phpbb\cache\driver\base  		{  			$iterator = new \DirectoryIterator($this->cache_dir);  		} -		catch (Exception $e) +		catch (\Exception $e)  		{  			return;  		} @@ -259,7 +259,7 @@ class file extends \phpbb\cache\driver\base  		{  			$iterator = new \DirectoryIterator($dir);  		} -		catch (Exception $e) +		catch (\Exception $e)  		{  			return;  		} diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index b890d90558..56727c2ad5 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -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/content_visibility.php b/phpBB/phpbb/content_visibility.php index 1f50032f26..da4405d676 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; @@ -576,7 +584,7 @@ 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);  	}  	/** @@ -588,15 +596,28 @@ class content_visibility  	*/  	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);  	}  	/** @@ -627,8 +648,8 @@ class content_visibility  		$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); +		$this->config->increment('num_topics', -1, false); +		$this->config->increment('num_posts', $topic_row['topic_posts_approved'] * (-1), false);  		// Get user post count information  		$sql = 'SELECT poster_id, COUNT(post_id) AS num_posts 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/tools.php b/phpBB/phpbb/db/tools.php index ae0c695aa2..5d93eb8246 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -2104,7 +2104,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); 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 | 
