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

Request #17789 Cache_Lite and HTTP_Request should be optional
Submitted: 2010-08-22 12:37 UTC
From: glen Assigned:
Status: Wont fix Package: Net_DNSBL (version 1.3.3)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2010-08-22 12:37 UTC] glen (Elan Ruusamäe)
Description: ------------ i can use Net_DNSBL normally, without actually using Net/DNSBL/SURBL.php class which try to use those classes. why not make Cache_Lite and HTTP_Request optional in package.xml

Comments

 [2011-02-10 21:31 UTC] hm2k (James Wade)
It's a tough one because they are required to make the SURBL component work, but the SURBL component itself is optional (DNSBL does not depend on it). Do you have an example of how this is handled else where?
 [2011-02-10 22:18 UTC] glen (Elan Ruusamäe)
no problem. here's simplified part of code i use: <?php require_once 'Net/DNSBL.php'; $ip = '127.0.0.1'; $d = new Net_DNSBL(); $r = $d->isListed($ip); var_dump($r); $ip = '127.0.0.2'; $d = new Net_DNSBL(); $r = $d->isListed($ip); var_dump($r); $ php test.php bool(false) bool(true)
 [2011-02-10 22:27 UTC] glen (Elan Ruusamäe)
oh sorry, i mis-read the question if you mean how to make some dependency optional, then <dependencies> has <optional> tag like <required> tag: <dependencies> ... <optional> <package> <name>PHP_Timer</name> <channel>pear.phpunit.de</channel> </package> </optional> above is from http://svn.php.net/viewvc/pear/packages/PHP_CodeSniffer/trunk/package.xml?view=log or if you mean how to make some subpart of code optional, i see several ways: 1. split the subcomponents to separate packages (-> maintenance hell) 2. just do require_once in code when needed and throw exception if missing some required part?
 [2011-02-11 02:00 UTC] hm2k (James Wade)
You got it right, third time lucky. I was really asking how you expect the package to handle required dependencies to an optional component... and if you had a working example from another package.
 [2011-02-11 11:40 UTC] glen (Elan Ruusamäe)
perhaps any package with factory method? function &factory($driver, $params = array()) { $driver = strtolower($driver); @include_once 'Mail/' . $driver . '.php'; $class = 'Mail_' . $driver; if (class_exists($class)) { $mailer = new $class($params); return $mailer; } else { return PEAR::raiseError('Unable to find class for driver ' . $driver); } } http://svn.php.net/viewvc/pear/packages/Mail/trunk/Mail.php the @include_once is important (not require_once) to avoid getting fatal error while loading the file
 [2011-02-11 13:36 UTC] nohn (Sebastian Nohn)
To me all discussed solutions except splitting up the package look ugly.
 [2011-02-11 16:36 UTC] hm2k (James Wade)
I see only two options: 1. Split into a separately maintained package or 2. The "driver" check method outlined by glen I would be willing to act upon option 2, but not option 1. Ultimately I'd have to leave it up to nohn to make the decision.
 [2011-02-11 21:10 UTC] nohn (Sebastian Nohn)
I doubt the "Driver" solution matches the PEAR coding standards and even if it does, it is ugly in my eyes. The only viable solution in my eyes would be splitting up the packages, I don't however see a real need for that, Cache_Lite and HTTP_Request are not uncommon packages and what's actually the reason to not install them?
 [2011-02-11 21:26 UTC] glen (Elan Ruusamäe)
question is not about is it common or not if i install extra package, it involves installing extra dependencies the extra packages include, some might now want that. altho i think it should be discussed rather in #pear irc channel than in this ticket, how to handle optional subdependencies in a pear package :)
 [2011-02-11 21:35 UTC] hm2k (James Wade)
Perhaps as a compromise (for now) the packages required by SURBL should be made optional in the packages.xml rather than required. At least until we we have a conclusive answer.
 [2011-02-11 21:50 UTC] nohn (Sebastian Nohn)
Net_DNSBL also depends on Net_DNS and dependencies which also may or may not be wanted by some people. Currently, Net_DNSBL_SURBL is part of Net_DNSBL, so the dependencies of Net_DNSBL_SURBL are also non optional dependencies of Net_DNSBL. If you don't feel OK with that, feel free to submit a patch that makes Net_DNSBL_SURBL a distinct package that depends on Net_DNSBL and probaly other packages while Net_DNSBL doesn't depend on the specific dependencies for Net_DNSBL_SURBL.
 [2011-02-11 21:53 UTC] hm2k (James Wade)
Nohn, you seem to be suggesting that this "Wont Fix". If that's the case, make it so, otherwise, propose a solution. Cheers.
 [2011-08-05 14:54 UTC] hm2k (James Wade)
-Status: Open +Status: Wont fix
I see no way to take this further.