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

Bug #10995 addPostInstallTask() should validate incoming tasks
Submitted: 2007-05-09 18:55 UTC
From: lsolesen Assigned: cellog
Status: Closed Package: PEAR_PackageFileManager
PHP Version: 5.2.1 OS: Windows Vista
Roadmaps: 1.6.1    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 37 - 21 = ?

 
 [2007-05-09 18:55 UTC] lsolesen (Lars Olesen)
Description: ------------ When using a minus (-) in a custom task, it cannot find the task, so validation fails. Used the chiaramdb2schema and chiara-managedb task from pear.chiaraquartet.net in a script. By adding this line: $task = str_replace(array($this->_tasksNs . ':', '_'), array('', ' '), $task); To class PEAR_PackageFile_v2::getTask() It seems it works. This also feels more correct, as underscore is used everywhere else in PEAR to map to a directory. The problem with the chiara-managedb task is that: PEAR_Task_Chiara_Managedb_rw::getName() returns the task name with an underscore. Changing this to a - though creates problems when instantiating the classes in this task later, as Chiara_Managedb would then be Chiara-Managedb, and thus is not found. Test script: --------------- <?php require_once 'PEAR/PackageFileManager2.php'; require_once 'PEAR/PackageFileManager/File.php'; require_once 'PEAR/Task/Postinstallscript/rw.php'; require_once 'PEAR/Task/Chiara/Managedb.php'; require_once 'PEAR/Task/Chiara/Managedb/rw.php'; require_once 'PEAR/Config.php'; require_once 'PEAR/Frontend.php'; error_reporting(E_ALL); PEAR::setErrorHandling(PEAR_ERROR_DIE); $pfm = new PEAR_PackageFileManager2(); $pfm->setOptions(array( 'packagedirectory' => dirname(__FILE__), 'baseinstalldir' => 'LiveUser/Install', 'filelistgenerator' => 'file', 'ignore' => array( '*.tgz', 'generate_package_xml.php', 'generate_database_xml.php', 'Install.php'), 'simpleoutput' => true, 'exceptions' => array( 'auth_schema.xml' => 'chiaramdb2schema', 'perm_schema.xml' => 'chiaramdb2schema' ) )); // managedb why is startSession() started under package creation $pfm->setPackage('LiveUser_Schema'); $pfm->setPackageType('php'); // this is a PEAR-style php script package $pfm->setSummary('A database schema for PEAR LiveUser'); $pfm->setDescription('This package contains a complex database schema for use with the PEAR LiveUser package.'); $pfm->setUri('http://localhost/'); $pfm->setAPIStability('alpha'); $pfm->setReleaseStability('alpha'); $pfm->setAPIVersion('0.0.1'); $pfm->setReleaseVersion('0.0.1'); $pfm->setNotes("* First release."); $pfm->addUsesRole('chiaramdb2schema', 'PEAR_Installer_Role_Chiaramdb2schema', 'pear.chiaraquartet.net'); $pfm->addUsesTask('chiara_managedb', 'PEAR_Task_Chiara_Managedb', 'pear.chiaraquartet.net'); $pfm->addMaintainer('lead','lsolesen','Lars Olesen','lars@legestue.net'); $pfm->setLicense('BSD', 'http://www.opensource.org/licenses/bsd-license.php'); $pfm->clearDeps(); $pfm->setPhpDep('5.0.0'); $pfm->setPearinstallerDep('1.4.3'); $pfm->addPackageDepWithChannel('required', 'PEAR_Installer_Role_Chiaramdb2schema', 'pear.chiaraquartet.net', '0.2.0'); $pfm->addPackageDepWithChannel('required', 'PEAR_Task_Chiara_Managedb', 'pear.chiaraquartet.net', '0.1.1'); $config = PEAR_Config::singleton(); $log = PEAR_Frontend::singleton(); $auth_task = new PEAR_Task_Chiara_Managedb_rw($pfm, $config, $log, array('name' => 'auth_schema.xml', 'role' => 'chiaramdb2schema')); $perm_task = new PEAR_Task_Chiara_Managedb_rw($pfm, $config, $log, array('name' => 'perm_schema.xml', 'role' => 'chiaramdb2schema')); $pfm->addPostinstallTask($auth_task, 'auth_schema.xml'); $pfm->addPostinstallTask($perm_task, 'perm_schema.xml'); $pfm->generateContents(); if (isset($_GET['make']) OR isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make') { if ($pfm->writePackageFile()) { exit('package file written'); } } else { $pfm->debugPackageFile(); } ?> Expected result: ---------------- Expect the package.xml to validate out of the box. Actual result: -------------- PEAR_PackageFileManager2 Error: Package validation failed: Error: Unknown task "tasks:chiara_managedb" passed in file <file name="perm_schema.xml"> Error: This package contains task "tasks:chiara_managedb" and requires package "channel://pear.chiaraquartet.net/PEAR_Task_Chiara_Managedb" to be used Error: Unknown task "tasks:chiara_managedb" passed in file <file name="auth_schema.xml"> Error: This package contains task "tasks:chiara_managedb" and requires package "channel://pear.chiaraquartet.net/PEAR_Task_Chiara_Managedb" to be used

Comments

 [2007-05-10 02:31 UTC] cellog (Greg Beaver)
if you pass a random task that isn't a postinstall task, it should error out - the bug in PEAR is bogus
 [2007-06-17 05:18 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.