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

Bug #16894 Custom Role Including failed.
Submitted: 2009-12-09 19:22 UTC
From: thirakawa Assigned:
Status: Open Package: PEAR (version 1.9.0)
PHP Version: 5.2.5 OS: UNIX/Windows
Roadmaps: (Not assigned)    
Subscription  


 [2009-12-09 19:22 UTC] thirakawa (Takayuki Hirakawa)
Description: ------------ Including information about custom roles will be failed when I try to create to instance of PEAR_Config. PEAR_Config: line 1094 function _addConfigVars($class, $vars) { static $called = array(); if (isset($called[$class])) { return; } those part of code will reject to set custom role information. I traced source code but I think those part doesn't make sense. I think its BUG. Thanks

Comments

 [2009-12-10 05:39 UTC] doconnor (Daniel O'Connor)
ew @ the static behaviour. Uhm, got some reproduce code?
 [2009-12-10 09:26 UTC] thirakawa (Takayuki Hirakawa)
Custom Role CLass --------------------------------------- class PEAR_Installer_Role_Site extends PEAR_Installer_Role_Common {} --------------------------------------- Site.xml --------------------------------------- <role version="1.0"> <releasetypes>php</releasetypes> <releasetypes>extsrc</releasetypes> <releasetypes>extbin</releasetypes> <releasetypes>zendextsrc</releasetypes> <releasetypes>zendextbin</releasetypes> <installable>1</installable> <locationconfig>site_dir</locationconfig> <honorsbaseinstall>1</honorsbaseinstall> <unusualbaseinstall /> <phpfile>1</phpfile> <executable /> <phpextension /> <config_vars> <site_dir> <type>directory</type> <default/> <doc>Path for Onyx Site</doc> <prompt>Onyx Site Path</prompt> <group>File Locations</group> </site_dir> </config_vars> </role> --------------------------------------- Here is sample code. --------------------------------------- require_once('PEAR/Config.php'); $customRoleClass = 'PEAR_Installer_Role_Site'; $systemConf = 'C:\xampp\php\pearsys.ini'; $localConf = 'local/pear.ini'; // System Wide PEAR Environment $config = new PEAR_Config('', $systemConf); if (isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$customRoleClass])){ var_dump($GLOBALS['_PEAR_INSTALLER_ROLES'][$customRoleClass]); // fine } var_dump($config->configuration_info['site_dir']); // fine // local PEAR environment $local = new PEAR_Config($localConf, $systemConf); var_dump($local->configuration_info['site_dir']); // this will output NULL --------------------------------------- my custrom role class is located on system wide PEAR environment. As you mentioned, it's about static behavior. static variable $called['className'] will be set after create instance of system wide PEAR_Config. so, PEAR_Config# addConfigVars won't set custom role information when I try to create local (another) PEAR_Config instance. the sample code is just for explanation. my problem is writing unit test. I usually use PHPUnit on system wide PEAR environment.and test cases located on local environment. so, test case that using custom roll is failed because of static behavior. if variable $called was member variable of PEAR_Config, it will be fine. Let me know if you have another way to solve this probles or some recommendation. Thank you.