ericvaandering / DocDB

Working repository for DocDB
25 stars 20 forks source link

DocDBHelp: “Can't use a hash as a reference” (Perl 5.34) - easy fix patch included #113

Open pms967 opened 1 year ago

pms967 commented 1 year ago

More troubles with the help system. With up to date Perl (5.34) and libs, DocDBHelp fails with errors like the following in the apache log:

[cgi:error] AH01215: Can't use a hash as a reference at /var/www/docdb/cgi/DocDBHelp line 66.: /var/www/docdb/cgi/DocDBHelp, referer: SearchForm

The error is caused by (any/each of) these lines:

$DefaultText = %{$HelpXML->{entry}{$helpterm}}->{text};
$DefaultTitle = %{$HelpXML->{entry}{$helpterm}}->{title};

  $ProjectText = %{$ProjectXML->{entry}{$helpterm}}->{text};
  $ProjectTitle = %{$ProjectXML->{entry}{$helpterm}}->{title};
  $Action = %{$ProjectXML->{entry}{$helpterm}}->{action};
pms967 commented 1 year ago

Here's the patch to fix the problem:

--- ../../DocDB-8.8.9/cgi/DocDBHelp     2018-06-26 20:19:08.000000000 +0200
+++ DocDBHelp   2023-08-17 17:48:23.990017444 +0200
@@ -54,15 +63,15 @@

 my $HelpXML = XMLin("DocDBHelp.xml");

-$DefaultText = %{$HelpXML->{entry}{$helpterm}}->{text};
-$DefaultTitle = %{$HelpXML->{entry}{$helpterm}}->{title};
+$DefaultText = $HelpXML->{entry}->{$helpterm}->{text};
+$DefaultTitle = $HelpXML->{entry}->{$helpterm}->{title};

 if ($ProjectHelp) {
   my $ProjectXML = XMLin("ProjectHelp.xml");

-  $ProjectText = %{$ProjectXML->{entry}{$helpterm}}->{text};
-  $ProjectTitle = %{$ProjectXML->{entry}{$helpterm}}->{title};
-  $Action = %{$ProjectXML->{entry}{$helpterm}}->{action};
+  $ProjectText = $ProjectXML->{entry}->{$helpterm}->{text};
+  $ProjectTitle = $ProjectXML->{entry}->{$helpterm}->{title};
+  $Action = $ProjectXML->{entry}->{$helpterm}->{action};
 }

 # Remove line breaks and XML element tags
pms967 commented 1 year ago

Doh! Only now I notice that an almost identical patch had been already submitted as pull request https://github.com/ericvaandering/DocDB/commit/0bcb322389926f577f67ba1f02d5e037590c4be9 by @jpamdeandre