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

Bug #11008 Default argument values override object properties in initialize()
Submitted: 2007-05-10 22:48 UTC
From: spaze Assigned: davidc
Status: Closed Package: Net_URL (version CVS)
PHP Version: 5.2.1 OS: Win32
Roadmaps: (Not assigned)    
Subscription  


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 : 28 + 20 = ?

 
 [2007-05-10 22:48 UTC] spaze (Michal Spacek)
Description: ------------ Regarding the revision 1.45 of URL.php there's a big showstopper in initialize(): In __construct() you set the object properties and then call the initialize() method with no arguments: $this->url = $url; $this->useBrackets = $useBrackets; $this->initialize(); But initialize() is declared with default argument values: function initialize($url = null, $useBrackets = true) and later you copy the arguments into object properties: $this->useBrackets = $useBrackets; $this->url = $url; So the $url passed to the contructor is not taken into care and the defaults are used. Plus sometimes you refer to the function argument instead of the object property: if (!preg_match('/^[a-z0-9]+:\/\//i', $url)) { In previous revisions (i.e. stable 1.36) everything works fine. Please find attached patch against 1.46 which fixes all the problems, thanks for reviewing. Test script: --------------- require_once 'Net/URL.php'; $dsn = 'imap://foo:bar@mail.example.com:143/INBOX'; $net_url =& new Net_URL($dsn); echo $net_url->host; Expected result: ---------------- mail.example.com Actual result: -------------- localhost

Comments

 [2007-05-11 01:56 UTC] davidc (David Coallier)
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.
 [2007-05-11 01:57 UTC] davidc (David Coallier)
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.