logo       
Google Custom Search
    AddThis Social Bookmark Button

cvs: pear-core /PEAR/PackageFile v2.php: msg#00227

Subject: cvs: pear-core /PEAR/PackageFile v2.php
cellog          Sun Sep 26 20:13:03 2004 EDT

  Modified files:              
    /pear-core/PEAR/PackageFile v2.php 
  Log:
  add in validation for version attribute
  
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2.php?r1=1.11&r2=1.12&ty=u
Index: pear-core/PEAR/PackageFile/v2.php
diff -u pear-core/PEAR/PackageFile/v2.php:1.11 
pear-core/PEAR/PackageFile/v2.php:1.12
--- pear-core/PEAR/PackageFile/v2.php:1.11      Sat Sep 25 23:59:52 2004
+++ pear-core/PEAR/PackageFile/v2.php   Sun Sep 26 20:13:03 2004
@@ -17,7 +17,7 @@
 // |                                                                      |
 // +----------------------------------------------------------------------+
 //
-// $Id: v2.php,v 1.11 2004/09/26 03:59:52 cellog Exp $
+// $Id: v2.php,v 1.12 2004/09/27 00:13:03 cellog Exp $
 
 /**
  * @author Greg Beaver <cellog@xxxxxxx>
@@ -512,6 +512,10 @@
         if (!isset($this->_packageInfo) || !is_array($this->_packageInfo)) {
             return false;
         }
+        if (!isset($this->_packageInfo['attribs']['version']) ||
+              $this->_packageInfo['attribs']['version'] != '2.0') {
+            $this->_noPackageVersion();
+        }
         $structure =
         array(
             'name',
@@ -532,7 +536,7 @@
             'contents', //special validation needed
             '*compatible',
             '*dependencies', //special validation needed
-            '+phprelease|+extsrcrelease|+extbinrelease|+bundle' //special 
validation needed
+            '+phprelease|extsrcrelease|+extbinrelease|bundle' //special 
validation needed
         );
         if (!$this->_stupidSchemaValidate($structure,
                                           $this->_packageInfo, '<package>')) {
@@ -566,7 +570,26 @@
         $this->_validateStabilityVersion();
         $this->_validateFilelist();
         $this->_validateRelease();
-        return !$this->_stack->hasErrors();
+        if (!$this->_stack->hasErrors()) {
+            $chan = $this->_registry->getChannel($this->getChannel());
+            if (!$chan) {
+                $this->_unknownChannel($this->getChannel());
+            } else {
+                $validator = $chan->getValidationObject();
+                $validator->setPackageFile($this);
+                $validator->validate($state);
+                $failures = $validator->getFailures();
+                foreach ($failures['errors'] as $error) {
+                    $this->_stack->push(__FUNCTION__, 'error', $error,
+                        'Channel validator error: field "%field%" - %reason%');
+                    $this->_isValid = false;
+                }
+                foreach ($failures['warnings'] as $warning) {
+                    $this->_stack->push(__FUNCTION__, 'warning', $warning,
+                        'Channel validator warning: field "%field%" - 
%reason%');
+                }
+            }
+        }
     }
 
     function _stupidSchemaValidate($structure, $xml, $root)
@@ -1188,6 +1211,18 @@
             'name' => $name, 'group' => $group),
             'Group "%group%" dependency <%type%> "%name%" must have either url 
OR ' .
             'channel attributes');
+    }
+
+    function _unknownChannel($channel)
+    {
+        $this->_stack->push(__FUNCTION__, 'error', array('channel' => 
$channel),
+            'Unknown channel "%channel%"');
+    }
+
+    function _noPackageVersion()
+    {
+        $this->_stack->push(__FUNCTION__, 'error', array(),
+            'package.xml <package> tag has no version attribute, or version is 
not 2.0');
     }
 }
 ?>

-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>