diff options
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/includes/functions_container.php | 31 | ||||
| -rw-r--r-- | phpBB/install/database_update.php | 47 | ||||
| -rw-r--r-- | phpBB/install/index.php | 62 | ||||
| -rw-r--r-- | phpBB/install/install_update.php | 33 | ||||
| -rw-r--r-- | phpBB/phpbb/di/extension/core.php | 12 | ||||
| -rw-r--r-- | phpBB/phpbb/user.php | 7 | 
6 files changed, 131 insertions, 61 deletions
diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index f63dde0614..5c6bd6dd8a 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -118,7 +118,10 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext)  */  function phpbb_create_install_container($phpbb_root_path, $php_ext)  { -	$core = new phpbb_di_extension_core($phpbb_root_path); +	$other_config_path = $phpbb_root_path . 'install/update/new/config/'; +	$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; + +	$core = new phpbb_di_extension_core($config_path);  	$container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext);  	$container->setParameter('core.root_path', $phpbb_root_path); @@ -136,6 +139,30 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext)  }  /** +* Create updater container +* +* @param string $phpbb_root_path Root path +* @param string $php_ext PHP Extension +* @param array $config_path Path to config directory +* @return ContainerBuilder object (compiled) +*/ +function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) +{ +	return phpbb_create_compiled_container( +		array( +			new phpbb_di_extension_config($phpbb_root_path . 'config.' . $php_ext), +			new phpbb_di_extension_core($config_path), +		), +		array( +			new phpbb_di_pass_collection_pass(), +			new phpbb_di_pass_kernel_pass(), +		), +		$phpbb_root_path, +		$php_ext +	); +} + +/**  * Create a compiled ContainerBuilder object  *  * @param array $extensions Array of Container extension objects @@ -235,7 +262,7 @@ function phpbb_create_default_container($phpbb_root_path, $php_ext)  		$config_file,  		array(  			new phpbb_di_extension_config($config_file), -			new phpbb_di_extension_core($phpbb_root_path), +			new phpbb_di_extension_core($phpbb_root_path . 'config'),  		),  		array(  			new phpbb_di_pass_collection_pass(), diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cd6fb7931b..44cbc74d29 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -25,7 +25,7 @@ if (!function_exists('phpbb_require_updated'))  {  	function phpbb_require_updated($path, $optional = false)  	{ -		global $phpbb_root_path; +		global $phpbb_root_path, $table_prefix;  		$new_path = $phpbb_root_path . 'install/update/new/' . $path;  		$old_path = $phpbb_root_path . $path; @@ -41,6 +41,26 @@ if (!function_exists('phpbb_require_updated'))  	}  } +if (!function_exists('phpbb_include_updated')) +{ +	function phpbb_include_updated($path, $optional = false) +	{ +		global $phpbb_root_path; + +		$new_path = $phpbb_root_path . 'install/update/new/' . $path; +		$old_path = $phpbb_root_path . $path; + +		if (file_exists($new_path)) +		{ +			include($new_path); +		} +		else if (!$optional || file_exists($old_path)) +		{ +			include($old_path); +		} +	} +} +  function phpbb_end_update($cache, $config)  {  	$cache->purge(); @@ -82,30 +102,35 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati  $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;  // Include files -require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); +phpbb_require_updated('phpbb/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +phpbb_require_updated('includes/functions.' . $phpEx); +phpbb_require_updated('includes/functions_content.' . $phpEx); +phpbb_require_updated('includes/functions_container.' . $phpEx); -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); +require($phpbb_root_path . 'config.' . $phpEx); +phpbb_require_updated('includes/constants.' . $phpEx); +phpbb_require_updated('includes/utf/utf_tools.' . $phpEx);  // Set PHP error handler to ours  set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');  // Setup class loader first +$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); +$phpbb_class_loader_new->register();  $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx);  $phpbb_class_loader->register();  // Set up container (must be done here because extensions table may not exist) +$other_config_path = $phpbb_root_path . 'install/update/new/config/'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; +  $container_extensions = array(  	new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), -	new phpbb_di_extension_core($phpbb_root_path), +	new phpbb_di_extension_core($config_path),  );  $container_passes = array(  	new phpbb_di_pass_collection_pass(), -	//new phpbb_di_pass_kernel_pass(),  );  $phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); @@ -264,7 +289,7 @@ while (!$migrator->finished())  	if ((time() - $update_start_time) >= $safe_time_limit)  	{  		echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />'; -		echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&language=' . $user->lang['USER_LANG']) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; +		echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&language=' . $request->variable('language', 'en')) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>';  		phpbb_end_update($cache, $config);  	} @@ -280,7 +305,7 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '<br />';  if ($request->variable('type', 0))  {  	echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '<br /><br />'; -	echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&sub=file_check&language=' . $user->lang['USER_LANG']) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>'; +	echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&sub=file_check&language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>';  }  else  { diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 45e5777e36..ada1f43905 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -28,7 +28,7 @@ if (version_compare(PHP_VERSION, '5.3.3') < 0)  function phpbb_require_updated($path, $optional = false)  { -	global $phpbb_root_path; +	global $phpbb_root_path, $table_prefix;  	$new_path = $phpbb_root_path . 'install/update/new/' . $path;  	$old_path = $phpbb_root_path . $path; @@ -43,6 +43,23 @@ function phpbb_require_updated($path, $optional = false)  	}  } +function phpbb_include_updated($path, $optional = false) +{ +	global $phpbb_root_path; + +	$new_path = $phpbb_root_path . 'install/update/new/' . $path; +	$old_path = $phpbb_root_path . $path; + +	if (file_exists($new_path)) +	{ +		include($new_path); +	} +	else if (!$optional || file_exists($old_path)) +	{ +		include($old_path); +	} +} +  phpbb_require_updated('includes/startup.' . $phpEx);  // Try to override some limits - maybe it helps some... @@ -78,18 +95,21 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati  $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;  // Include essential scripts -require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); +phpbb_require_updated('phpbb/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +phpbb_require_updated('includes/functions.' . $phpEx); +phpbb_require_updated('includes/functions_container.' . $phpEx);  phpbb_require_updated('includes/functions_content.' . $phpEx, true); -include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -require($phpbb_root_path . 'includes/functions_install.' . $phpEx); +phpbb_include_updated('includes/functions_admin.' . $phpEx); +phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); +phpbb_include_updated('includes/utf/utf_tools.' . $phpEx); +phpbb_require_updated('includes/functions_install.' . $phpEx);  // Setup class loader first +$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); +$phpbb_class_loader_new->register();  $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx);  $phpbb_class_loader->register();  $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); @@ -108,7 +128,7 @@ $request	= $phpbb_container->get('request');  request_var('', 0, false, false, $request); // "dependency injection" for a function  // Try and load an appropriate language if required -$language = basename(request_var('language', '')); +$language = basename($request->variable('language', ''));  if ($request->header('Accept-Language') && !$language)  { @@ -167,11 +187,23 @@ if (!file_exists($phpbb_root_path . 'language/' . $language) || !is_dir($phpbb_r  }  // And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx); +$load_lang_files = array('common', 'acp/common', 'acp/board', 'install', 'posting'); +$new_path = $phpbb_root_path . 'install/update/new/language/' . $language . '/'; +$old_path = $phpbb_root_path . 'language/' . $language . '/'; + +// NOTE: we can not use "phpbb_include_updated" as the files uses vars which would be required +// to be global while loading. +foreach ($load_lang_files as $lang_file) +{ +	if (file_exists($new_path . $lang_file . '.' . $phpEx)) +	{ +		include($new_path . $lang_file . '.' . $phpEx); +	} +	else +	{ +		include($old_path . $lang_file . '.' . $phpEx); +	} +}  // usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :( @@ -181,8 +213,8 @@ define('CHMOD_READ', 4);  define('CHMOD_WRITE', 2);  define('CHMOD_EXECUTE', 1); -$mode = request_var('mode', 'overview'); -$sub = request_var('sub', ''); +$mode = $request->variable('mode', 'overview'); +$sub = $request->variable('sub', '');  // Set PHP error handler to ours  set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..f9dfaaef50 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -75,7 +75,7 @@ class install_update extends module  		global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container;  		// Create a normal container now -		$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); +		$phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config');  		// Writes into global $cache  		$cache = $phpbb_container->get('cache'); @@ -125,7 +125,7 @@ class install_update extends module  		$config['default_lang'] = $language;  		$user->data['user_lang'] = $language; -		$user->setup(array('common', 'acp/common', 'acp/board', 'install', 'posting')); +		$user->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting'));  		// Reset the default_lang  		$config['default_lang'] = $config_default_lang; @@ -302,30 +302,6 @@ class install_update extends module  			break;  			case 'update_db': - -				// Make sure the database update is valid for the latest version -				$valid = false; -				$updates_to_version = ''; - -				if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) -				{ -					include_once($phpbb_root_path . 'install/database_update.' . $phpEx); - -					if ($updates_to_version === $this->update_info['version']['to']) -					{ -						$valid = true; -					} -				} - -				// Should not happen at all -				if (!$valid) -				{ -					trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); -				} - -				// Just a precaution -				$cache->purge(); -  				// Redirect the user to the database update script with some explanations...  				$template->assign_vars(array(  					'S_DB_UPDATE'			=> true, @@ -509,8 +485,11 @@ class install_update extends module  				if ($all_up_to_date)  				{ +					global $phpbb_container; +					$phpbb_log = $phpbb_container->get('log'); +  					// Add database update to log -					add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); +					$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UPDATE_PHPBB', time(), array($this->current_version, $this->update_to_version));  					$db->sql_return_on_error(true);  					$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 9c36ba2fc4..9d59a24b7e 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -26,19 +26,19 @@ use Symfony\Component\Config\FileLocator;  class phpbb_di_extension_core extends Extension  {  	/** -	* phpBB Root path +	* Config path  	* @var string  	*/ -	protected $root_path; +	protected $config_path;  	/**  	* Constructor  	* -	* @param string $root_path Root path +	* @param string $config_path Config path  	*/ -	public function __construct($root_path) +	public function __construct($config_path)  	{ -		$this->root_path = $root_path; +		$this->config_path = $config_path;  	}  	/** @@ -51,7 +51,7 @@ class phpbb_di_extension_core extends Extension  	*/  	public function load(array $config, ContainerBuilder $container)  	{ -		$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config'))); +		$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path)));  		$loader->load('services.yml');  	} diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 5530fe3f03..b39438e315 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -590,6 +590,13 @@ class phpbb_user extends phpbb_session  				$language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx;  			} +			// If we are in install, try to use the updated version, when available +			$install_language_filename = str_replace('language/', 'install/update/new/language/', $language_filename); +			if (defined('IN_INSTALL') && file_exists($install_language_filename)) +			{ +				$language_filename = $install_language_filename; +			} +  			if (!file_exists($language_filename))  			{  				global $config;  | 
