From 7e016b9038ec0d5e05091ba84278a6d75ba84af8 Mon Sep 17 00:00:00 2001 From: Laurent Laville Date: Mon, 6 Feb 2006 23:06:48 +0000 Subject: [PATCH] - fixed Bug #5874 : Fails generation on missing "notes" element without error message. - problem may occurs also with "package", "summary", "description", "version", "state", "license" elements. git-svn-id: http://svn.php.net/repository/pear/packages/PEAR_PackageFileManager/trunk@206603 c90b9560-bf6c-de11-be94-00142212c4b1 --- PackageFileManager.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/PackageFileManager.php b/PackageFileManager.php index 50ef8e8..59e6078 100644 --- a/PackageFileManager.php +++ b/PackageFileManager.php @@ -56,6 +56,8 @@ define('PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE', 25); define('PEAR_PACKAGEFILEMANAGER_CVS_PACKAGED', 26); define('PEAR_PACKAGEFILEMANAGER_NO_PHPCOMPATINFO', 27); +define('PEAR_PACKAGEFILEMANAGER_NONOTES', 28); +define('PEAR_PACKAGEFILEMANAGER_NOLICENSE', 29); /**#@-*/ /** * Error messages @@ -124,6 +126,10 @@ 'path "%path%" contains CVS directory', PEAR_PACKAGEFILEMANAGER_NO_PHPCOMPATINFO => 'PHP_Compat is not installed, cannot detect dependencies', + PEAR_PACKAGEFILEMANAGER_NONOTES => + 'Release Notes (option \'notes\') must be specified in PEAR_PackageFileManager setOptions', + PEAR_PACKAGEFILEMANAGER_NOLICENSE => + 'Release License (option \'license\') must be specified in PEAR_PackageFileManager setOptions', ), // other language translations go here ); @@ -474,10 +480,10 @@ function PEAR_PackageFileManager() function setOptions($options = array(), $internal = false) { if (!$internal) { - if (!isset($options['state'])) { + if (!isset($options['state']) || empty($options['state'])) { return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOSTATE); } - if (!isset($options['version'])) { + if (!isset($options['version']) || empty($options['version'])) { return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOVERSION); } } @@ -930,6 +936,12 @@ function writePackageFile($debuginterface = null) if (!isset($this->_packageXml['maintainers']) || empty($this->_packageXml['maintainers'])) { return $this->raiseError(PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS); } + if (!isset($this->_options['notes']) || empty($this->_options['notes'])) { + return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NONOTES); + } + if (!isset($this->_options['license']) || empty($this->_options['license'])) { + return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOLICENSE); + } extract($this->_options); $date = date('Y-m-d'); if (isset($package)) { @@ -1559,13 +1571,13 @@ function _getExistingPackageXML($path, $packagefile = 'package.xml') function _generateNewPackageXML() { $this->_oldPackageXml = false; - if (!isset($this->_options['package'])) { + if (!isset($this->_options['package']) || empty($this->_options['package'])) { return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOPACKAGE); } - if (!isset($this->_options['summary'])) { + if (!isset($this->_options['summary']) || empty($this->_options['summary'])) { return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOSUMMARY); } - if (!isset($this->_options['description'])) { + if (!isset($this->_options['description']) || empty($this->_options['description'])) { return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NODESC); } $this->_packageXml = array();