stas 2002/06/05 22:17:06
Modified: Constants Constants.pm
. Changes
Log:
Document the possible misuses of the Apache::Constant constants
Submitted by: Per Einar Ellefsen <[EMAIL PROTECTED]>
Revision Changes Path
1.23 +33 -0 modperl/Constants/Constants.pm
Index: Constants.pm
===================================================================
RCS file: /home/cvs/modperl/Constants/Constants.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Constants.pm 24 Mar 2002 02:07:58 -0000 1.22
+++ Constants.pm 6 Jun 2002 05:17:05 -0000 1.23
@@ -243,6 +243,39 @@
=back
+=head1 Misuses
+
+You should be aware of the issues relating to using constant
+subroutines in Perl. For example this:
+
+ $r->custom_response(FORBIDDEN => "File size exceeds quota.");
+
+will not set a custom response for C<FORBIDDEN>, but for the string
+C<"FORBIDDEN">, which clearly isn't what is expected. You'll get an
+error like this:
+
+ [Tue Apr 23 19:46:14 2002] null: Argument "FORBIDDEN" isn't
+ numeric in subroutine entry at ...
+
+Therefore, the best solution is not to use the hash notation for
+things that don't require it:
+
+ $r->custom_response(FORBIDDEN, "File size exceeds quota.");
+
+Another important note is that instead of using HTTP codes, you should
+use designed for that purpose constants. Therefore, this is wrong:
+
+ sub handler { return 200; }
+
+The correct use is:
+
+ use Apache::Constants qw(OK);
+ sub handler { return OK; }
+
+Also remember that C<OK != HTTP_OK>.
+
=head1 AUTHORS
Doug MacEachern, Gisle Aas and h2xs
+
+=cut
1.651 +3 -0 modperl/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl/Changes,v
retrieving revision 1.650
retrieving revision 1.651
diff -u -r1.650 -r1.651
--- Changes 2 Jun 2002 03:07:13 -0000 1.650
+++ Changes 6 Jun 2002 05:17:05 -0000 1.651
@@ -10,6 +10,9 @@
=item 1.27_01-dev
+Document the possible misuses of the Apache::Constant constants [Per
+Einar Ellefsen <[EMAIL PROTECTED]>]
+
=item 1.27 - June 1, 2002
workaround Cwd bug in 5.8.0-RC1 that breaks apache configuration on solaris