On Wed, 2004-01-21 at 23:33, Stas Bekman wrote:
Philippe,
Adding this to httpd.conf:
PerlModule Does::not::ExiST
aborts the startup and prints the error message.
The following section should be an equivalent one and behave the same:
<Perl> use Apache::ServerUtil; my $s = Apache->server->add_config(['PerlModule Does::not::ExiST']); </Perl>
but it doesn't fail. By tracing through I can see that we simply return the error message through add_config and expect the user to test for the error message? Most people won't think of doing that and will scratch their heads in mystery why things seem to be wrong, while the server has started. Besides it makes the above two snippets which do the same thing behave differently.
yes, and is definitely _not_ intuitive.
I suggest to change add_config methods to return void, and croak on error. Following is a partial patch w/o adjusting the return values to void.
Yes, and if people want to ->add_config and know if it fails can just use an eval block.
ok, now committed. (though quite a different implementation, since other wrappers call the general insert function and want to give a different error message on the failure.
A few remaining issues:
The error message goes:
[Thu Jan 22 15:14:23 2004] [warn] Syntax error at /home/stas/apache.org/mp2-vhost/t/conf/httpd.conf:41 $s->add_config() has failed: ...
I wasn't sure whether we need to include the $lines passed to add_config().
I also find it inconvenient to need to split the multiline section s/\n/ and feed it as a array ref. Why not allow to send a multiline section and split it internally?
Also any idea why does it say [warn] and not [error]? After all this is on Perl_croak.
Of course we still have the perlsections bug where a failing perlsection doesn't prevent from the server to happily continue its starting, so that croak below won't kill the server. it'd be very handy to get it fixed, hint, hint ;)
That is not a bug, it's a feature, or a documentation bug.
That's what $Apache::Server::StrictPerlSections is for
Notice that by default, perl sections _will_ print a warning (so with your croak patch):
[warn] Syntax error at t/conf/extra.last.conf:74 Can't locate Does/not/ExiST.pm in @INC (@INC contains:[...]) at (eval 81) line 3.
oh, here it is again [warn] and not [error]
And if you set StrictPerlSections, you'll get a fatal error and the server startup will abort.
AFAIK, the fact that a syntax error in a <Perl> sections in mp1 aborts server startup is a bug ...
Why calling 'PerlRequire foo.pl' and having it fail cause an abort on the start is not a bug, but the same code failing from the <Perl> sections is a bug? I can't see why anybody will want to continue with the startup if something fails. They could run it in eval block if they wanted to ignore the failures. I don't think $Apache::Server::StrictPerlSections is needed at all. Please correct me if I'm wrong.
I would possibly suggest making Apache::Server::StrictPerlSections = 1 by default, maybe.
+1 to make it the default.
In any case, I'm also not sure about the name StrictPerlSections, as it makes me think of 'use strict' and not of the possibility to ignore errors.
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]