Skip to content

Commit 47c71bc

Browse files
committed
- The config object is stored by the factory method
- Make install/unistall/package work again (didn't work for me)
1 parent 67b971a commit 47c71bc

File tree

4 files changed

+18
-27
lines changed

4 files changed

+18
-27
lines changed

pear/PEAR/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ class PEAR_Command
8888
*
8989
* @access public
9090
*/
91-
function factory($command)
91+
function factory($command, &$config)
9292
{
9393
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
9494
PEAR_Command::registerCommands();
9595
}
9696
if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
9797
$class = $GLOBALS['_PEAR_Command_commandlist'][$command];
98-
$obj = &new $class(PEAR_Command::getUIObject());
98+
$obj = &new $class(PEAR_Command::getUIObject(), $config);
9999
return $obj;
100100
}
101101
return PEAR::raiseError("unknown command `$command'");

pear/PEAR/Command/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class PEAR_Command_Common extends PEAR
4242
*
4343
* @access public
4444
*/
45-
function PEAR_Command_Common(&$ui)
45+
function PEAR_Command_Common(&$ui, &$config)
4646
{
4747
parent::PEAR();
48-
$this->config = &PEAR_Config::singleton();
48+
$this->config =& $config;
4949
$this->ui = $ui;
5050
}
5151

pear/PEAR/Command/Install.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@
2929
class PEAR_Command_Install extends PEAR_Command_Common
3030
{
3131
// {{{ properties
32-
33-
/** Stack of executing commands, to make run() re-entrant
34-
* @var array
35-
*/
36-
var $command_stack; // XXX UNUSED to make run() re-entrant
37-
38-
/** Currently executing command.
39-
* @var string
40-
*/
41-
var $command; // XXX UNUSED
42-
4332
// }}}
4433

4534
// {{{ constructor
@@ -49,9 +38,9 @@ class PEAR_Command_Install extends PEAR_Command_Common
4938
*
5039
* @access public
5140
*/
52-
function PEAR_Command_Install($ui)
41+
function PEAR_Command_Install(&$ui, &$config)
5342
{
54-
parent::PEAR_Command_Common($ui);
43+
parent::PEAR_Command_Common($ui, $config);
5544
}
5645

5746
// }}}
@@ -71,19 +60,21 @@ function getCommands()
7160
// }}}
7261
// {{{ run()
7362

74-
function run($command, $options, $params)
63+
function run($command, $params)
7564
{
76-
$installer =& new PEAR_Installer($options['php_dir'],
77-
$options['ext_dir'],
78-
$options['doc_dir']);
79-
$installer->debug = @$options['verbose'];
65+
$installer =& new PEAR_Installer($this->config->get('php_dir'),
66+
$this->config->get('ext_dir'),
67+
$this->config->get('doc_dir'));
68+
$installer->debug = $this->config->get('verbose');
8069
$failmsg = '';
70+
$options = array();
8171
switch ($command) {
8272
case 'install':
8373
case 'upgrade': {
8474
if ($command == 'upgrade') {
8575
$options['upgrade'] = true;
8676
}
77+
// The ['force'] and ['nodeps'] options are still missing
8778
if ($installer->install($params[0], $options, $this->config)) {
8879
$this->ui->displayLine("install ok");
8980
} else {
@@ -92,13 +83,13 @@ function run($command, $options, $params)
9283
break;
9384
}
9485
case 'uninstall': {
95-
if ($installer->uninstall($params[0], $uninstall_options)) {
86+
if ($installer->uninstall($params[0], $options)) {
9687
$this->ui->displayLine("uninstall ok");
9788
} else {
9889
$failmsg = "uninstall failed";
9990
}
10091
break;
101-
}
92+
}
10293
default: {
10394
return false;
10495
}

pear/PEAR/Command/Package.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class PEAR_Command_Package extends PEAR_Command_Common
1212
*
1313
* @access public
1414
*/
15-
function PEAR_Command_Package(&$ui)
15+
function PEAR_Command_Package(&$ui, &$config)
1616
{
17-
parent::PEAR_Command_Common($ui);
17+
parent::PEAR_Command_Common($ui, $config);
1818
}
1919

2020
// }}}
@@ -48,7 +48,7 @@ function getCommands()
4848
*
4949
* @access public
5050
*/
51-
function run($command, $options, $params)
51+
function run($command, $params)
5252
{
5353
$failmsg = '';
5454
switch ($command) {

0 commit comments

Comments
 (0)