Mailing List Archive

Warnings by the dozen
I've installed the Wikipedia software on my machine, so I can start
hacking at it. It seems to be working OK, except that I get huge
numbers of PHP warning messages at the top of each page. I can get
rid of them by turning down the level of PHP warnings, but this is a
really bad idea from a bug-prevention point of view.

Looking through some of the old bug reports I see that at least one
of the major bugs was caused precisely by ignoring such messages.
So I have to assume that this is not my just a bad installation on my
part, and that the Wikipedia code really doesn't work properly with
error_reporting turned up full. Clearly this ought to be fixed. But
I can't do this on my own, since in some cases it's unclear what the
purpose of the code is. For example, the first five warnings come from
the following section of wikiSettings.php:

# Namespace backgrounds
$wikiNamespaceBackground = array () ;
$wikiNamespaceBackground[$wikiTalk] = "#eeFFFF" ;
$wikiNamespaceBackground["user_talk"] = $wikiNamespaceBackground["talk"] ;
$wikiNamespaceBackground["wikipedia_talk"] = $wikiNamespaceBackground["talk"] ;
$wikiNamespaceBackground[$wikiUser] = "#FFeeee" ;
$wikiNamespaceBackground[$wikiWikipedia] = "#eeFFee" ;
$wikiNamespaceBackground["log"] = "#FFFFcc" ;
$wikiNamespaceBackground["special"] = "#eeeeee" ;

Here, $wikiTalk, $wikiNamespaceBackground["talk"], $wikiUser and
$wikiWikipedia are all undefined. I've no idea how to clean this
up, because I don't understand what it's supposed to look like.
Why are some of the indices variables and other constants?
In particular, what is the intended distinction between
$wikiNamespaceBackground["talk"] and $wikiNamespaceBackground[$wikiTalk]?
What should be done with this code?

--
Zundark
RE: Warnings by the dozen [ In reply to ]
> I've installed the Wikipedia software on my machine, so I can start
> hacking at it. It seems to be working OK, except that I get huge
> numbers of PHP warning messages at the top of each page. I can get
> rid of them by turning down the level of PHP warnings, but this is a
> really bad idea from a bug-prevention point of view.

I think we all work with "standard settings", and there are no warnings
showing up, just like the Bomis server uses standard and doesn't show
anything like that, either. Me, I'm still surprised that it's running at all
;)

<snip>
> Here, $wikiTalk, $wikiNamespaceBackground["talk"], $wikiUser and
> $wikiWikipedia are all undefined. I've no idea how to clean this
> up, because I don't understand what it's supposed to look like.
> Why are some of the indices variables and other constants?
> In particular, what is the intended distinction between
> $wikiNamespaceBackground["talk"] and $wikiNamespaceBackground[$wikiTalk]?
> What should be done with this code?

The reason (without looking at the code right now) is probably the missing
"global" statement at the beginning of the function.
The purpose of the indices being variables is that the German wikipedia, for
example, uses "/Diskussion" instead of "/Talk", and will get a "Diskussion:"
namespace instead of "Talk:". The reason for the mix with constants is that
we're too lazy to convert them all to variables...

Magnus
Re: Warnings by the dozen [ In reply to ]
Magnus Manske wrote:

> I think we all work with "standard settings", and there are no warnings
> showing up, just like the Bomis server uses standard and doesn't show
> anything like that, either.

But at least one major Wikipedia bug was caused by ignoring these
warnings, so this certainly isn't a good idea. (In development, that is.
The Bomis server is obviously a different matter.)

> > Here, $wikiTalk, $wikiNamespaceBackground["talk"], $wikiUser and
> > $wikiWikipedia are all undefined. I've no idea how to clean this
> > up, because I don't understand what it's supposed to look like.
> > Why are some of the indices variables and other constants?
> > In particular, what is the intended distinction between
> > $wikiNamespaceBackground["talk"] and $wikiNamespaceBackground[$wikiTalk]?
> > What should be done with this code?
>
> The reason (without looking at the code right now) is probably the missing
> "global" statement at the beginning of the function.

No, it's caused by using them before they are defined. The file
wikiTextEn.php which defines them is included later on. (This doesn't
apply to $wikiNamespaceBackground["talk"], which isn't defined anywhere.
I assume it's a mistake for $wikiNamespaceBackground[$wikiTalk].)
For the same reason, $wikiCharset is also used before being defined.

So the values in $wikiNamespaceBackground need to be assigned
after wikiTextEn.php (and any other language-specific setting file)
has been included. But these files can modify $wikiNamespaceBackground
(at least, the Esperanto one does - perhaps it shouldn't), so the only
solution appears to be to declare $wikiNamespaceBackground first,
then include the language-specific files, then assign values to
$wikiNamespaceBackground, but making sure not to overwrite any values
that have already been assigned. I'll post a patch for this later.

--
Zundark