kareila: "PERL!" (perl)
kareila ([personal profile] kareila) wrote in [site community profile] dw_dev2010-10-13 02:30 pm
Entry tags:

S2 constant errors

With global warnings on, some permutation of these lines shows up in the log whenever I hit an S2 page:

Constant subroutine S2::PROPS redefined at /usr/share/perl/5.8/constant.pm line 103.
Constant subroutine S2::STATIC redefined at /usr/share/perl/5.8/constant.pm line 103.
Constant subroutine S2::VTABLE redefined at /usr/share/perl/5.8/constant.pm line 103.

Any ideas as to why this might be happening?
fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2010-10-14 06:42 am (UTC)(link)
Hmm, okay so, I tried looking up "constant subroutine" in man perldiag which told me to look at the "Constant Functions" section in man perlsub.

And I think that what that means is that since constants are inlined for efficiency, redefining the constant on the fly, won't update the places it had previously been inlined into at compile-time.

We could silence it in the same way that we silence "Subroutine redefined" in Apache::LiveJournal, but, assuming that what my understanding in the second paragraph is correct, this might result in some strange behavior, until we restart apache.

Another alternative: silence the warnings, but if a constant may have been redefined because its file was reloaded, print out one warning "Constants may have been redefined; restart web server" or something? It only affects dev servers so we can afford to restart servers as much as wanted.
alierak: (Default)

[personal profile] alierak 2010-10-14 02:50 pm (UTC)(link)
If I understand [personal profile] fu correctly, they're only defined once in all the code, but an Apache process that stays running for a while may read a new version of the code, containing a new definition of the constants. If that's the case, restarting Apache should make it quit warning you.
fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2010-10-14 03:34 pm (UTC)(link)
I think it's any constants at all, when the file is reloaded (and we could do it one check per set of files to be reloaded in a request, which will make things a lot less verbose)

You can see it if you, e.g., touch $LJHOME/cgi-bin/DW/InviteCodes.pm; when that is reloaded, you get all the warnings about the constants in there.

[personal profile] andy 2010-10-14 06:56 pm (UTC)(link)
I guess these lines can just be moved to S2.pm, no?

[personal profile] andy 2010-10-14 07:12 pm (UTC)(link)
You will need to recompile all styles on your dev server, obviously. Issue bin/upgrading/update-db.pl --help and go from there, the appropriate flags would be -f -p, but I'm unsure.