svn: /pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/PackageFile/ Commands.php
[email protected] ("Daniel O'Connor") Sat, 26 Feb 2011 04:34:53 +0000
| Newsgroups | php.pear.cvs,php.pear.core |
|---|---|
| Message-ID | <[email protected]> |
clockwerx Sat, 26 Feb 2011 04:34:53 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308702
Log:
Prevent fatal errors when only a package2.xml is present, ala XML_RPC2
Changed paths:
U pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/PackageFile/Commands.php
Modified: pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/PackageFile/Commands.php
===================================================================
--- pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/PackageFile/Commands.php 2011-02-26 01:33:54 UTC (rev 308701)
+++ pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/PackageFile/Commands.php 2011-02-26 04:34:53 UTC (rev 308702)
@@ -151,31 +151,45 @@
echo "done\n";
}
+ /** @todo Consider simply injecting the Package object as appropriate */
function package($frontend, $args, $options)
{
- $package = false;
- if (!isset($args['packagexml'])) {
+ $path = getcwd() . DIRECTORY_SEPARATOR;
+ $package = new \PEAR2\Pyrus\Package(null);
+
+
+ if (!isset($args['packagexml']) && !file_exists($path . 'package.xml') && !file_exists($path . 'package2.xml')) {
+ throw new \PEAR2\Pyrus\PackageFile\Exception("No package.xml or package2.xml found in " . $path);
+ }
+
+ if (isset($args['packagexml'])) {
+ $package = new \PEAR2\Pyrus\Package($args['packagexml']);
+ } else {
// first try ./package.xml
- if (file_exists('package.xml')) {
+ if (file_exists($path . 'package.xml')) {
try {
- $package = new \PEAR2\Pyrus\Package(getcwd() . DIRECTORY_SEPARATOR . 'package.xml');
+ $package = new \PEAR2\Pyrus\Package($path . 'package.xml');
} catch (\PEAR2\Pyrus\PackageFile\Exception $e) {
if ($e->getCode() != -3) {
throw $e;
}
- if (!file_exists('package2.xml')) {
+ if (!file_exists($path . 'package2.xml')) {
throw $e;
}
- $package = new \PEAR2\Pyrus\Package(getcwd() . DIRECTORY_SEPARATOR . 'package2.xml');
+ $package = new \PEAR2\Pyrus\Package($path . 'package2.xml');
// now the creator knows to do the magic of package2.xml/package.xml
$package->thisIsOldAndCrustyCompatible();
}
}
- } else {
- $package = new \PEAR2\Pyrus\Package($args['packagexml']);
+
+ // Alternatively; there's only a package2.xml
+ if (file_exists($path . 'package2.xml') && !file_exists($path . 'package.xml')) {
+ $package = new \PEAR2\Pyrus\Package($path . 'package2.xml');
+ }
}
+
if ($package->isNewPackage()) {
if (!$options['phar'] && !$options['zip'] && !$options['tar'] && !$options['tgz']) {
// try tgz first