ericvaandering / DocDB

Working repository for DocDB
25 stars 18 forks source link

DB Query fails when trying to modify an existing event (ShowAllTalks is empty) #115

Open pms967 opened 1 year ago

pms967 commented 1 year ago

When trying to modify an existing event, query fails with the following errors:

AH01215: DBD::mysql::st execute failed: Incorrect integer value: '' for column 'ShowAllTalks' at row 1 at MeetingSQL.pm line 558.: MeetingModify

AH01215: DBD::mysql::st execute failed: Incorrect integer value: '' for column 'ShowAllTalks' at row 1 at MeetingSQL.pm line 559.: MeetingModify

It turns out that (in MeetingSQL.pm) $ArgRef->{-showalltalks} is defined, but is an empty string.

I have not fully traced the source of this problem yet (any help or hint would be welcome).

I noticed the problem when trying to modify the short description of an externally managed event. I don't know whether this is a general problem which happens with any kind of events, or only on externally managed ones. I also ignore whether it affects only newer systems (such as AL9 or Ubuntu 22.04, which is what I use) or it happens also on the old CentOS ones.

Nevertheless, as a quick & dirty fix, for the moment I have applied this patch:

--- ../../DocDB-8.8.9/cgi/MeetingSQL.pm 2018-06-26 20:19:08.000000000 +0200
+++ ./MeetingSQL.pm 2023-08-19 18:38:05.265992984 +0200
@@ -536,6 +540,8 @@
   my $AltLocation      = exists $ArgRef->{-altlocation}      ?   $ArgRef->{-altlocation}      : "";
   my $URL              = exists $ArgRef->{-url}              ?   $ArgRef->{-url}              : "";
   my $ShowAllTalks     = exists $ArgRef->{-showalltalks}     ?   $ArgRef->{-showalltalks}     : 0;
+    # print "<p>DEBUG: ShowAllTalks = $ShowAllTalks</p>\n";
+    if ($ShowAllTalks eq '') { $ShowAllTalks = 0 };
   my $Preamble         = exists $ArgRef->{-preamble}         ?   $ArgRef->{-preamble}         : "";
   my $Epilogue         = exists $ArgRef->{-epilogue}         ?   $ArgRef->{-epilogue}         : "";
   my @TopicIDs         = exists $ArgRef->{-topicids}         ? @{$ArgRef->{-topicids}}        : ();

(Among the other things, I will have to check what happen when trying to modify some "ShowAllTalks" in an event managed with DocDB).

BTW: to make it work with current mySQL (8.0), previously I also had to change where there is the "FIXME" for mySQL 3/4...

--- ../../DocDB-8.8.9/cgi/MeetingSQL.pm 2018-06-26 20:19:08.000000000 +0200
+++ ./MeetingSQL.pm 2023-08-19 18:38:05.265992984 +0200
@@ -345,15 +354,10 @@

   # FIXME: These next three lines are good for MySQL >= 4, but not MySQL 3

-#  my $SessionList   = $dbh -> prepare(
-#    "select SessionID from Session where DATE(StartTime)=?");
-#  $SessionList -> execute($Date);
-
-  # FIXME: These next three lines are good for MySQL 3
-
   my $SessionList   = $dbh -> prepare(
-    "select SessionID from Session where StartTime like ?");
-  $SessionList -> execute($Date."%");
+    "select SessionID from Session where DATE(StartTime)=?");
+  $SessionList -> execute($Date);
+
   $SessionList -> bind_columns(undef, \($SessionID));
   while ($SessionList -> fetch) {
     $SessionID = FetchSessionByID($SessionID);