Stas Bekman wrote:
Philippe M. Chiasson wrote:

This new patch addresses the issue Geoff pointed out. Deleting package Foo, shouldn't delete
package Foo::Bar.

It actually makes the patch a bit simpler, deleting all entries in the package's stash only
skipping the ones ending in '::'. Still works like a charm for me.

More Comments ?


+void modperl_clear_namespace(pTHX_ apr_pool_t *p, const char *package)
+{
+ /* delete $INC{'Some/Package.pm} */
+ modperl_delete_from_inc(aTHX_ p, package);
+
+ /* delete $Some::{'Package::'}; */
+ modperl_clear_stash(aTHX_ p, package);
+ + return;
}


Unrelated to the proposed patch, but the outcome may affect it a bit.

I see that we have a problem with modperl_perl_module_loaded, since it doesn't do what it suggests to do. If I say:

$Foo::bar = 1;

w/o loading Foo.pm. modperl_perl_module_loaded("Foo") will return true. And it's broken. I see that Perl modules use module_loaded to do the check, and think that the module was loaded when it might be not loaded at all.

Yes, I've noticed that issue as well and was thinking about a possible solution. Right now, if you use Foo::Bar::Baz; modperl_perl_module_loaded('Foo') will return true because the Foo:: stash has been created.

Notice that PerlRequire/PerlModule *do not* check the stash's existence, precisely because some variables could get into the module's stash and it shouldn't prevent the module from loading.

I think this should be fixed to lookup in $INC, in which case the above code will need to be changed too.

Yes, that was the conclusion I reached as well. After seeing what Perl does, looking at %INC seems to be the _only_ right way to test wether a module is loaded or not.


Index: t/response/TestModules/reload.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestModules/reload.pm,v
retrieving revision 1.1
diff -u -I$Id -r1.1 reload.pm
--- t/response/TestModules/reload.pm    24 Aug 2004 17:36:56 -0000      1.1
+++ t/response/TestModules/reload.pm    24 Aug 2004 19:17:08 -0000
@@ -5,6 +5,8 @@

use Apache::Const -compile => qw(OK);

+use ModPerl::Util;


what is it for?


sub handler {
    my $r = shift;

@@ -21,5 +23,4 @@
PerlModule Apache::Reload
PerlInitHandler Apache::TestHandler::same_interp_fixup Apache::Reload
PerlSetVar ReloadDebug On
-PerlSetVar ReloadConstantRedefineWarnings Off
PerlSetVar ReloadAll Off
Index: xs/ModPerl/Util/ModPerl__Util.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/ModPerl/Util/ModPerl__Util.h,v
retrieving revision 1.5
diff -u -I$Id -r1.5 ModPerl__Util.h
--- xs/ModPerl/Util/ModPerl__Util.h     4 Mar 2004 06:01:14 -0000       1.5
+++ xs/ModPerl/Util/ModPerl__Util.h     24 Aug 2004 19:17:08 -0000
@@ -28,5 +28,5 @@

#define mpxs_Apache_current_callback modperl_callback_current_callback_get

-
+#define mpxs_ModPerl__Util_clear_namespace(p, pkg) modperl_clear_namespace(aTHX_ p, 
pkg)


wrap long line?



-- -------------------------------------------------------------------------------- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to