Re: Optionally include a script
| From: | bertrand Gugger | Date: | Thu, 03 Nov 2005 07:33:01 +0000 |
| Subject: | Re: Optionally include a script | ||
| References: | 1 2 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-3220@lists.php.net to get a copy of this message | ||
Bonjour
Justin Patrin wrote:
On 11/1/05, bertrand Gugger <bertrand@toggg.com> wrote:1) the *implementer* of the package: that's the case for drivers as MDB or 'schema' or 'alerter' as Net_Monitor, service provider as Net_SMS ... In that case, the implementer codes it himself , so should be aware of what s?he does. Then the raw require without any silencing is just fine, as you mentionned. The php warning mechanism does the job perfectly. Perhaps only the doc should emphasize what optional package is needed for which "driver". 2) The *end-user*: that's the case in Text_Wiki for certain rules as Plugin. (sorry, no other examples on top of my head) In that case, issuing a system wide Warning is just bad, as only the end-user currently editing h(er|is) wiki is concerned. Furthermore, that should not break the rest of the parsing. Only the resulting parsed data should contain a warning or just refuse to interpret the plugin tag: generally, the end-user controls the output and will immediatly correct it. Here, we can't avoid a include_path/file_exists mechanism ... OK, depending on the package's use of the feature, some caching mechanism could be advisable if intensively used. Again, sorry for my crap english... a+ -- bertrand "toggg" GuggerBonsoir, As discussed in the "Silencing @" thread, silencing optional includes can be very bad. Someone said it's bad design, but I know/encounter 2 cases: - a package has an optional dependency but has calls to it hard coded, how could pear installer notify it is there or not ? or should this package give an interface to force the caller to say: I have the dependency in, I agree ? e.g. Net_MonitorPackages with optional dependencies should not try to use them unless told to do so by the caller / configuration. If a package wishes to do automatic inclusion of optional dependencies they *must* use the include_path/file_exists set to make sure a file exists before including it. @ on includes is not ok.- a package provides dynamic , post installation possibly includes, there's no other ways as the include_path scan mentionned, imho e.g. Text_Wiki_Tiki , rule PluginYou mean a driver system, right? Same as for DB/MDB/etc? These should also not use @. Either an include should be done and cause an error/failure if it returns false and the PHP error should be left as-is, or the include_path/file_exists system should be used which would also raise an error. I'm in favor of no checking, just include or require it and let the dev deal with missing file warnings. In fact my 2 examples are 2 different cases on who give the name of the file to include: