Parent Directory
|
Revision Log
|
Patch
--- perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod 2005/04/03 00:53:08 159854 +++ perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod 2005/04/03 01:04:11 159855 @@ -18,7 +18,7 @@ L<porting Perl modules|docs::2.0::user:: about L<porting XS modules|docs::2.0::devel::porting::porting>). As it will be explained in details later, loading -C<L<Apache::compat|docs::2.0::api::Apache::compat>> at the server +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> at the server startup, should make the code running properly under 1.0 work under mod_perl 2.0. If you want to port your code to mod_perl 2.0 or writing from scratch and not concerned about backwards compatibility, this @@ -131,7 +131,7 @@ If you need to use the same I<httpd.conf =head2 C<$Apache::Server::StrictPerlSections> In mod_perl 2.0, C<L<E<lt>PerlE<gt> -sections|docs::2.0::api::Apache::PerlSections>> errors are now always +sections|docs::2.0::api::Apache2::PerlSections>> errors are now always fatal. Any error in them will cause an immediate server startup abort, dumping the error to STDERR. To avoid this, C<eval {}> can be used to trap errors and ignore them. In mod_perl 1.0, C<strict> was somewhat @@ -143,8 +143,8 @@ of a misnomer. =head2 C<$Apache::Server::SaveConfig> C<$Apache::Server::SaveConfig> has been renamed to -C<$Apache::PerlSections::Save>. see C<L<E<lt>PerlE<gt> -sections|docs::2.0::api::Apache::PerlSections>> for more information +C<$Apache2::PerlSections::Save>. see C<L<E<lt>PerlE<gt> +sections|docs::2.0::api::Apache2::PerlSections>> for more information on this global variable. @@ -212,7 +212,7 @@ mod_perl 2.0 is trying hard to be back c gain a complete compatibilty with 1.0 while running under 2.0, you should load the compatibility module as early as possible: - use Apache::compat; + use Apache2::compat; at the server startup. And unless there are forgotten things or bugs, your code should work without any changes under 2.0 series. @@ -225,44 +225,6 @@ improvement. This document explains what APIs have changed and what new APIs should be used instead. -If you have mod_perl 1.0 and 2.0 installed on the same system and the -two use the same perl libraries directory (e.g. I</usr/lib/perl5>), to -use mod_perl 2.0 make sure to load first the C<Apache2> module which -will perform the necessary adjustments to C<@INC>. - - use Apache2; # if you have 1.0 and 2.0 installed - use Apache::compat; - -So if before loading C<Apache2.pm> the C<@INC> array consisted of: - - /home/stas/perl/ithread/lib/5.8.0/i686-linux-thread-multi - /home/stas/perl/ithread/lib/5.8.0 - /home/stas/perl/ithread/lib/site_perl/5.8.0/i686-linux-thread-multi - /home/stas/perl/ithread/lib/site_perl/5.8.0 - /home/stas/perl/ithread/lib/site_perl - . - -It will now look as: - - /home/stas/perl/ithread/lib/site_perl/5.8.0/i686-linux-thread-multi/Apache2 - /home/stas/perl/ithread/lib/5.8.0/i686-linux-thread-multi - /home/stas/perl/ithread/lib/5.8.0 - /home/stas/perl/ithread/lib/site_perl/5.8.0/i686-linux-thread-multi - /home/stas/perl/ithread/lib/site_perl/5.8.0 - /home/stas/perl/ithread/lib/site_perl - . - -Notice that a new directory was prepended to the search path, so if -for example the code attempts to load C<Apache::RequestRec> and there -are two versions of this module undef -I</home/stas/perl/ithread/lib/site_perl/>: - - 5.8.0/i686-linux-thread-multi/Apache/RequestRec.pm - 5.8.0/i686-linux-thread-multi/Apache2/Apache/RequestRec.pm - -The mod_perl 2.0 version will be loaded first, because the directory -I<5.8.0/i686-linux-thread-multi/Apache2> is coming before the -directory I<5.8.0/i686-linux-thread-multi> in C<@INC>. Finally, mod_perl 2.0 has all its methods spread across many modules. In order to use these methods the modules containing them @@ -292,7 +254,7 @@ to save memory. C<Apache::Registry>, C<Apache::PerlRun> and other modules from the registry family now live in the C<ModPerl::> namespace. In mod_perl 2.0 we put mod_perl specific functionality into the C<ModPerl::> -namespace, similar to C<APR::> and C<Apache::> which are used for apr +namespace, similar to C<APR::> and C<Apache2::> which are used for apr and apache features, respectively. At this moment @@ -385,7 +347,7 @@ C<Apache::Constants> has been replaced b =over -=item C<L<Apache::Const|docs::2.0::api::Apache::Const>> +=item C<L<Apache2::Const|docs::2.0::api::Apache2::Const>> Apache constants @@ -404,7 +366,7 @@ constants they provide. META: add the info how to perform the transition. XXX: may be write a script, which can tell you how to port the constants to 2.0? Currently -C<L<Apache::compat|docs::2.0::api::Apache::compat>> doesn't provide a +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> doesn't provide a complete back compatibility layer. @@ -420,7 +382,7 @@ complete back compatibility layer. If the same codebase is used for both mod_perl generations, the following technique can be used for using constants: - package MyApache::Foo; + package MyApache2::Foo; use strict; use warnings; @@ -430,8 +392,8 @@ following technique can be used for usin BEGIN { if (MP2) { - require Apache::Const; - Apache::Const->import(-compile => qw(OK DECLINED)); + require Apache2::Const; + Apache2::Const->import(-compile => qw(OK DECLINED)); } else { require Apache::Constants; @@ -441,13 +403,13 @@ following technique can be used for usin sub handler { # ... - return MP2 ? Apache::OK : Apache::Constants::OK; + return MP2 ? Apache2::OK : Apache::Constants::OK; } 1; Notice that if you don't use the idiom: - return MP2 ? Apache::OK : Apache::Constants::OK; + return MP2 ? Apache2::OK : Apache::Constants::OK; but something like the following: @@ -457,7 +419,7 @@ but something like the following: } sub handler2 { ... - return Apache::OK(); + return Apache2::OK(); } You need to add C<()>. If you don't do that, let's say that you run @@ -502,7 +464,7 @@ This will work in both mod_perl generati =head2 C<SERVER_VERSION()> C<Apache::Constants::SERVER_VERSION()> has been replaced with -C<L<Apache::ServerUtil::get_server_version()|docs::2.0::api::Apache::ServerUtil/C_get_server_version_>>. +C<L<Apache2::ServerUtil::get_server_version()|docs::2.0::api::Apache2::ServerUtil/C_get_server_version_>>. @@ -586,7 +548,7 @@ C<$mod_perl::VERSION>: =head2 C<Apache-E<gt>request> -C<L<Apache-E<gt>request|docs::2.0::api::Apache::RequestUtil/C_request_>> +C<L<Apache-E<gt>request|docs::2.0::api::Apache2::RequestUtil/C_request_>> usage should be avoided under mod_perl 2.0 C<$r> should be passed around as an argument instead (or in the worst case maintain your own global variable). Since your application may run under under threaded @@ -607,7 +569,7 @@ into something like: sub handler { print "Content-type: text/plain\n\n"; print "Hello"; - return Apache::OK; + return Apache2::OK; } where the C<handler()> function always receives C<$r> as an argument, @@ -636,7 +598,7 @@ it'll really be converted into something print "Content-type: text/plain\n\n"; } print "Hello" - return Apache::OK; + return Apache2::OK; } The script works under both mod_perl and mod_cgi. @@ -671,16 +633,16 @@ setting it in the handler that has an ac following skeleton for an I<authen> phase handler makes the C<Apache-E<gt>request> available in the calls made from it: - package MyApache::Auth; + package MyApache2::Auth; - # PerlAuthenHandler MyApache::Auth + # PerlAuthenHandler MyApache2::Auth - use Apache::RequestUtil (); + use Apache2::RequestUtil (); #... sub handler { my $r = shift; - Apache->request($r); - # do some calls that rely on Apache->request being available + Apache2->request($r); + # do some calls that rely on Apache2->request being available #... } @@ -692,7 +654,7 @@ C<Apache-E<gt>request> available in the =head2 C<Apache-E<gt>define> C<Apache-E<gt>define> has been replaced with -C<L<Apache::ServerUtil::exists_config_define()|docs::2.0::api::Apache::ServerUtil/C_exists_config_define_>>. +C<L<Apache2::ServerUtil::exists_config_define()|docs::2.0::api::Apache2::ServerUtil/C_exists_config_define_>>. @@ -710,13 +672,13 @@ can always stack handlers. =head2 C<Apache-E<gt>untaint> C<Apache-E<gt>untaint> has moved to -C<L<Apache::ModPerl::Util::untaint()|docs::2.0::api::ModPerl::Util/C_untaint_>> +C<L<Apache2::ModPerl::Util::untaint()|docs::2.0::api::ModPerl::Util/C_untaint_>> and now is a function, rather a class method. It'll will untaint all its arguments. You shouldn't be using this function unless you know what you are doing. Refer to the I<perlsec> manpage for more information. -C<L<Apache::compat|docs::2.0::api::Apache::compat>> provides the +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> provides the backward compatible with mod_perl 1.0 implementation. @@ -726,38 +688,38 @@ backward compatible with mod_perl 1.0 im =head2 C<Apache-E<gt>get_handlers> To get handlers for the server level, mod_perl 2.0 code should use -C<L<Apache::ServerUtil::get_handlers()|docs::2.0::api::Apache::ServerUtil/C_get_handlers_>>: +C<L<Apache2::ServerUtil::get_handlers()|docs::2.0::api::Apache2::ServerUtil/C_get_handlers_>>: $s->get_handlers(...); or: - Apache->server->get_handlers(...); + Apache2->server->get_handlers(...); C<Apache-E<gt>get_handlers> is avalable via -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. See also -C<L<Apache::RequestUtil::get_handlers()|docs::2.0::api::Apache::RequestUtil/C_get_handlers_>>. +C<L<Apache2::RequestUtil::get_handlers()|docs::2.0::api::Apache2::RequestUtil/C_get_handlers_>>. =head2 C<Apache-E<gt>push_handlers> To push handlers at the server level, mod_perl 2.0 code should use -C<L<Apache::ServerUtil::push_handlers()|docs::2.0::api::Apache::ServerUtil/C_push_handlers_>>: +C<L<Apache2::ServerUtil::push_handlers()|docs::2.0::api::Apache2::ServerUtil/C_push_handlers_>>: $s->push_handlers(...); or: - Apache->server->push_handlers(...); + Apache2->server->push_handlers(...); C<Apache-E<gt>push_handlers> is avalable via -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. See also -C<L<Apache::RequestUtil::push_handlers()|docs::2.0::api::Apache::RequestUtil/C_push_handlers_>>. +C<L<Apache2::RequestUtil::push_handlers()|docs::2.0::api::Apache2::RequestUtil/C_push_handlers_>>. @@ -765,16 +727,16 @@ C<L<Apache::RequestUtil::push_handlers() =head2 C<Apache-E<gt>set_handlers> To set handlers at the server level, mod_perl 2.0 code should use -C<L<Apache::ServerUtil::set_handlers()|docs::2.0::api::Apache::ServerUtil/C_set_handlers_>>: +C<L<Apache2::ServerUtil::set_handlers()|docs::2.0::api::Apache2::ServerUtil/C_set_handlers_>>: $s->set_handlers(...); or: - Apache->server->set_handlers(...); + Apache2->server->set_handlers(...); C<Apache-E<gt>set_handlers> is avalable via -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. To reset the list of handlers, instead of doing: @@ -789,7 +751,7 @@ or $r->set_handlers(PerlAuthenHandler => undef); See also -C<L<Apache::RequestUtil::set_handlers()|docs::2.0::api::Apache::RequestUtil/C_set_handlers_>>. +C<L<Apache2::RequestUtil::set_handlers()|docs::2.0::api::Apache2::RequestUtil/C_set_handlers_>>. @@ -799,16 +761,16 @@ C<L<Apache::RequestUtil::set_handlers()| =head2 C<Apache-E<gt>httpd_conf> C<Apache-E<gt>httpd_conf> is now -C<L<$s-E<gt>add_config|docs::2.0::api::Apache::ServerUtil/C_add_config_>>: +C<L<$s-E<gt>add_config|docs::2.0::api::Apache2::ServerUtil/C_add_config_>>: - require Apache::ServerUtil; - Apache->server->add_config(['require valid-user']); + require Apache2::ServerUtil; + Apache2->server->add_config(['require valid-user']); C<Apache-E<gt>httpd_conf> is avalable via -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. See also -C<L<Apache::RequestUtil::add_config()|docs::2.0::api::Apache::RequestUtil/C_add_config_>>. +C<L<Apache2::RequestUtil::add_config()|docs::2.0::api::Apache2::RequestUtil/C_add_config_>>. @@ -821,7 +783,7 @@ API. Use C<CGI::Util::unescape> instead (http://search.cpan.org/dist/CGI.pm/CGI/Util.pm). It is also available via -C<L<Apache::compat|docs::2.0::api::Apache::compat>> +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> for backwards compatibility. @@ -856,12 +818,12 @@ extensions writers. C<Apache::log_error()> is not available in mod_perl 2.0 API. You can use -C<L<Apache::Log::log_error()|docs::2.0::api::Apache::Log/C__s_E_gt_log_error_>>: +C<L<Apache2::Log::log_error()|docs::2.0::api::Apache2::Log/C__s_E_gt_log_error_>>: - Apache->server->log_error + Apache2->server->log_error instead. See the -C<L<Apache::Log|docs::2.0::api::Apache::Log>> manpage. +C<L<Apache2::Log|docs::2.0::api::Apache2::Log>> manpage. @@ -870,8 +832,8 @@ C<L<Apache::Log|docs::2.0::api::Apache:: =head2 C<Apache-E<gt>warn> C<$Apache-E<gt>warn> has been removed and exists only in -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. Choose another -C<L<Apache::Log|docs::2.0::api::Apache::Log>> method. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. Choose another +C<L<Apache2::Log|docs::2.0::api::Apache2::Log>> method. @@ -879,15 +841,15 @@ C<L<Apache::Log|docs::2.0::api::Apache:: =head2 C<Apache::warn> C<$Apache::warn> has been removed and exists only in -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. Choose another -C<L<Apache::Log|docs::2.0::api::Apache::Log>> method. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. Choose another +C<L<Apache2::Log|docs::2.0::api::Apache2::Log>> method. =head2 C<Apache::module()> C<Apache::module()> has been replaced with the function -C<L<Apache::Module::loaded()|docs::2.0::api::Apache::Module/C_loaded_>>, +C<L<Apache2::Module::loaded()|docs::2.0::api::Apache2::Module/C_loaded_>>, which now accepts a single argument: the module name. @@ -920,14 +882,14 @@ instead. =head2 C<Apache::Module-E<gt>top_module> C<Apache::Module-E<gt>top_module> has been replaced with the function -C<L<Apache::Module::top_module()|docs::2.0::api::Apache::Module/C_top_module_>>. +C<L<Apache2::Module::top_module()|docs::2.0::api::Apache2::Module/C_top_module_>>. =head2 C<Apache::Module-E<gt>get_config> C<Apache::Module-E<gt>get_config> has been replaced with the function -C<L<Apache::Module::get_config()|docs::2.0::api::Apache::Module/C_get_config_>>. +C<L<Apache2::Module::get_config()|docs::2.0::api::Apache2::Module/C_get_config_>>. @@ -944,7 +906,7 @@ C<L<Apache::Module::get_config()|docs::2 =head2 C<Apache::ModuleConfig-E<gt>get> C<Apache::ModuleConfig-E<gt>get> has been replaced with the function -C<L<Apache::Module::get_config()|docs::2.0::api::Apache::Module/C_get_config_>>. +C<L<Apache2::Module::get_config()|docs::2.0::api::Apache2::Module/C_get_config_>>. @@ -960,7 +922,7 @@ C<L<Apache::Module::get_config()|docs::2 =head2 C<$Apache::Server::CWD> C<$Apache::Server::CWD> is deprecated and exists only in -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. @@ -968,7 +930,7 @@ C<L<Apache::compat|docs::2.0::api::Apach =head2 C<$Apache::Server::AddPerlVersion> C<$Apache::Server::AddPerlVersion> is deprecated and exists only in -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. @@ -977,8 +939,8 @@ C<L<Apache::compat|docs::2.0::api::Apach C<$Apache::Server::Starting> and C<$Apache::Server::ReStarting> were replaced by -C<L<Apache::ServerUtil::restart_count()|docs::2.0::api::Apache::ServerUtil/C_restart_count_>>. -Though both exist in C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::ServerUtil::restart_count()|docs::2.0::api::Apache2::ServerUtil/C_restart_count_>>. +Though both exist in C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. @@ -986,8 +948,8 @@ Though both exist in C<L<Apache::compat| =head2 C<Apache::Server-E<gt>warn> C<Apache::Server-E<gt>warn> has been removed and exists only in -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. Choose another -C<L<Apache::Log|docs::2.0::api::Apache::Log>> method. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. Choose another +C<L<Apache2::Log|docs::2.0::api::Apache2::Log>> method. @@ -1007,11 +969,11 @@ C<L<APR::Pool::cleanup_register()|docs:: which accepts the pool object as the first argument instead of the server object. e.g.: - use Apache::ServerUtil (); + use Apache2::ServerUtil (); sub cleanup_callback { my($pool, $s) = @_; # your code comes here - Apache::OK; + Apache2::OK; } $s->push_handlers(PerlChildExitHandler => \&my_access); @@ -1023,7 +985,7 @@ C<L<PerlChildExitHandler|docs::2.0::user In order to register a cleanup handler to be run only once when the main server (not each child process) shuts down, you can register a cleanup handler with -C<L<server_shutdown_cleanup_register()|docs::2.0::api::Apache::ServerUtil/C_server_shutdown_cleanup_register_>>. +C<L<server_shutdown_cleanup_register()|docs::2.0::api::Apache2::ServerUtil/C_server_shutdown_cleanup_register_>>. @@ -1043,8 +1005,8 @@ supports it: http://httpd.apache.org/doc It's possible to emulate mod_perl 1.0 API doing: - sub Apache::Server::uid { $< } - sub Apache::Server::gid { $( } + sub Apache2::Server::uid { $< } + sub Apache2::Server::gid { $( } but the problem is that if the server is started as I<root>, but its child processes are run under a different username, e.g. I<nobody>, at @@ -1074,7 +1036,7 @@ See the next item =head2 C<$r-E<gt>cgi_var> C<$r-E<gt>cgi_env> and C<$r-E<gt>cgi_var> should be replaced with -C<L<$r-E<gt>subprocess_env|docs::2.0::api::Apache::RequestRec/C_subprocess_env_>>, +C<L<$r-E<gt>subprocess_env|docs::2.0::api::Apache2::RequestRec/C_subprocess_env_>>, which works identically in both mod_perl generations. @@ -1086,7 +1048,7 @@ C<L<ModPerl::Util::current_callback|docs and can be called for any of the phases, including those where C<$r> simply doesn't exist. -C<L<Apache::compat|docs::2.0::api::Apache::compat>> implements +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> implements C<$r-E<gt>current_callback> for backwards compatibility. @@ -1095,30 +1057,30 @@ C<$r-E<gt>current_callback> for backward =head2 C<$r-E<gt>cleanup_for_exec> C<$r-E<gt>cleanup_for_exec> wasn't a part of the mp1 core API, but -lived in a 3rd party module C<Apache::SubProcess>. That module's +lived in a 3rd party module C<Apache2::SubProcess>. That module's functionality is now a part of mod_perl 2.0 API. But Apache 2.0 doesn't need this function any longer. -C<L<Apache::compat|docs::2.0::api::Apache::compat>> implements +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> implements C<$r-E<gt>cleanup_for_exec> for backwards compatibility as a NOOP. See also the -C<L<Apache::SubProcess|docs::2.0::api::Apache::SubProcess>> manpage. +C<L<Apache2::SubProcess|docs::2.0::api::Apache2::SubProcess>> manpage. =head2 C<$r-E<gt>get_remote_host> -C<L<get_remote_host()|docs::2.0::api::Apache::Connection/C_get_remote_host_>> +C<L<get_remote_host()|docs::2.0::api::Apache2::Connection/C_get_remote_host_>> is now invoked on the C<L<connection -object|docs::2.0::api::Apache::Connection>>: +object|docs::2.0::api::Apache2::Connection>>: - use Apache::Connection; + use Apache2::Connection; $r->connection->get_remote_host(); C<$r-E<gt>get_remote_host> is available through -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. @@ -1131,7 +1093,7 @@ See the next item. =head2 C<$r-E<gt>args> in an Array Context -C<L<$r-E<gt>args|docs::2.0::api::Apache::RequestRec/C_args_>> in 2.0 +C<L<$r-E<gt>args|docs::2.0::api::Apache2::RequestRec/C_args_>> in 2.0 returns the query string without parsing and splitting it into an array. You can also set the query string by passing a string to this method. @@ -1173,7 +1135,7 @@ C<$r-E<gt>read($buf, $r-E<gt>headers_in- =back For now you can use C<CGI.pm> or the code in -C<L<Apache::compat|docs::2.0::api::Apache::compat>> (it's slower). +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> (it's slower). META: when C<Apache::Request> will be ported to mod_perl 2.0, you will have the fast C implementation of these functions. @@ -1199,11 +1161,11 @@ mod_perl|docs::2.0::user::coding::coding =head2 C<$r-E<gt>is_main> C<$r-E<gt>is_main> is not part of the mod_perl 2.0 API. Use -C<L<!$r-E<gt>main|docs::2.0::api::Apache::RequestRec/C_main_>> +C<L<!$r-E<gt>main|docs::2.0::api::Apache2::RequestRec/C_main_>> instead. Refer to the -C<L<Apache::RequestRec|docs::2.0::api::Apache::RequestRec/main__>> +C<L<Apache2::RequestRec|docs::2.0::api::Apache2::RequestRec/main__>> manpage. @@ -1211,13 +1173,13 @@ manpage. =head2 C<$r-E<gt>filename> When a new -C<L<$r-E<gt>filename|docs::2.0::api::Apache::RequestRec/C_filename_>> +C<L<$r-E<gt>filename|docs::2.0::api::Apache2::RequestRec/C_filename_>> is assigned Apache 2.0 doesn't update the finfo structure like it did -in Apache 1.3. If the old behavior is desired Apache::compat's -L<overriding|docs::2.0::api::Apache::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API> +in Apache 1.3. If the old behavior is desired Apache2::compat's +L<overriding|docs::2.0::api::Apache2::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API> can be used. Otherwise one should explicitly update the finfo struct when desired as explained in the -C<L<filename|docs::2.0::api::Apache::RequestRec/C_filename_>> API +C<L<filename|docs::2.0::api::Apache2::RequestRec/C_filename_>> API entry. @@ -1234,14 +1196,14 @@ invoke the C<L<APR::Finfo|docs::2.0::api methods on it. It's also possible to adjust the mod_perl 1.0 code using -Apache::compat's -L<overriding|docs::2.0::api::Apache::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>. +Apache2::compat's +L<overriding|docs::2.0::api::Apache2::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>. For example: - use Apache::compat; - Apache::compat::override_mp2_api('Apache::RequestRec::finfo'); + use Apache2::compat; + Apache2::compat::override_mp2_api('Apache2::RequestRec::finfo'); my $is_writable = -w $r->finfo; - Apache::compat::restore_mp2_api('Apache::RequestRec::finfo'); + Apache2::compat::restore_mp2_api('Apache2::RequestRec::finfo'); which internally does just the following: @@ -1256,7 +1218,7 @@ with the performance penalty of an extra don't want this extra call, you'd have to write: use APR::Finfo; - use Apache::RequestRec; + use Apache2::RequestRec; use APR::Const -compile => qw(WWRITE); my $is_writable = $r->finfo->protection & APR::WWRITE, @@ -1269,11 +1231,11 @@ information. =head2 C<$r-E<gt>notes> Similar to -C<L<headers_in()|docs::2.0::api::Apache::RequestRec/C_headers_in_>>, -C<L<headers_out()|docs::2.0::api::Apache::RequestRec/C_headers_out_>> +C<L<headers_in()|docs::2.0::api::Apache2::RequestRec/C_headers_in_>>, +C<L<headers_out()|docs::2.0::api::Apache2::RequestRec/C_headers_out_>> and -C<L<err_headers_out()|docs::2.0::api::Apache::RequestRec/C_err_headers_out_>> -in mod_perl 2.0, C<L<$r-E<gt>notes()|docs::2.0::api::Apache::RequestRec/C_notes_>> returns an +C<L<err_headers_out()|docs::2.0::api::Apache2::RequestRec/C_err_headers_out_>> +in mod_perl 2.0, C<L<$r-E<gt>notes()|docs::2.0::api::Apache2::RequestRec/C_notes_>> returns an C<L<APR::Table|docs::2.0::api::APR::Table>> object, which can be used as a tied hash or calling its I<L<get()|docs::2.0::api::APR::Table/C_get_>> / @@ -1282,16 +1244,16 @@ I<L<add()|docs::2.0::api::APR::Table/C_a I<L<unset()|docs::2.0::api::APR::Table/C_unset_>> methods. It's also possible to adjust the mod_perl 1.0 code using -C<L<Apache::compat|docs::2.0::api::Apache::compat>>'s -L<overriding|docs::2.0::api::Apache::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>: +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>'s +L<overriding|docs::2.0::api::Apache2::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>: - use Apache::compat; - Apache::compat::override_mp2_api('Apache::RequestRec::notes'); + use Apache2::compat; + Apache2::compat::override_mp2_api('Apache2::RequestRec::notes'); $r->notes($key => $val); $val = $r->notes($key); - Apache::compat::restore_mp2_api('Apache::RequestRec::notes'); + Apache2::compat::restore_mp2_api('Apache2::RequestRec::notes'); -See the C<L<Apache::RequestRec|docs::2.0::api::Apache::RequestRec>> +See the C<L<Apache2::RequestRec|docs::2.0::api::Apache2::RequestRec>> manpage. @@ -1313,10 +1275,10 @@ See C<L<$r-E<gt>err_header_out|/C__r_E_g C<header_in()>, C<header_out()> and C<err_header_out()> are not available in 2.0. Use -C<L<headers_in()|docs::2.0::api::Apache::RequestRec/C_headers_in_>>, -C<L<headers_out()|docs::2.0::api::Apache::RequestRec/C_headers_out_>> +C<L<headers_in()|docs::2.0::api::Apache2::RequestRec/C_headers_in_>>, +C<L<headers_out()|docs::2.0::api::Apache2::RequestRec/C_headers_out_>> and -C<L<err_headers_out()|docs::2.0::api::Apache::RequestRec/C_err_headers_out_>> +C<L<err_headers_out()|docs::2.0::api::Apache2::RequestRec/C_err_headers_out_>> instead (which should be used in 1.0 as well). For example you need to replace: @@ -1326,7 +1288,7 @@ with: $r->err_headers_out->{'Pragma'} = "no-cache"; -See the L<Apache::RequestRec> manpage. +See the L<Apache2::RequestRec> manpage. @@ -1364,14 +1326,14 @@ See the C<L<APR::Pool>> manpage. =head2 C<$r-E<gt>request> -Use C<L<Apache-E<gt>request|/C_Apache_E_gt_request_>>. +Use C<L<Apache2-E<gt>request|/C_Apache2_E_gt_request_>>. =head2 C<$r-E<gt>send_fd> mod_perl 2.0 provides a new method -C<L<sendfile()|docs::2.0::api::Apache::RequestIO/C_sendfile_>> instead +C<L<sendfile()|docs::2.0::api::Apache2::RequestIO/C_sendfile_>> instead of C<send_fd>, so if your code used to do: open my $fh, "<$file" or die "$!"; @@ -1383,7 +1345,7 @@ now all you need is: $r->sendfile($file); There is also a compatibility implementation of send_fd in pure perl -in C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +in C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. XXX: later we may provide a direct access to the real send_fd. That will be possible if we figure out how to portably convert PerlIO/FILE @@ -1396,9 +1358,9 @@ filehandle, so I'm not sure whether this =head2 C<$r-E<gt>send_http_header> This method is not needed in 2.0, though available in -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. 2.0 handlers only +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. 2.0 handlers only need to set the I<Content-type> via -C<L<$r-E<gt>content_type($type)|docs::2.0::api::Apache::RequestRec/C_content_type_>>. +C<L<$r-E<gt>content_type($type)|docs::2.0::api::Apache2::RequestRec/C_content_type_>>. @@ -1406,13 +1368,13 @@ C<L<$r-E<gt>content_type($type)|docs::2. =head2 C<$r-E<gt>server_root_relative> This method was replaced with -C<L<Apache::ServerUtil::server_root_relative()|docs::2.0::api::Apache::ServerUtil/C_server_root_relative_>> +C<L<Apache2::ServerUtil::server_root_relative()|docs::2.0::api::Apache2::ServerUtil/C_server_root_relative_>> function and its first argument is a I<pool> object. For example: # during request - $conf_dir = Apache::server_root_relative($r->pool, 'conf'); + $conf_dir = Apache2::server_root_relative($r->pool, 'conf'); # during startup - $conf_dir = Apache::server_root_relative($s->pool, 'conf'); + $conf_dir = Apache2::server_root_relative($s->pool, 'conf'); Note that the old form @@ -1422,7 +1384,7 @@ is no longer valid - C<server_root_relat passed a pool. The old functionality is available with -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. @@ -1453,7 +1415,7 @@ See C<L<$r-E<gt>kill_timeout|/C__r_E_gt_ The functions C<$r-E<gt>hard_timeout>, C<$r-E<gt>reset_timeout>, C<$r-E<gt>soft_timeout> and C<$r-E<gt>kill_timeout> aren't needed in -mod_perl 2.0. C<L<Apache::compat|docs::2.0::api::Apache::compat>> +mod_perl 2.0. C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> implements these functions for backwards compatibility as NOOPs. @@ -1500,9 +1462,9 @@ I<modules/http/http_protocol.c>. The record I<auth_type> doesn't exist in the Apache 2.0's connection struct. It exists only in the request record struct. The new accessor in 2.0 API is -C<L<$r-E<gt>ap_auth_type|docs::2.0::api::Apache::RequestRec/C_ap_auth_type_>>. +C<L<$r-E<gt>ap_auth_type|docs::2.0::api::Apache2::RequestRec/C_ap_auth_type_>>. -C<L<Apache::compat|docs::2.0::api::Apache::compat>> provides a back +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> provides a back compatibility method, though it relies on the availability of the global C<Apache-E<gt>request>, which requires the configuration to have: @@ -1518,7 +1480,7 @@ to set it up for earlier stages than res =head2 C<$connection-E<gt>user> This method is deprecated in mod_perl 1.0 and -C<L<$r-E<gt>user|docs::2.0::api::Apache::RequestRec/C_user_>> should +C<L<$r-E<gt>user|docs::2.0::api::Apache2::RequestRec/C_user_>> should be used instead for both mod_perl generations. C<$r-E<gt>user()> method is available since mod_perl version 1.24_01. @@ -1534,9 +1496,9 @@ See C<L<$connection-E<gt>remote_addr|/C_ =head2 C<$connection-E<gt>remote_addr> -C<L<$c-E<gt>local_addr|docs::2.0::api::Apache::Connection/C_local_addr_>> +C<L<$c-E<gt>local_addr|docs::2.0::api::Apache2::Connection/C_local_addr_>> and -C<L<$c-E<gt>remote_addr|docs::2.0::api::Apache::Connection/C_remote_addr_>> +C<L<$c-E<gt>remote_addr|docs::2.0::api::Apache2::Connection/C_remote_addr_>> return an C<L<APR::SockAddr|docs::2.0::api::APR::SockAddr>> object and you can use this object's methods to retrieve the wanted bits of information, so if you had a code like: @@ -1555,19 +1517,19 @@ now it'll be written as: my $remoteport = $c->remote_addr->port; my $remoteip = $c->remote_addr->ip_get; -It's also possible to adjust the code using Apache::compat's -L<overriding|docs::2.0::api::Apache::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>: +It's also possible to adjust the code using Apache2::compat's +L<overriding|docs::2.0::api::Apache2::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>: use Socket 'sockaddr_in'; - use Apache::compat; + use Apache2::compat; - Apache::compat::override_mp2_api('Apache::Connection::local_addr'); + Apache2::compat::override_mp2_api('Apache2::Connection::local_addr'); my ($serverport, $serverip) = sockaddr_in($r->connection->local_addr); - Apache::compat::restore_mp2_api('Apache::Connection::local_addr'); + Apache2::compat::restore_mp2_api('Apache2::Connection::local_addr'); - Apache::compat::override_mp2_api('Apache::Connection::remote_addr'); + Apache2::compat::override_mp2_api('Apache::Connection::remote_addr'); my ($remoteport, $remoteip) = sockaddr_in($r->connection->remote_addr); - Apache::compat::restore_mp2_api('Apache::Connection::remote_addr'); + Apache2::compat::restore_mp2_api('Apache::Connection::remote_addr'); @@ -1587,7 +1549,7 @@ either moved to other packages or remove The methods C<new()>, C<open()> and C<close()> were removed. See the back compatibility implementation in the module -C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. Because of that some of the idioms have changes too. If previously you were writing: @@ -1599,9 +1561,9 @@ were writing: close $fh; Now, you would write that using -C<L<Apache::RequestUtil::slurp_filename()|docs::2.0::api::Apache::RequestUtil/C_slurp_filename_>>: +C<L<Apache2::RequestUtil::slurp_filename()|docs::2.0::api::Apache2::RequestUtil/C_slurp_filename_>>: - use Apache::RequestUtil (); + use Apache2::RequestUtil (); my $content = ${ $r->slurp_filename() }; @@ -1614,7 +1576,7 @@ The method C<tmpfile()> was removed sinc API for this method anymore. See C<File::Temp>, or the back compatibility implementation in the -module C<L<Apache::compat|docs::2.0::api::Apache::compat>>. +module C<L<Apache2::compat|docs::2.0::api::Apache2::compat>>. With Perl v5.8.0 you can create anonymous temporary files: @@ -1627,7 +1589,7 @@ That is a literal C<undef>, not an undef =head1 C<Apache::Util> -A few C<L<Apache::Util|docs::2.0::api::Apache::Util>> functions have +A few C<L<Apache2::Util|docs::2.0::api::Apache2::Util>> functions have changed their interface. @@ -1644,17 +1606,17 @@ which returns formatted strings of only =head2 C<Apache::Util::escape_uri()> C<Apache::Util::escape_uri()> has been replaced with -C<L<Apache::Util::escape_path()|docs::2.0::api::Apache::Util/C_escape_path_>> +C<L<Apache2::Util::escape_path()|docs::2.0::api::Apache2::Util/C_escape_path_>> and requires a pool object as a second argument. For example: - $escaped_path = Apache::Util::escape_path($path, $r->pool); + $escaped_path = Apache2::Util::escape_path($path, $r->pool); =head2 C<Apache::Util::unescape_uri()> C<Apache::Util::unescape_uri()> has been replaced with -C<L<Apache::URI::unescape_url()|docs::2.0::api::Apache::URI/C_unescape_url_>>. +C<L<Apache2::URI::unescape_url()|docs::2.0::api::Apache2::URI/C_unescape_url_>>. @@ -1665,7 +1627,7 @@ C<HTML::Entities> instead (http://search.cpan.org/dist/HTML-Parser/lib/HTML/Entities.pm). It's also available via -C<L<Apache::compat|docs::2.0::api::Apache::compat>> for backwards +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> for backwards compatibility. @@ -1682,29 +1644,29 @@ C<L<APR::Date::parse_http()|docs::2.0::a =head2 C<Apache::Util::ht_time()> -C<L<Apache::Util::ht_time()|docs::2.0::api::Apache::Util/C_ht_time_>> +C<L<Apache2::Util::ht_time()|docs::2.0::api::Apache2::Util/C_ht_time_>> now requires a C<L<pool|docs::2.0::api::APR::Pool>> object as a first argument. For example: - use Apache::Util (); + use Apache2::Util (); $fmt = '%a, %d %b %Y %H:%M:%S %Z'; $gmt = 1; - $fmt_time = Apache::Util::ht_time($r->pool, time(), $fmt, $gmt); + $fmt_time = Apache2::Util::ht_time($r->pool, time(), $fmt, $gmt); -See the L<Apache::Util|docs::2.0::api::Apache::Util> manpage. +See the L<Apache2::Util|docs::2.0::api::Apache2::Util> manpage. It's also possible to adjust the mod_perl 1.0 code using -Apache::compat's -L<overriding|docs::2.0::api::Apache::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>. +Apache2::compat's +L<overriding|docs::2.0::api::Apache2::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>. For example: - use Apache::compat; - Apache::compat::override_mp2_api('Apache::Util::ht_time'); - $fmt_time = Apache::Util::ht_time(time(), $fmt, $gmt); - Apache::compat::restore_mp2_api('Apache::Util::ht_time'); + use Apache2::compat; + Apache2::compat::override_mp2_api('Apache2::Util::ht_time'); + $fmt_time = Apache2::Util::ht_time(time(), $fmt, $gmt); + Apache2::compat::restore_mp2_api('Apache2::Util::ht_time'); @@ -1717,7 +1679,7 @@ C<Apache::Util::validate_password()> has C<L<APR::Util::password_validate()|docs::2.0::api::APR::Util/C_password_validate_>>. For example: - my $ok = Apache::Util::password_validate("stas", "ZeO.RAc3iYvpA"); + my $ok = Apache2::Util::password_validate("stas", "ZeO.RAc3iYvpA"); @@ -1778,19 +1740,19 @@ See the C<L<APR::URI|docs::2.0::api::APR information. It's also possible to adjust the behavior to be mod_perl 1.0 -compatible using Apache::compat's -L<overriding|docs::2.0::api::Apache::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>, +compatible using Apache2::compat's +L<overriding|docs::2.0::api::Apache2::compat/Compatibility_Functions_Colliding_with_mod_perl_2_0_API>, in which case C<unparse()> will transparently set I<scheme> to I<http>. # request http://localhost.localdomain:8529/TestAPI::uri - Apache::compat::override_mp2_api('APR::URI::unparse'); + Apache2::compat::override_mp2_api('APR::URI::unparse'); my $parsed = $r->parsed_uri; # set hostname, but not the scheme $parsed->hostname($r->get_server_name); $parsed->port($r->get_server_port); print $parsed->unparse; - Apache::compat::restore_mp2_api('APR::URI::unparse'); + Apache2::compat::restore_mp2_api('APR::URI::unparse'); prints: @@ -1886,7 +1848,6 @@ transparent with C<L<ModPerl::MM|docs::2 Here is how to write a simple I<Makefile.PL> for modules wanting to build XS code against mod_perl 2.0: - use Apache2; use mod_perl 1.99; use ModPerl::MM (); @@ -1915,7 +1876,7 @@ C<L<APR::Table|docs::2.0::api::APR::Tabl =head1 C<Apache::SIG> C<Apache::SIG> currently exists only -C<L<Apache::compat|docs::2.0::api::Apache::compat>> and it does +C<L<Apache2::compat|docs::2.0::api::Apache2::compat>> and it does nothing. @@ -1925,17 +1886,17 @@ nothing. =head1 C<Apache::StatINC> C<Apache::StatINC> has been replaced by -C<L<Apache::Reload|docs::2.0::api::Apache::Reload>>, which works for -both mod_perl generations. To migrate to C<Apache::Reload> simply +C<L<Apache2::Reload|docs::2.0::api::Apache2::Reload>>, which works for +both mod_perl generations. To migrate to C<Apache2::Reload> simply replace: PerlInitHandler Apache::StatINC with: - PerlInitHandler Apache::Reload + PerlInitHandler Apache2::Reload -However C<Apache::Reload> provides an extra functionality, covered in +However C<Apache2::Reload> provides an extra functionality, covered in the module's manpage.
infrastructure at apache.org | ViewVC Help |
Powered by ViewVC 1.1.26 |