Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 3... Line 3...
3
 * PEAR_Command_Remote (remote-info, list-upgrades, remote-list, search, list-all, download,
3
 * PEAR_Command_Remote (remote-info, list-upgrades, remote-list, search, list-all, download,
4
 * clear-cache commands)
4
 * clear-cache commands)
5
 *
5
 *
6
 * PHP versions 4 and 5
6
 * PHP versions 4 and 5
7
 *
7
 *
8
 * LICENSE: This source file is subject to version 3.0 of the PHP license
-
 
9
 * that is available through the world-wide-web at the following URI:
-
 
10
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
-
 
11
 * the PHP License and are unable to obtain it through the web, please
-
 
12
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
13
 *
-
 
14
 * @category   pear
8
 * @category   pear
15
 * @package    PEAR
9
 * @package    PEAR
16
 * @author     Stig Bakken <ssb@php.net>
10
 * @author     Stig Bakken <ssb@php.net>
17
 * @author     Greg Beaver <cellog@php.net>
11
 * @author     Greg Beaver <cellog@php.net>
18
 * @copyright  1997-2006 The PHP Group
12
 * @copyright  1997-2009 The Authors
19
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
13
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
20
 * @version    CVS: $Id: Remote.php,v 1.96 2006/09/24 03:08:57 cellog Exp $
-
 
21
 * @link       http://pear.php.net/package/PEAR
14
 * @link       http://pear.php.net/package/PEAR
22
 * @since      File available since Release 0.1
15
 * @since      File available since Release 0.1
23
 */
16
 */
Line 24... Line 17...
24
 
17
 
Line 33... Line 26...
33
 *
26
 *
34
 * @category   pear
27
 * @category   pear
35
 * @package    PEAR
28
 * @package    PEAR
36
 * @author     Stig Bakken <ssb@php.net>
29
 * @author     Stig Bakken <ssb@php.net>
37
 * @author     Greg Beaver <cellog@php.net>
30
 * @author     Greg Beaver <cellog@php.net>
38
 * @copyright  1997-2006 The PHP Group
31
 * @copyright  1997-2009 The Authors
39
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
32
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
40
 * @version    Release: 1.5.1
33
 * @version    Release: 1.10.1
41
 * @link       http://pear.php.net/package/PEAR
34
 * @link       http://pear.php.net/package/PEAR
42
 * @since      Class available since Release 0.1
35
 * @since      Class available since Release 0.1
43
 */
36
 */
44
class PEAR_Command_Remote extends PEAR_Command_Common
37
class PEAR_Command_Remote extends PEAR_Command_Common
45
{
38
{
46
    // {{{ command definitions
-
 
47
 
-
 
48
    var $commands = array(
39
    var $commands = array(
49
        'remote-info' => array(
40
        'remote-info' => array(
50
            'summary' => 'Information About Remote Packages',
41
            'summary' => 'Information About Remote Packages',
51
            'function' => 'doRemoteInfo',
42
            'function' => 'doRemoteInfo',
52
            'shortcut' => 'ri',
43
            'shortcut' => 'ri',
Line 56... Line 47...
56
            ),
47
            ),
57
        'list-upgrades' => array(
48
        'list-upgrades' => array(
58
            'summary' => 'List Available Upgrades',
49
            'summary' => 'List Available Upgrades',
59
            'function' => 'doListUpgrades',
50
            'function' => 'doListUpgrades',
60
            'shortcut' => 'lu',
51
            'shortcut' => 'lu',
61
            'options' => array(),
52
            'options' => array(
-
 
53
                'channelinfo' => array(
-
 
54
                    'shortopt' => 'i',
-
 
55
                    'doc' => 'output fully channel-aware data, even on failure',
-
 
56
                    ),
-
 
57
            ),
62
            'doc' => '[preferred_state]
58
            'doc' => '[preferred_state]
63
List releases on the server of packages you have installed where
59
List releases on the server of packages you have installed where
64
a newer version is available with the same release state (stable etc.)
60
a newer version is available with the same release state (stable etc.)
65
or the state passed as the second parameter.'
61
or the state passed as the second parameter.'
66
            ),
62
            ),
Line 88... Line 84...
88
                'channel' =>
84
                'channel' =>
89
                    array(
85
                    array(
90
                    'shortopt' => 'c',
86
                    'shortopt' => 'c',
91
                    'doc' => 'specify a channel other than the default channel',
87
                    'doc' => 'specify a channel other than the default channel',
92
                    'arg' => 'CHAN',
88
                    'arg' => 'CHAN',
93
                    )
89
                    ),
-
 
90
                'allchannels' => array(
-
 
91
                    'shortopt' => 'a',
-
 
92
                    'doc' => 'search packages from all known channels',
-
 
93
                    ),
-
 
94
                'channelinfo' => array(
-
 
95
                    'shortopt' => 'i',
-
 
96
                    'doc' => 'output fully channel-aware data, even on failure',
-
 
97
                    ),
94
                ),
98
                ),
95
            'doc' => '[packagename] [packageinfo]
99
            'doc' => '[packagename] [packageinfo]
96
Lists all packages which match the search parameters.  The first
100
Lists all packages which match the search parameters.  The first
97
parameter is a fragment of a packagename.  The default channel
101
parameter is a fragment of a packagename.  The default channel
98
will be used unless explicitly overridden.  The second parameter
102
will be used unless explicitly overridden.  The second parameter
Line 106... Line 110...
106
                'channel' =>
110
                'channel' =>
107
                    array(
111
                    array(
108
                    'shortopt' => 'c',
112
                    'shortopt' => 'c',
109
                    'doc' => 'specify a channel other than the default channel',
113
                    'doc' => 'specify a channel other than the default channel',
110
                    'arg' => 'CHAN',
114
                    'arg' => 'CHAN',
111
                    )
115
                    ),
-
 
116
                'channelinfo' => array(
-
 
117
                    'shortopt' => 'i',
-
 
118
                    'doc' => 'output fully channel-aware data, even on failure',
-
 
119
                    ),
112
                ),
120
                ),
113
            'doc' => '
121
            'doc' => '
114
Lists the packages available on the configured server along with the
122
Lists the packages available on the configured server along with the
115
latest stable release of each package.',
123
latest stable release of each package.',
116
            ),
124
            ),
Line 133... Line 141...
133
            'summary' => 'Clear Web Services Cache',
141
            'summary' => 'Clear Web Services Cache',
134
            'function' => 'doClearCache',
142
            'function' => 'doClearCache',
135
            'shortcut' => 'cc',
143
            'shortcut' => 'cc',
136
            'options' => array(),
144
            'options' => array(),
137
            'doc' => '
145
            'doc' => '
138
Clear the XML-RPC/REST cache.  See also the cache_ttl configuration
146
Clear the REST cache. See also the cache_ttl configuration
139
parameter.
147
parameter.
140
',
148
',
141
            ),
149
            ),
142
        );
150
        );
Line 143... Line -...
143
 
-
 
144
    // }}}
-
 
145
    // {{{ constructor
-
 
146
 
151
 
147
    /**
152
    /**
148
     * PEAR_Command_Remote constructor.
153
     * PEAR_Command_Remote constructor.
149
     *
154
     *
150
     * @access public
155
     * @access public
151
     */
156
     */
152
    function PEAR_Command_Remote(&$ui, &$config)
157
    function __construct(&$ui, &$config)
153
    {
158
    {
154
        parent::PEAR_Command_Common($ui, $config);
159
        parent::__construct($ui, $config);
Line 155... Line -...
155
    }
-
 
156
 
-
 
157
    // }}}
160
    }
158
 
161
 
159
    function _checkChannelForStatus($channel, $chan)
162
    function _checkChannelForStatus($channel, $chan)
160
    {
163
    {
161
        if (PEAR::isError($chan)) {
164
        if (PEAR::isError($chan)) {
Line 165... Line 168...
165
            return $this->raiseError('Internal corruption error: invalid channel "' .
168
            return $this->raiseError('Internal corruption error: invalid channel "' .
166
                $channel . '"');
169
                $channel . '"');
167
        }
170
        }
168
        $rest = new PEAR_REST($this->config);
171
        $rest = new PEAR_REST($this->config);
169
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
172
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
173
        $mirror = $this->config->get('preferred_mirror', null,
-
 
174
                                     $channel);
170
        $a = $rest->downloadHttp('http://' . $channel .
175
        $a = $rest->downloadHttp('http://' . $channel .
171
            '/channel.xml', $chan->lastModified());
176
            '/channel.xml', $chan->lastModified());
172
        PEAR::staticPopErrorHandling();
177
        PEAR::staticPopErrorHandling();
173
        if (!PEAR::isError($a) && $a) {
178
        if (!PEAR::isError($a) && $a) {
174
            $this->ui->outputData('WARNING: channel "' . $channel . '" has ' .
179
            $this->ui->outputData('WARNING: channel "' . $channel . '" has ' .
175
                'updated its protocols, use "channel-update ' . $channel .
180
                'updated its protocols, use "' . PEAR_RUNTYPE . ' channel-update ' . $channel .
176
                '" to update');
181
                '" to update');
177
        }
182
        }
178
    }
183
    }
Line 179... Line -...
179
 
-
 
180
    // {{{ doRemoteInfo()
-
 
181
 
184
 
182
    function doRemoteInfo($command, $options, $params)
185
    function doRemoteInfo($command, $options, $params)
183
    {
186
    {
184
        if (sizeof($params) != 1) {
187
        if (sizeof($params) != 1) {
185
            return $this->raiseError("$command expects one param: the remote package name");
188
            return $this->raiseError("$command expects one param: the remote package name");
Line 196... Line 199...
196
        $this->config->set('default_channel', $channel);
199
        $this->config->set('default_channel', $channel);
197
        $chan = $reg->getChannel($channel);
200
        $chan = $reg->getChannel($channel);
198
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
201
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
199
            return $e;
202
            return $e;
200
        }
203
        }
-
 
204
 
201
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
205
        $mirror = $this->config->get('preferred_mirror');
202
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
206
        if ($chan->supportsREST($mirror) && $base = $chan->getBaseURL('REST1.0', $mirror)) {
203
            $rest = &$this->config->getREST('1.0', array());
207
            $rest = &$this->config->getREST('1.0', array());
204
            $info = $rest->packageInfo($base, $parsed['package']);
208
            $info = $rest->packageInfo($base, $parsed['package'], $channel);
205
        } else {
209
        }
-
 
210
 
206
            $r = &$this->config->getRemote();
211
        if (!isset($info)) {
207
            $info = $r->call('package.info', $parsed['package']);
212
            return $this->raiseError('No supported protocol was found');
208
        }
213
        }
-
 
214
 
209
        if (PEAR::isError($info)) {
215
        if (PEAR::isError($info)) {
210
            $this->config->set('default_channel', $savechannel);
216
            $this->config->set('default_channel', $savechannel);
211
            return $this->raiseError($info);
217
            return $this->raiseError($info);
212
        }
218
        }
-
 
219
 
213
        if (!isset($info['name'])) {
220
        if (!isset($info['name'])) {
214
            return $this->raiseError('No remote package "' . $package . '" was found');
221
            return $this->raiseError('No remote package "' . $package . '" was found');
215
        }
222
        }
Line 216... Line 223...
216
 
223
 
Line 224... Line 231...
224
        $this->config->set('default_channel', $savechannel);
231
        $this->config->set('default_channel', $savechannel);
Line 225... Line 232...
225
 
232
 
226
        return true;
233
        return true;
Line 227... Line -...
227
    }
-
 
228
 
-
 
229
    // }}}
-
 
230
    // {{{ doRemoteList()
234
    }
231
 
235
 
232
    function doRemoteList($command, $options, $params)
236
    function doRemoteList($command, $options, $params)
233
    {
237
    {
234
        $savechannel = $channel = $this->config->get('default_channel');
238
        $savechannel = $channel = $this->config->get('default_channel');
235
        $reg = &$this->config->getRegistry();
239
        $reg = &$this->config->getRegistry();
236
        if (isset($options['channel'])) {
240
        if (isset($options['channel'])) {
237
            $channel = $options['channel'];
-
 
238
            if ($reg->channelExists($channel)) {
-
 
239
                $this->config->set('default_channel', $channel);
241
            $channel = $options['channel'];
240
            } else {
242
            if (!$reg->channelExists($channel)) {
-
 
243
                return $this->raiseError('Channel "' . $channel . '" does not exist');
-
 
244
            }
241
                return $this->raiseError('Channel "' . $channel . '" does not exist');
245
 
-
 
246
            $this->config->set('default_channel', $channel);
242
            }
247
        }
243
        }
248
 
244
        $chan = $reg->getChannel($channel);
249
        $chan = $reg->getChannel($channel);
245
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
250
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
-
 
251
            return $e;
246
            return $e;
252
        }
247
        }
253
 
248
        $list_options = false;
254
        $list_options = false;
249
        if ($this->config->get('preferred_state') == 'stable') {
255
        if ($this->config->get('preferred_state') == 'stable') {
-
 
256
            $list_options = true;
-
 
257
        }
250
            $list_options = true;
258
 
251
        }
259
        $available = array();
-
 
260
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
252
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
261
              $base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))
253
              $base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
262
        ) {
254
            // use faster list-all if available
263
            // use faster list-all if available
255
            $rest = &$this->config->getREST('1.1', array());
264
            $rest = &$this->config->getREST('1.1', array());
256
            $available = $rest->listAll($base, $list_options);
265
            $available = $rest->listAll($base, $list_options, true, false, false, $chan->getName());
257
        } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
266
        } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
258
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
267
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
259
            $rest = &$this->config->getREST('1.0', array());
-
 
260
            $available = $rest->listAll($base, $list_options);
-
 
261
        } else {
-
 
262
            $r = &$this->config->getRemote();
-
 
263
            if ($channel == 'pear.php.net') {
-
 
264
                // hack because of poor pearweb design
-
 
265
                $available = $r->call('package.listAll', true, $list_options, false);
-
 
266
            } else {
-
 
267
                $available = $r->call('package.listAll', true, $list_options);
268
            $rest = &$this->config->getREST('1.0', array());
-
 
269
            $available = $rest->listAll($base, $list_options, true, false, false, $chan->getName());
268
            }
270
        }
269
        }
271
 
270
        if (PEAR::isError($available)) {
272
        if (PEAR::isError($available)) {
271
            $this->config->set('default_channel', $savechannel);
273
            $this->config->set('default_channel', $savechannel);
-
 
274
            return $this->raiseError($available);
272
            return $this->raiseError($available);
275
        }
273
        }
276
 
274
        $i = $j = 0;
277
        $i = $j = 0;
275
        $data = array(
278
        $data = array(
276
            'caption' => 'Channel ' . $channel . ' Available packages:',
279
            'caption' => 'Channel ' . $channel . ' Available packages:',
-
 
280
            'border' => true,
277
            'border' => true,
281
            'headline' => array('Package', 'Version'),
-
 
282
            'channel' => $channel
278
            'headline' => array('Package', 'Version'),
283
            );
279
            );
284
 
280
        if (count($available)==0) {
285
        if (count($available) == 0) {
281
            $data = '(no packages available yet)';
286
            $data = '(no packages available yet)';
282
        } else {
287
        } else {
283
            foreach ($available as $name => $info) {
288
            foreach ($available as $name => $info) {
284
                $data['data'][] = array($name, (isset($info['stable']) && $info['stable'])
289
                $version = (isset($info['stable']) && $info['stable']) ? $info['stable'] : '-n/a-';
285
                    ? $info['stable'] : '-n/a-');
290
                $data['data'][] = array($name, $version);
286
            }
291
            }
287
        }
292
        }
288
        $this->ui->outputData($data, $command);
293
        $this->ui->outputData($data, $command);
289
        $this->config->set('default_channel', $savechannel);
294
        $this->config->set('default_channel', $savechannel);
Line 290... Line -...
290
        return true;
-
 
291
    }
-
 
292
 
-
 
293
    // }}}
295
        return true;
294
    // {{{ doListAll()
296
    }
295
 
297
 
296
    function doListAll($command, $options, $params)
298
    function doListAll($command, $options, $params)
297
    {
299
    {
298
        $savechannel = $channel = $this->config->get('default_channel');
300
        $savechannel = $channel = $this->config->get('default_channel');
299
        $reg = &$this->config->getRegistry();
301
        $reg = &$this->config->getRegistry();
300
        if (isset($options['channel'])) {
-
 
301
            $channel = $options['channel'];
-
 
302
            if ($reg->channelExists($channel)) {
302
        if (isset($options['channel'])) {
303
                $this->config->set('default_channel', $channel);
303
            $channel = $options['channel'];
-
 
304
            if (!$reg->channelExists($channel)) {
-
 
305
                return $this->raiseError("Channel \"$channel\" does not exist");
304
            } else {
306
            }
-
 
307
 
305
                return $this->raiseError("Channel \"$channel\" does not exist");
308
            $this->config->set('default_channel', $channel);
306
            }
309
        }
307
        }
310
 
308
        $list_options = false;
311
        $list_options = false;
-
 
312
        if ($this->config->get('preferred_state') == 'stable') {
309
        if ($this->config->get('preferred_state') == 'stable') {
313
            $list_options = true;
310
            $list_options = true;
314
        }
311
        }
315
 
312
        $chan = $reg->getChannel($channel);
316
        $chan = $reg->getChannel($channel);
-
 
317
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
313
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
318
            return $e;
314
            return $e;
319
        }
315
        }
320
 
316
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
321
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
317
              $base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
322
              $base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
318
            // use faster list-all if available
323
            // use faster list-all if available
319
            $rest = &$this->config->getREST('1.1', array());
324
            $rest = &$this->config->getREST('1.1', array());
320
            $available = $rest->listAll($base, $list_options, false);
325
            $available = $rest->listAll($base, $list_options, false, false, false, $chan->getName());
321
        } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
326
        } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
322
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
-
 
323
            $rest = &$this->config->getREST('1.0', array());
-
 
324
            $available = $rest->listAll($base, $list_options, false);
-
 
325
        } else {
-
 
326
            $r = &$this->config->getRemote();
-
 
327
            if ($channel == 'pear.php.net') {
-
 
328
                // hack because of poor pearweb design
-
 
329
                $available = $r->call('package.listAll', true, $list_options, false);
-
 
330
            } else {
327
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
-
 
328
            $rest = &$this->config->getREST('1.0', array());
331
                $available = $r->call('package.listAll', true, $list_options);
329
            $available = $rest->listAll($base, $list_options, false, false, false, $chan->getName());
332
            }
330
        }
333
        }
331
 
334
        if (PEAR::isError($available)) {
332
        if (PEAR::isError($available)) {
-
 
333
            $this->config->set('default_channel', $savechannel);
335
            $this->config->set('default_channel', $savechannel);
334
            return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "' . $available->getMessage() . '")');
336
            return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "' . $available->getMessage() . '")');
335
        }
337
        }
336
 
338
        $data = array(
337
        $data = array(
-
 
338
            'caption' => 'All packages [Channel ' . $channel . ']:',
339
            'caption' => 'All packages:',
339
            'border' => true,
-
 
340
            'headline' => array('Package', 'Latest', 'Local'),
-
 
341
            'channel' => $channel,
-
 
342
            );
-
 
343
 
-
 
344
        if (isset($options['channelinfo'])) {
-
 
345
            // add full channelinfo
-
 
346
            $data['caption'] = 'Channel ' . $channel . ' All packages:';
340
            'border' => true,
347
            $data['headline'] = array('Channel', 'Package', 'Latest', 'Local',
Line 341... Line 348...
341
            'headline' => array('Package', 'Latest', 'Local'),
348
                'Description', 'Dependencies');
342
            );
349
        }
343
        $local_pkgs = $reg->listPackages($channel);
350
        $local_pkgs = $reg->listPackages($channel);
Line 371... Line 378...
371
            }
378
            }
Line 372... Line 379...
372
 
379
 
373
            if (isset($info['stable']) && !$info['stable']) {
380
            if (isset($info['stable']) && !$info['stable']) {
374
                $info['stable'] = null;
381
                $info['stable'] = null;
-
 
382
            }
-
 
383
 
-
 
384
            if (isset($options['channelinfo'])) {
-
 
385
                // add full channelinfo
-
 
386
                if ($info['stable'] === $info['unstable']) {
-
 
387
                    $state = $info['state'];
-
 
388
                } else {
-
 
389
                    $state = 'stable';
-
 
390
                }
-
 
391
                $latest = $info['stable'].' ('.$state.')';
-
 
392
                $local = '';
-
 
393
                if (isset($installed['version'])) {
-
 
394
                    $inst_state = $reg->packageInfo($name, 'release_state', $channel);
-
 
395
                    $local = $installed['version'].' ('.$inst_state.')';
-
 
396
                }
375
            }
397
 
-
 
398
                $packageinfo = array(
-
 
399
                    $channel,
-
 
400
                    $name,
-
 
401
                    $latest,
-
 
402
                    $local,
-
 
403
                    isset($desc) ? $desc : null,
-
 
404
                    isset($info['deps']) ? $info['deps'] : null,
-
 
405
                );
-
 
406
            } else {
376
            $data['data'][$info['category']][] = array(
407
                $packageinfo = array(
377
                $reg->channelAlias($channel) . '/' . $name,
408
                    $reg->channelAlias($channel) . '/' . $name,
378
                isset($info['stable']) ? $info['stable'] : null,
409
                    isset($info['stable']) ? $info['stable'] : null,
379
                isset($installed['version']) ? $installed['version'] : null,
410
                    isset($installed['version']) ? $installed['version'] : null,
380
                isset($desc) ? $desc : null,
411
                    isset($desc) ? $desc : null,
381
                isset($info['deps']) ? $info['deps'] : null,
412
                    isset($info['deps']) ? $info['deps'] : null,
382
                );
413
                );
-
 
414
            }
-
 
415
            $data['data'][$info['category']][] = $packageinfo;
Line 383... Line 416...
383
        }
416
        }
384
 
417
 
385
        if (isset($options['mode']) && in_array($options['mode'], array('notinstalled', 'upgrades'))) {
418
        if (isset($options['mode']) && in_array($options['mode'], array('notinstalled', 'upgrades'))) {
386
            $this->config->set('default_channel', $savechannel);
419
            $this->config->set('default_channel', $savechannel);
387
            $this->ui->outputData($data, $command);
420
            $this->ui->outputData($data, $command);
-
 
421
            return true;
388
            return true;
422
        }
389
        }
423
 
390
        foreach ($local_pkgs as $name) {
424
        foreach ($local_pkgs as $name) {
391
            $info = &$reg->getPackage($name, $channel);
425
            $info = &$reg->getPackage($name, $channel);
392
            $data['data']['Local'][] = array(
426
            $data['data']['Local'][] = array(
Line 401... Line 435...
401
        $this->config->set('default_channel', $savechannel);
435
        $this->config->set('default_channel', $savechannel);
402
        $this->ui->outputData($data, $command);
436
        $this->ui->outputData($data, $command);
403
        return true;
437
        return true;
404
    }
438
    }
Line 405... Line -...
405
 
-
 
406
    // }}}
-
 
407
    // {{{ doSearch()
-
 
408
 
439
 
409
    function doSearch($command, $options, $params)
440
    function doSearch($command, $options, $params)
410
    {
441
    {
411
        if ((!isset($params[0]) || empty($params[0]))
442
        if ((!isset($params[0]) || empty($params[0]))
412
            && (!isset($params[1]) || empty($params[1])))
443
            && (!isset($params[1]) || empty($params[1])))
413
        {
444
        {
414
            return $this->raiseError('no valid search string supplied');
445
            return $this->raiseError('no valid search string supplied');
Line 415... Line 446...
415
        };
446
        }
416
 
447
 
-
 
448
        $channelinfo = isset($options['channelinfo']);
-
 
449
        $reg = &$this->config->getRegistry();
-
 
450
        if (isset($options['allchannels'])) {
-
 
451
            // search all channels
-
 
452
            unset($options['allchannels']);
-
 
453
            $channels = $reg->getChannels();
-
 
454
            $errors = array();
-
 
455
            PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
456
            foreach ($channels as $channel) {
-
 
457
                if ($channel->getName() != '__uri') {
-
 
458
                    $options['channel'] = $channel->getName();
-
 
459
                    $ret = $this->doSearch($command, $options, $params);
-
 
460
                    if (PEAR::isError($ret)) {
-
 
461
                        $errors[] = $ret;
-
 
462
                    }
-
 
463
                }
-
 
464
            }
-
 
465
 
-
 
466
            PEAR::staticPopErrorHandling();
-
 
467
            if (count($errors) !== 0) {
-
 
468
                // for now, only give first error
-
 
469
                return PEAR::raiseError($errors[0]);
-
 
470
            }
-
 
471
 
-
 
472
            return true;
-
 
473
        }
417
        $savechannel = $channel = $this->config->get('default_channel');
474
 
418
        $reg = &$this->config->getRegistry();
475
        $savechannel = $channel = $this->config->get('default_channel');
419
        $package = $params[0];
476
        $package = strtolower($params[0]);
420
        $summary = isset($params[1]) ? $params[1] : false;
477
        $summary = isset($params[1]) ? $params[1] : false;
421
        if (isset($options['channel'])) {
478
        if (isset($options['channel'])) {
422
            $reg = &$this->config->getRegistry();
479
            $reg = &$this->config->getRegistry();
423
            $channel = $options['channel'];
-
 
424
            if ($reg->channelExists($channel)) {
-
 
425
                $this->config->set('default_channel', $channel);
480
            $channel = $options['channel'];
426
            } else {
481
            if (!$reg->channelExists($channel)) {
-
 
482
                return $this->raiseError('Channel "' . $channel . '" does not exist');
-
 
483
            }
427
                return $this->raiseError('Channel "' . $channel . '" does not exist');
484
 
-
 
485
            $this->config->set('default_channel', $channel);
428
            }
486
        }
429
        }
487
 
430
        $chan = $reg->getChannel($channel);
488
        $chan = $reg->getChannel($channel);
431
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
489
        if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
-
 
490
            return $e;
432
            return $e;
491
        }
433
        }
492
 
434
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
493
        if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
435
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
494
              $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
436
            $rest = &$this->config->getREST('1.0', array());
-
 
437
            $available = $rest->listAll($base, false, false, $package, $summary);
-
 
438
        } else {
-
 
439
            $r = &$this->config->getRemote();
-
 
440
            $available = $r->call('package.search', $package, $summary, true, 
495
            $rest = &$this->config->getREST('1.0', array());
-
 
496
            $available = $rest->listAll($base, false, false, $package, $summary, $chan->getName());
441
                $this->config->get('preferred_state') == 'stable', true);
497
        }
442
        }
498
 
443
        if (PEAR::isError($available)) {
499
        if (PEAR::isError($available)) {
444
            $this->config->set('default_channel', $savechannel);
500
            $this->config->set('default_channel', $savechannel);
-
 
501
            return $this->raiseError($available);
445
            return $this->raiseError($available);
502
        }
-
 
503
 
446
        }
504
        if (!$available && !$channelinfo) {
-
 
505
            // clean exit when not found, no error !
-
 
506
            $data = 'no packages found that match pattern "' . $package . '", for channel '.$channel.'.';
-
 
507
            $this->ui->outputData($data);
447
        if (!$available) {
508
            $this->config->set('default_channel', $channel);
-
 
509
            return true;
-
 
510
        }
-
 
511
 
-
 
512
        if ($channelinfo) {
-
 
513
            $data = array(
-
 
514
                'caption' => 'Matched packages, channel ' . $channel . ':',
-
 
515
                'border' => true,
-
 
516
                'headline' => array('Channel', 'Package', 'Stable/(Latest)', 'Local'),
-
 
517
                'channel' => $channel
448
            return $this->raiseError('no packages found that match pattern "' . $package . '"');
518
                );
449
        }
519
        } else {
450
        $data = array(
520
            $data = array(
451
            'caption' => 'Matched packages, channel ' . $channel . ':',
521
                'caption' => 'Matched packages, channel ' . $channel . ':',
-
 
522
                'border' => true,
452
            'border' => true,
523
                'headline' => array('Package', 'Stable/(Latest)', 'Local'),
-
 
524
                'channel' => $channel
-
 
525
                );
-
 
526
        }
-
 
527
 
-
 
528
        if (!$available && $channelinfo) {
-
 
529
            unset($data['headline']);
-
 
530
            $data['data'] = 'No packages found that match pattern "' . $package . '".';
Line 453... Line 531...
453
            'headline' => array('Package', 'Stable/(Latest)', 'Local'),
531
            $available = array();
454
            );
532
        }
455
 
533
 
456
        foreach ($available as $name => $info) {
534
        foreach ($available as $name => $info) {
457
            $installed = $reg->packageInfo($name, null, $channel);
535
            $installed = $reg->packageInfo($name, null, $channel);
Line -... Line 536...
-
 
536
            $desc = $info['summary'];
-
 
537
            if (isset($params[$name]))
458
            $desc = $info['summary'];
538
                $desc .= "\n\n".$info['description'];
459
            if (isset($params[$name]))
539
 
-
 
540
            if (!isset($info['stable']) || !$info['stable']) {
-
 
541
                $version_remote = 'none';
460
                $desc .= "\n\n".$info['description'];
542
            } else {
461
 
543
                if ($info['unstable']) {
462
            $unstable = '';
544
                    $version_remote = $info['unstable'];
463
            if ($info['unstable']) {
-
 
464
                $unstable = '/(' . $info['unstable'] . ' ' . $info['state'] . ')';
545
                } else {
465
            }
546
                    $version_remote = $info['stable'];
466
            if (!isset($info['stable']) || !$info['stable']) {
547
                }
-
 
548
                $version_remote .= ' ('.$info['state'].')';
467
                $info['stable'] = 'none';
549
            }
-
 
550
            $version = is_array($installed['version']) ? $installed['version']['release'] :
468
            }
551
                $installed['version'];
469
            $version = is_array($installed['version']) ? $installed['version']['release'] :
552
            if ($channelinfo) {
470
                $installed['version'];
553
                $packageinfo = array(
471
            $data['data'][$info['category']][] = array(
554
                    $channel,
472
                $name,
555
                    $name,
-
 
556
                    $version_remote,
-
 
557
                    $version,
-
 
558
                    $desc,
-
 
559
                );
-
 
560
            } else {
-
 
561
                $packageinfo = array(
-
 
562
                    $name,
-
 
563
                    $version_remote,
-
 
564
                    $version,
473
                $info['stable'] . $unstable,
565
                    $desc,
-
 
566
                );
474
                $version,
567
            }
475
                $desc,
568
            $data['data'][$info['category']][] = $packageinfo;
476
                );
569
        }
477
        }
570
 
Line 478... Line -...
478
        $this->ui->outputData($data, $command);
-
 
479
        $this->config->set('default_channel', $channel);
571
        $this->ui->outputData($data, $command);
480
        return true;
572
        $this->config->set('default_channel', $channel);
481
    }
573
        return true;
482
 
574
    }
483
    // }}}
575
 
484
    function &getDownloader($options)
576
    function &getDownloader($options)
485
    {
577
    {
486
        if (!class_exists('PEAR_Downloader')) {
578
        if (!class_exists('PEAR_Downloader')) {
487
            require_once 'PEAR/Downloader.php';
-
 
Line 488... Line 579...
488
        }
579
            require_once 'PEAR/Downloader.php';
489
        $a = &new PEAR_Downloader($this->ui, $options, $this->config);
580
        }
490
        return $a;
581
        $a = new PEAR_Downloader($this->ui, $options, $this->config);
491
    }
582
        return $a;
Line 501... Line 592...
501
           prefered state */
592
           prefered state */
502
        /* $options['ignorepreferred_state'] = 1; */
593
        /* $options['ignorepreferred_state'] = 1; */
503
        // eliminate error messages for preferred_state-related errors
594
        // eliminate error messages for preferred_state-related errors
Line 504... Line 595...
504
 
595
 
-
 
596
        $downloader = &$this->getDownloader($options);
505
        $downloader = &$this->getDownloader($options);
597
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
598
        $e = $downloader->setDownloadDir(getcwd());
-
 
599
        PEAR::staticPopErrorHandling();
-
 
600
        if (PEAR::isError($e)) {
-
 
601
            return $this->raiseError('Current directory is not writeable, cannot download');
-
 
602
        }
506
        $downloader->setDownloadDir(getcwd());
603
 
507
        $errors = array();
604
        $errors = array();
508
        $downloaded = array();
605
        $downloaded = array();
509
        $err = $downloader->download($params);
606
        $err = $downloader->download($params);
510
        if (PEAR::isError($err)) {
607
        if (PEAR::isError($err)) {
511
            return $err;
608
            return $err;
-
 
609
        }
512
        }
610
 
513
        $errors = $downloader->getErrorMsgs();
611
        $errors = $downloader->getErrorMsgs();
514
        if (count($errors)) {
612
        if (count($errors)) {
-
 
613
            foreach ($errors as $error) {
515
            foreach ($errors as $error) {
614
                if ($error !== null) {
516
                $this->ui->outputData($error);
615
                    $this->ui->outputData($error);
-
 
616
                }
-
 
617
            }
517
            }
618
 
518
            return $this->raiseError("$command failed");
619
            return $this->raiseError("$command failed");
-
 
620
        }
519
        }
621
 
520
        $downloaded = $downloader->getDownloadedPackages();
622
        $downloaded = $downloader->getDownloadedPackages();
521
        foreach ($downloaded as $pkg) {
623
        foreach ($downloaded as $pkg) {
522
            $this->ui->outputData("File $pkg[file] downloaded", $command);
624
            $this->ui->outputData("File $pkg[file] downloaded", $command);
-
 
625
        }
523
        }
626
 
524
        return true;
627
        return true;
Line 525... Line 628...
525
    }
628
    }
526
 
629
 
527
    function downloadCallback($msg, $params = null)
630
    function downloadCallback($msg, $params = null)
528
    {
631
    {
529
        if ($msg == 'done') {
632
        if ($msg == 'done') {
530
            $this->bytes_downloaded = $params;
633
            $this->bytes_downloaded = $params;
Line 531... Line -...
531
        }
-
 
532
    }
-
 
533
 
-
 
534
    // }}}
634
        }
535
    // {{{ doListUpgrades()
635
    }
536
 
636
 
537
    function doListUpgrades($command, $options, $params)
637
    function doListUpgrades($command, $options, $params)
538
    {
638
    {
539
        require_once 'PEAR/Common.php';
639
        require_once 'PEAR/Common.php';
-
 
640
        if (isset($params[0]) && !is_array(PEAR_Common::betterStates($params[0]))) {
540
        if (isset($params[0]) && !is_array(PEAR_Common::betterStates($params[0]))) {
641
            return $this->raiseError($params[0] . ' is not a valid state (stable/beta/alpha/devel/etc.) try "pear help list-upgrades"');
541
            return $this->raiseError($params[0] . ' is not a valid state (stable/beta/alpha/devel/etc.) try "pear help list-upgrades"');
642
        }
542
        }
643
 
543
        $savechannel = $channel = $this->config->get('default_channel');
644
        $savechannel = $channel = $this->config->get('default_channel');
544
        $reg = &$this->config->getRegistry();
645
        $reg = &$this->config->getRegistry();
545
        foreach ($reg->listChannels() as $channel) {
646
        foreach ($reg->listChannels() as $channel) {
546
            $inst = array_flip($reg->listPackages($channel));
647
            $inst = array_flip($reg->listPackages($channel));
-
 
648
            if (!count($inst)) {
547
            if (!count($inst)) {
649
                continue;
548
                continue;
650
            }
549
            }
651
 
-
 
652
            if ($channel == '__uri') {
550
            if ($channel == '__uri') {
653
                continue;
551
                continue;
-
 
552
            }
654
            }
553
            $this->config->set('default_channel', $channel);
-
 
554
            if (empty($params[0])) {
-
 
555
                $state = $this->config->get('preferred_state');
655
 
556
            } else {
656
            $this->config->set('default_channel', $channel);
557
                $state = $params[0];
657
            $state = empty($params[0]) ? $this->config->get('preferred_state') : $params[0];
558
            }
658
 
559
            $caption = $channel . ' Available Upgrades';
659
            $caption = $channel . ' Available Upgrades';
560
            $chan = $reg->getChannel($channel);
660
            $chan = $reg->getChannel($channel);
-
 
661
            if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
-
 
662
                return $e;
-
 
663
            }
-
 
664
 
561
            if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
665
            $latest = array();
-
 
666
            $base2  = false;
562
                return $e;
667
            $preferred_mirror = $this->config->get('preferred_mirror');
-
 
668
            if ($chan->supportsREST($preferred_mirror) &&
-
 
669
                (
-
 
670
                   ($base2 = $chan->getBaseURL('REST1.3', $preferred_mirror))
-
 
671
                   || ($base  = $chan->getBaseURL('REST1.0', $preferred_mirror))
-
 
672
                )
-
 
673
 
-
 
674
            ) {
-
 
675
                if ($base2) {
563
            }
676
                    $rest = &$this->config->getREST('1.3', array());
-
 
677
                    $base = $base2;
-
 
678
                } else {
564
            if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
679
                    $rest = &$this->config->getREST('1.0', array());
565
                  $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
680
                }
566
                $rest = &$this->config->getREST('1.0', array());
681
 
567
                if (empty($state) || $state == 'any') {
682
                if (empty($state) || $state == 'any') {
568
                    $state = false;
683
                    $state = false;
-
 
684
                } else {
569
                } else {
685
                    $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
570
                    $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
686
                }
571
                }
687
 
572
                PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
573
                $latest = $rest->listLatestUpgrades($base, $state, $inst, $channel, $reg);
-
 
574
                PEAR::staticPopErrorHandling();
-
 
575
            } else {
-
 
576
                $remote = &$this->config->getRemote();
-
 
577
                $remote->pushErrorHandling(PEAR_ERROR_RETURN);
-
 
578
                if (empty($state) || $state == 'any') {
-
 
579
                    $latest = $remote->call("package.listLatestReleases");
-
 
580
                } else {
-
 
581
                    $latest = $remote->call("package.listLatestReleases", $state);
-
 
582
                    $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
688
                PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
689
                $latest = $rest->listLatestUpgrades($base, $state, $inst, $channel, $reg);
583
                }
690
                PEAR::staticPopErrorHandling();
584
                $remote->popErrorHandling();
691
            }
585
            }
692
 
586
            if (PEAR::isError($latest)) {
693
            if (PEAR::isError($latest)) {
-
 
694
                $this->ui->outputData($latest->getMessage());
587
                $this->ui->outputData($latest->getMessage());
695
                continue;
588
                continue;
696
            }
589
            }
697
 
590
            $caption .= ':';
698
            $caption .= ':';
591
            if (PEAR::isError($latest)) {
699
            if (PEAR::isError($latest)) {
-
 
700
                $this->config->set('default_channel', $savechannel);
592
                $this->config->set('default_channel', $savechannel);
701
                return $latest;
593
                return $latest;
702
            }
594
            }
703
 
595
            $data = array(
704
            $data = array(
-
 
705
                'caption' => $caption,
596
                'caption' => $caption,
706
                'border' => 1,
-
 
707
                'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'),
597
                'border' => 1,
708
                'channel' => $channel
598
                'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'),
709
                );
599
                );
710
 
600
            foreach ((array)$latest as $pkg => $info) {
711
            foreach ((array)$latest as $pkg => $info) {
601
                $package = strtolower($pkg);
712
                $package = strtolower($pkg);
602
                if (!isset($inst[$package])) {
713
                if (!isset($inst[$package])) {
-
 
714
                    // skip packages we don't have installed
603
                    // skip packages we don't have installed
715
                    continue;
604
                    continue;
716
                }
605
                }
717
 
606
                extract($info);
718
                extract($info);
607
                $inst_version = $reg->packageInfo($package, 'version', $channel);
719
                $inst_version = $reg->packageInfo($package, 'version', $channel);
608
                $inst_state   = $reg->packageInfo($package, 'release_state', $channel);
720
                $inst_state   = $reg->packageInfo($package, 'release_state', $channel);
609
                if (version_compare("$version", "$inst_version", "le")) {
721
                if (version_compare("$version", "$inst_version", "le")) {
-
 
722
                    // installed version is up-to-date
610
                    // installed version is up-to-date
723
                    continue;
611
                    continue;
724
                }
612
                }
725
 
613
                if ($filesize >= 20480) {
726
                if ($filesize >= 20480) {
614
                    $filesize += 1024 - ($filesize % 1024);
727
                    $filesize += 1024 - ($filesize % 1024);
615
                    $fs = sprintf("%dkB", $filesize / 1024);
728
                    $fs = sprintf("%dkB", $filesize / 1024);
616
                } elseif ($filesize > 0) {
729
                } elseif ($filesize > 0) {
617
                    $filesize += 103 - ($filesize % 103);
730
                    $filesize += 103 - ($filesize % 103);
618
                    $fs = sprintf("%.1fkB", $filesize / 1024.0);
731
                    $fs = sprintf("%.1fkB", $filesize / 1024.0);
-
 
732
                } else {
619
                } else {
733
                    $fs = "  -"; // XXX center instead
620
                    $fs = "  -"; // XXX center instead
734
                }
-
 
735
 
-
 
736
                $data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs);
-
 
737
            }
-
 
738
 
-
 
739
            if (isset($options['channelinfo'])) {
-
 
740
                if (empty($data['data'])) {
-
 
741
                    unset($data['headline']);
-
 
742
                    if (count($inst) == 0) {
-
 
743
                        $data['data'] = '(no packages installed)';
-
 
744
                    } else {
-
 
745
                        $data['data'] = '(no upgrades available)';
-
 
746
                    }
621
                }
747
                }
622
                $data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs);
748
                $this->ui->outputData($data, $command);
623
            }
749
            } else {
624
            if (empty($data['data'])) {
750
                if (empty($data['data'])) {
625
                $this->ui->outputData('Channel ' . $channel . ': No upgrades available');
751
                    $this->ui->outputData('Channel ' . $channel . ': No upgrades available');
626
            } else {
752
                } else {
-
 
753
                    $this->ui->outputData($data, $command);
-
 
754
                }
627
                $this->ui->outputData($data, $command);
755
            }
628
            }
756
        }
629
        }
757
 
Line 630... Line -...
630
        $this->config->set('default_channel', $savechannel);
-
 
631
        return true;
-
 
632
    }
-
 
633
 
758
        $this->config->set('default_channel', $savechannel);
634
    // }}}
759
        return true;
635
    // {{{ doClearCache()
760
    }
636
 
761
 
637
    function doClearCache($command, $options, $params)
762
    function doClearCache($command, $options, $params)
638
    {
763
    {
639
        $cache_dir = $this->config->get('cache_dir');
764
        $cache_dir = $this->config->get('cache_dir');
640
        $verbose = $this->config->get('verbose');
765
        $verbose   = $this->config->get('verbose');
-
 
766
        $output = '';
641
        $output = '';
767
        if (!file_exists($cache_dir) || !is_dir($cache_dir)) {
642
        if (!file_exists($cache_dir) || !is_dir($cache_dir)) {
768
            return $this->raiseError("$cache_dir does not exist or is not a directory");
643
            return $this->raiseError("$cache_dir does not exist or is not a directory");
769
        }
-
 
770
 
644
        }
771
        if (!($dp = @opendir($cache_dir))) {
645
        if (!($dp = @opendir($cache_dir))) {
772
            return $this->raiseError("opendir($cache_dir) failed: $php_errormsg");
646
            return $this->raiseError("opendir($cache_dir) failed: $php_errormsg");
773
        }
-
 
774
 
647
        }
775
        if ($verbose >= 1) {
648
        if ($verbose >= 1) {
776
            $output .= "reading directory $cache_dir\n";
649
            $output .= "reading directory $cache_dir\n";
-
 
650
        }
777
        }
651
        $num = 0;
778
 
652
        while ($ent = readdir($dp)) {
779
        $num = 0;
653
            if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}$/', $ent) ||
780
        while ($ent = readdir($dp)) {
654
                  preg_match('/rest.cache(file|id)$/', $ent)) {
781
            if (preg_match('/rest.cache(file|id)\\z/', $ent)) {
655
                $path = $cache_dir . DIRECTORY_SEPARATOR . $ent;
782
                $path = $cache_dir . DIRECTORY_SEPARATOR . $ent;
656
                if (file_exists($path)) {
783
                if (file_exists($path)) {
657
                    $ok = @unlink($path);
784
                    $ok = @unlink($path);
-
 
785
                } else {
658
                } else {
786
                    $ok = false;
659
                    $ok = false;
787
                    $php_errormsg = '';
660
                    $php_errormsg = '';
788
                }
661
                }
789
 
662
                if ($ok) {
790
                if ($ok) {
663
                    if ($verbose >= 2) {
791
                    if ($verbose >= 2) {
664
                        $output .= "deleted $path\n";
792
                        $output .= "deleted $path\n";
665
                    }
793
                    }
666
                    $num++;
794
                    $num++;
667
                } elseif ($verbose >= 1) {
795
                } elseif ($verbose >= 1) {
-
 
796
                    $output .= "failed to delete $path $php_errormsg\n";
668
                    $output .= "failed to delete $path $php_errormsg\n";
797
                }
669
                }
798
            }
670
            }
799
        }
671
        }
800
 
-
 
801
        closedir($dp);
672
        closedir($dp);
802
        if ($verbose >= 1) {
673
        if ($verbose >= 1) {
803
            $output .= "$num cache entries cleared\n";
674
            $output .= "$num cache entries cleared\n";
804
        }
675
        }
-
 
676
        $this->ui->outputData(rtrim($output), $command);
-
 
677
        return $num;
805
 
678
    }
-
 
679
 
-