diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2017-03-19 15:53:08 +0100 | 
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2017-03-19 15:53:08 +0100 | 
| commit | 9958a68c575edeed965f5b47926329e039e4096e (patch) | |
| tree | dd6af1e4f857bc3e0307b392b37ea4f5900f4eb8 /phpBB/phpbb | |
| parent | 45ae23628e758ad4e06318a2191dd33f0427fbc1 (diff) | |
| parent | 59396771e6fe99a42aa48f0b8192c9c90bf60f6b (diff) | |
| download | forums-9958a68c575edeed965f5b47926329e039e4096e.tar forums-9958a68c575edeed965f5b47926329e039e4096e.tar.gz forums-9958a68c575edeed965f5b47926329e039e4096e.tar.bz2 forums-9958a68c575edeed965f5b47926329e039e4096e.tar.xz forums-9958a68c575edeed965f5b47926329e039e4096e.zip | |
Merge branch '3.1.x' into 3.2.x
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/extension/metadata_manager.php | 72 | 
1 files changed, 25 insertions, 47 deletions
| diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php index ae1af10c1d..f929433bff 100644 --- a/phpBB/phpbb/extension/metadata_manager.php +++ b/phpBB/phpbb/extension/metadata_manager.php @@ -93,29 +93,18 @@ class metadata_manager  		{  			case 'all':  			default: -				// Validate the metadata -				if (!$this->validate()) -				{ -					return false; -				} - +				$this->validate();  				return $this->metadata;  			break;  			case 'version':  			case 'name': -				return ($this->validate($element)) ? $this->metadata[$element] : false; +				$this->validate($element); +				return $this->metadata[$element];  			break;  			case 'display-name': -				if (isset($this->metadata['extra']['display-name'])) -				{ -					return $this->metadata['extra']['display-name']; -				} -				else -				{ -					return ($this->validate('name')) ? $this->metadata['name'] : false; -				} +				return (isset($this->metadata['extra']['display-name'])) ? $this->metadata['extra']['display-name'] : $this->get_metadata('name');  			break;  		}  	} @@ -212,23 +201,8 @@ class metadata_manager  		switch ($name)  		{  			case 'all': -				$this->validate('display'); - -				if (!$this->validate_dir()) -				{ -					throw new \phpbb\extension\exception('EXTENSION_DIR_INVALID'); -				} - -				if (!$this->validate_require_phpbb()) -				{ -					throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array('soft-require')); -				} - -				if (!$this->validate_require_php()) -				{ -					throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array('require php')); -				} -			break; +				$this->validate_enable(); +				// no break  			case 'display':  				foreach ($fields as $field => $data) @@ -285,40 +259,43 @@ class metadata_manager  	/**  	* This array handles the verification that this extension can be enabled on this board  	* -	* @return bool True if validation succeeded, False if failed +	* @return bool True if validation succeeded, throws an exception if invalid +	* @throws \phpbb\extension\exception  	*/  	public function validate_enable()  	{  		// Check for valid directory & phpBB, PHP versions -		if (!$this->validate_dir() || !$this->validate_require_phpbb() || !$this->validate_require_php()) -		{ -			return false; -		} - -		return true; +		return $this->validate_dir() && $this->validate_require_phpbb() && $this->validate_require_php();  	}  	/**  	* Validates the most basic directory structure to ensure it follows <vendor>/<ext> convention.  	* -	* @return boolean True when passes validation +	* @return boolean True when passes validation, throws an exception if invalid +	* @throws \phpbb\extension\exception  	*/  	public function validate_dir()  	{ -		return (substr_count($this->ext_name, '/') === 1 && $this->ext_name == $this->get_metadata('name')); +		if (substr_count($this->ext_name, '/') !== 1 || $this->ext_name != $this->get_metadata('name')) +		{ +			throw new \phpbb\extension\exception($this->user->lang('EXTENSION_DIR_INVALID')); +		} + +		return true;  	}  	/**  	* Validates the contents of the phpbb requirement field  	* -	* @return boolean True when passes validation +	* @return boolean True when passes validation, throws an exception if invalid +	* @throws \phpbb\extension\exception  	*/  	public function validate_require_phpbb()  	{  		if (!isset($this->metadata['extra']['soft-require']['phpbb/phpbb']))  		{ -			return false; +			throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', 'soft-require'));  		}  		return true; @@ -327,13 +304,14 @@ class metadata_manager  	/**  	* Validates the contents of the php requirement field  	* -	* @return boolean True when passes validation +	* @return boolean True when passes validation, throws an exception if invalid +	* @throws \phpbb\extension\exception  	*/  	public function validate_require_php()  	{  		if (!isset($this->metadata['require']['php']))  		{ -			return false; +			throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', 'require php'));  		}  		return true; @@ -356,10 +334,10 @@ class metadata_manager  			'META_LICENSE'		=> $this->metadata['license'],  			'META_REQUIRE_PHP'		=> (isset($this->metadata['require']['php'])) ? $this->metadata['require']['php'] : '', -			'META_REQUIRE_PHP_FAIL'	=> !$this->validate_require_php(), +			'META_REQUIRE_PHP_FAIL'	=> (isset($this->metadata['require']['php'])) ? false : true,  			'META_REQUIRE_PHPBB'		=> (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? $this->metadata['extra']['soft-require']['phpbb/phpbb'] : '', -			'META_REQUIRE_PHPBB_FAIL'	=> !$this->validate_require_phpbb(), +			'META_REQUIRE_PHPBB_FAIL'	=> (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? false : true,  			'META_DISPLAY_NAME'	=> (isset($this->metadata['extra']['display-name'])) ? $this->metadata['extra']['display-name'] : '',  		)); | 
