Page MenuHomePhabricator

osm4wiki fills error.log with warnings about uninitialized variables
Closed, ResolvedPublic

Description

/data/project/osm4wiki/error.log is full of:

[…]
[Thu Nov 24 15:49:15 2016] wiki-osm.pl: Use of uninitialized value $pre in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:49:15 2016] wiki-osm.pl: Use of uninitialized value $na in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:54:19 2016] wiki-osm.pl: Use of uninitialized value $pre in substitution (s///) at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 233.
[Thu Nov 24 15:54:19 2016] wiki-osm.pl: Use of uninitialized value $pre in string eq at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 234.
[Thu Nov 24 15:54:19 2016] wiki-osm.pl: Use of uninitialized value $lnk in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:54:19 2016] wiki-osm.pl: Use of uninitialized value $pre in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:54:19 2016] wiki-osm.pl: Use of uninitialized value $na in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:57:42 2016] wiki-osm.pl: Use of uninitialized value $tx in substitution (s///) at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 210.
[Thu Nov 24 15:57:42 2016] wiki-osm.pl: Use of uninitialized value $tx in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 212.
[Thu Nov 24 15:57:42 2016] wiki-osm.pl: Use of uninitialized value $tx in substitution (s///) at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 210.
[Thu Nov 24 15:57:42 2016] wiki-osm.pl: Use of uninitialized value $tx in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 212.
[Thu Nov 24 15:57:47 2016] wiki-osm.pl: Use of uninitialized value $tx in substitution (s///) at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 210.
[Thu Nov 24 15:57:47 2016] wiki-osm.pl: Use of uninitialized value $tx in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 212.
[Thu Nov 24 15:59:35 2016] wiki-osm.pl: Use of uninitialized value $pre in substitution (s///) at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 233.
[Thu Nov 24 15:59:35 2016] wiki-osm.pl: Use of uninitialized value $pre in string eq at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 234.
[Thu Nov 24 15:59:35 2016] wiki-osm.pl: Use of uninitialized value $lnk in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:59:35 2016] wiki-osm.pl: Use of uninitialized value $pre in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[Thu Nov 24 15:59:35 2016] wiki-osm.pl: Use of uninitialized value $na in concatenation (.) or string at /data/project/osm4wiki/public_html//cgi-bin/wiki/wiki-osm.pl line 236.
[…]

I debugged a bit, and for example http://tools.wmflabs.org/osm4wiki/cgi-bin/wiki/wiki-osm.pl?project=Commons&article=Category%3ATahara%2C_Aichi triggers this: The links in the left table do not point anywhere; a working example would be http://tools.wmflabs.org/osm4wiki/cgi-bin/wiki/wiki-osm.pl?project=en&article=WAMC where the links point to Wikipedia.

I would try to fix this, but the code is uncommented, and I have no idea where the links in the failure should point to instead.

The home page for this tool is apparently https://de.wikipedia.org/wiki/Benutzer:Plenz/OSM_for_Wiki.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I have backed up /data/project/osm4wiki/public_html to /data/project/osm4wiki/public_html-backup-2016-12-10T04:41:20+0100.tar.bz2 and edited /data/project/osm4wiki/public_html/cgi-bin/wiki/wiki-osm.pl per:

tools.osm4wiki@tools-bastion-03:~$ diff -u <(tar jxf ./public_html-backup-2016-12-10T04\:41\:20+0100.tar.bz2 -O public_html/cgi-bin/wiki/wiki-osm.pl) public_html/cgi-bin/wiki/wiki-osm.pl 
--- /dev/fd/63  2016-12-10 05:08:23.323006387 +0100
+++ public_html/cgi-bin/wiki/wiki-osm.pl        2016-12-10 05:01:42.915137436 +0100
@@ -205,9 +205,12 @@
 sub printfolder {
 my $tx = shift;
 my $bx = $msg{catgory};
-$tx =~ /\[CDATA\[(.*?)\]\]/;
-$tx = $1;
-$tx =~ s/Category/$bx/i;
+if (defined ($tx) && ($tx =~ /\[CDATA\[(.*?)\]\]/)) {
+    $tx = $1;
+    $tx =~ s/Category/$bx/i;
+} else {
+    $tx = '';
+}
 $bx = shift;
 print <<"ENDE";
               <a onclick="openbox(this);" id="fold$bx"><img src="open0.png" border="0"></a>
@@ -224,15 +227,21 @@
 my $na = shift;
 my $dc = shift;
 my $bx = shift;
+my ($pre, $lnk, $ltx);
 $na =~ /\[CDATA\[(.*?)\]\]/i;
 $na = $1;
-$dc =~ /CDATA\[(.*?)<a href=\"(.*?)\".*?>(.*?)</i;
-my $pre = $1;
-my $lnk = $2;
-my $ltx = $3;
-$pre =~ s/<.*?>//g;             # remove all tags
-if ($pre eq "Source: Wikipedia article ") {$pre = $msg{wikisrc};}
-$dc =~ s/</&#60;/g;
+if (defined ($dc)) {
+    $dc =~ /CDATA\[(.*?)<a href=\"(.*?)\".*?>(.*?)</i;
+    $pre = $1;
+    $lnk = $2;
+    $ltx = $3;
+    $pre =~ s/<.*?>//g;             # remove all tags
+    if ($pre eq "Source: Wikipedia article ") {$pre = $msg{wikisrc};}
+    $dc =~ s/</&#60;/g;
+} else {
+    $dc = $lnk = $pre = '';
+}
+
 print <<"ENDE";
                 <tr name="fbox$bx" id="crow$ct"
                     onmouseover="highlight(this, 1);" onmouseout="highlight(this, 0);">
tools.osm4wiki@tools-bastion-03:~$

Now error.log seems to be quiet. I will inform Plenz tomorrow at https://de.wikipedia.org/wiki/Benutzer:Plenz/OSM_for_Wiki.

scfc claimed this task.

"Tomorrow", "two months after" – what's the difference? :-)

I left a note at https://de.wikipedia.org/wiki/Benutzer_Diskussion:Plenz/OSM_for_Wiki#Warnungen_in_error.log_auf_Tool_Labs; <code>error.log</code> grew 6.7 MByte since December 10th, so this is close enough to "empty" for me.