Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #9695 sgl-list-all command problem
Submitted: 2006-12-26 14:30 UTC
From: mick Assigned: cellog
Status: Closed Package: PEAR (version 1.5.0RC2)
PHP Version: 5.0.5 OS: Apache 2.0
Roadmaps: (Not assigned)    
Subscription  


 [2006-12-26 14:30 UTC] mick (Michael Heuberger)
Description: ------------ Hello guys I am excperiencing a PEAR Error when running the command "sgl-list-all" on channel pear.php.net ... see raised PEAR ERROR in backtrace below, it says "Invalid argument supplied for foreach()" from file /home/httpd/vhosts/deafzone.ch/private/lib/pear/PEAR/REST/11.php at line 164. See test script for code I use. When I put @ at $cmd->run($command, $opts, $params); then it works, I see the list but not all packages are listed. For example the validate package is missing or the important bundle pear/Net_UserAgent_Detect is missing. I believe it's a bug because $packageinfo['deps'] may be null or not initialized correctly. Thank you for any comments and greetings from Switzerland Michael Heuberger Test script: --------------- protected function cmd_doRequest(SGL_Registry $inputRegistry, SGL_Output $output) { SGL::logMessage(null, PEAR_LOG_DEBUG); ini_set('max_execution_time', 180); putenv('PHP_PEAR_INSTALL_DIR=' . SGL_LIB_PEAR_DIR); define('PEAR_Frontend_Web', 1); $pearConfigPath = $this->getPearConfigPath(); // init PEAR Installer Code and WebFrontend $config = $GLOBALS['_PEAR_Frontend_Web_config'] = PEAR_Config::singleton($pearConfigPath, $pearConfigPath); $config->set('default_channel', $inputRegistry->channel); PEAR_Command::setFrontendType('WebSGL'); if ($inputRegistry->command == 'sgl-install') { if (!is_writable(SGL_MOD_DIR)) { return SGL::raiseError('Your module directory must be writable '. 'by the webserver before you attempt this command!', SGL_ERROR_FILEUNWRITABLE); } } if (!is_writable(SGL_LIB_PEAR_DIR)) { return SGL::raiseError('Your PEAR directory must be writable by the webserver!', SGL_ERROR_FILEUNWRITABLE); } if (empty($inputRegistry->command)) { $inputRegistry->command = 'sgl-list-all'; } $opts = array(); if ($inputRegistry->mode) { $opts['mode'] = 'installed'; } switch ($inputRegistry->command) { case 'sgl-list-all': SGL::logMessage('Made it to list-all pear packages...', PEAR_LOG_DEBUG); $cache = SGL_Cache::singleton(); $cacheId = 'pear' . $inputRegistry->command . $inputRegistry->mode; $serialized = $cache->get($cacheId, 'pear'); if ($serialized) { $data = unserialize($serialized); if (PEAR::isError($data)) { return SGL::raiseError($data); } else { SGL::logMessage('Pear data from cache.', PEAR_LOG_DEBUG); } } else { $result = $this->runCommand($inputRegistry->command, $config, $inputRegistry->pkg, $opts); if (PEAR::isError($result)) { return SGL::raiseError($result); } else { $serialized = serialize($result); $cache->save($serialized, $cacheId, 'pear'); SGL::logMessage('Pear data from db.', PEAR_LOG_DEBUG); } } break; case 'sgl-install': case 'upgrade-all': $opts['onlyreqdeps'] = true; // install all required dependencies $opts['force'] = true; // will overwrite newer installed packages $opts['soft'] = true; // soft install, fail silently, or upgrade if already installed // use register only parameter only if nothing works... // $opts['register-only'] = true; // do not install files, only register the package as installed // continue there ... case 'sgl-uninstall': case 'update-channels': $result = $this->runCommand($inputRegistry->command, $config, $inputRegistry->pkg, $opts, true); if (PEAR::isError($result)) { return SGL::raiseError($result); } else { $this->cmd_redirectToDefault($inputRegistry, $output); } break; } if (!empty($GLOBALS['_PEAR_Frontend_Web_log'])) { SGL::raiseInfo($GLOBALS['_PEAR_Frontend_Web_log']); } if (!empty($_SESSION['_PEAR_Frontend_Web_LastError_log'])) { SGL::raiseWarning($_SESSION['_PEAR_Frontend_Web_LastError_log']); } if (isset($result['data'])) { $output->result = $result['data']; } return true; } private function runCommand($command, $config, $pkg, $opts, $readOutput = false) { $cmd = PEAR_Command::factory($command, $config); if (PEAR::isError($cmd)) { return $cmd; } else { $params = array($pkg); if ($readOutput) { ob_start(); } $result = $cmd->run($command, $opts, $params); if ($readOutput) { $pearOutput = ob_get_contents(); ob_end_clean(); } if(PEAR::isError($result) && !empty($pearOutput)) { // special hack ... it's ok so! SGL::raiseWarning($pearOutput, false); return false; } else { if (!empty($pearOutput)) { SGL::raiseInfo($pearOutput, false); } else if (empty($result)) { SGL::raiseInfo('Nothing happened.'); } } } return $result; } Actual result: -------------- MESSAGE: Invalid argument supplied for foreach() TYPE: Warning FILE: /home/httpd/vhosts/deafzone.ch/private/lib/pear/PEAR/REST/11.php LINE: 164 DEBUG INFO: 159 !isset($packageinfo['deps'][0])) { 160 $packageinfo['deps'] = array($packageinfo['deps']); 161 } 162 } 163 $d = false; 164 foreach ($packageinfo['deps'] as $dep) { 165 if ($dep['v'] == $latest) { 166 $d = unserialize($dep['d']); 167 } 168 } 169 if ($d) {

Comments

 [2006-12-26 15:22 UTC] cellog (Greg Beaver)
Thank you for taking the time to report a problem with the package. This problem may have been already fixed by a previous change that is in the CVS of the package. Please log into CVS with: cvs -d :pserver:cvsread@cvs.php.net:/repository login and check out the CVS repository of this package and upgrade cvs -d :pserver:cvsread@cvs.php.net:/repository co pear-core pear upgrade pear-core/package2.xml or pear upgrade pear-core/package.xml If you are able to reproduce the bug with the latest CVS, please change the status back to "Open". Again, thank you for your continued support of PEAR.
 [2006-12-26 15:57 UTC] mick
Thank you for your quick answer but I am driving this code on a virtual shared host with no root access. Thus I am using a custom PEAR directory. Or do you believe I can call "upgrade pear-core/package.xml" from the web frontend ui? Cheers Michael Heuberger
 [2006-12-26 23:11 UTC] cellog (Greg Beaver)
in that case, use this code in PEAR/REST/11.php starting at line 159 if (isset($packageinfo['deps'])) { if (!is_array($packageinfo['deps']) || !isset($packageinfo['deps'][0])) { $packageinfo['deps'] = array($packageinfo['deps']); } } $d = false; foreach ($packageinfo['deps'] as $dep) { if ($dep['v'] == $latest) { $d = unserialize($dep['d']); } } This is the code from CVS. As you can see, it will fix the problem you're experiencing. If it works, I will mark this as duplicate, since it was previously reported and fixed
 [2006-12-26 23:31 UTC] mick
Hello again Thank you. I already found exactly these code lines on my /PEAR/REST/11.php and the problem is still there. I believe I ran an upgrade with the devel-option enabled. I believe that $packageinfo['deps'] may be NULL in my case. Therefore I recommend to add an else-code block to fix it when isset($packageinfo['deps']) is not the case. Well, there is another small problem happening in relation to this problem. I cannot install the DB_Object Package because of the error message that no directory in the /bin/ can be made (mkdir error). Of course because of the virtual host without root access. When I add the register-only option, DB_Object can be installed but is running somehow very unstable. I am just writing this, maybye you see a relation to the main problem? Thank you, I am very curious about your next answer. Best regards Michael Heuberger
 [2007-01-03 21:40 UTC] cellog (Greg Beaver)
DB_DataObject installs a script, /bin is probably the script_dir configuration variable. Installing packages through a webpage on an OS with permissions is very tricky, and not recommended. I'll bet you've got a problem with the cache directory, which is your download_dir configuration variable. Set this to a world-writeable unique directory, perhaps /tmp/donotoverwritesgl/ and it might eliminate the problem. However, since you're seeing null, then yes, this is a bug in PEAR, but the DB_DataObject problem is not PEAR installer-related. If it was, you would get an obvious fatal error (not able to find DB/DataObject.php)
 [2007-01-04 15:46 UTC] mick
Hello Thank you but nothing helped me. Of course, I made all the directories world-wide-writeable with chmod 0777 And it's getting worser, two new problems have occured: a) Many important packages are listed in the category "local" when calling sgl-list-all, for example pear/Archive_Tar, pear/XML_Parser, pear/DB_DataObject and so on. But they should appear in their correct categories. I believe this is related to the main bug. b) When trying to upgrade Archive_Tar a strange error appears see below, even when all the directories are correct and writeable. It's really somehow buggy... thank you for any help! Mick --- ERROR MESSAGE WHEN UPGRADING Archive_Tar --- pear/pear dependency package "pear/Archive_Tar" installed version 1.3.2 is not the recommended version 1.3.1 downloading Archive_Tar-1.3.2.tgz ... Starting to download Archive_Tar-1.3.2.tgz (17,150 bytes) . . . ...done: 17,150 bytes Could not copy /home/httpd/vhosts/deafzone.ch/private/var/tmp/Archive_Tar/docs/Archive_Tar.txt to /home/httpd/vhosts/deafzone.ch/private/var/tmp/Archive_Tar/docs/Archive_Tar.txt.bak failed to open stream: No such file or directory ERROR: commit failed
 [2007-01-07 18:39 UTC] cellog (Greg Beaver)
Thank you for taking the time to report a problem with the package. This problem may have been already fixed by a previous change that is in the CVS of the package. Please log into CVS with: cvs -d :pserver:cvsread@cvs.php.net:/repository login and check out the CVS repository of this package and upgrade cvs -d :pserver:cvsread@cvs.php.net:/repository co pear-core pear upgrade pear-core/package2.xml or pear upgrade pear-core/package.xml If you are able to reproduce the bug with the latest CVS, please change the status back to "Open". Again, thank you for your continued support of PEAR.
 [2007-01-07 22:02 UTC] mick
Thanks, I made the upgrade with cvs and now, when I run the same script of mine, I see other errors a) unknown command `sgl-list-all' b) Fatal error: Call to a member function outputData() on a non-object in /home/httpd/vhosts/deafzone.ch/private/lib/pear/PEAR/Command/Channels.php on line 219 So what now? Do you want me to send you my php script? Cheers Michael H.
 [2007-01-08 05:05 UTC] cellog (Greg Beaver)
those problems are not related to the previous issue. Demian is better equipped to analyze how Seagull is supposed to integrate with PEAR, talk to him, and after things are squared away, if you find other bugs, please report them here.
 [2007-01-08 18:03 UTC] mick
Yes, right, I forgot to restore some code lines for seagull code after upgrading from cvs and now all bugs are come. it seems that the bug has been solved within the CVS for 1.50RC3 - thank you, ticket closed. Mick