Item14756: Invalid date string errors for SEARCHES with order
Priority: Low
Current State: Closed
Released In: n/a
Target Release:
If a
SEARCH has the order-parameter set to a text-formfield and there are values starting with a number in this formfield, the following errors are logged:
| ... warning | Foswiki::Plugins::DateManipPlugin::Core | [parse] Invalid date string, string=3 foo bar |
I am trying this out here:
In our setup with
DateManipPlugin version 2.00 installed, a search like this leads to the mentioned warnings.
The formfield is of type "text".
--
StefanH - 31 Aug 2018
I can't repro the problem using this minimal example:
FaqForm.txt
--
Main.MichaelDaum - 31 Aug 2018
Ok, the problem seems to be more specific. You need at least two results, so create a copy of the file. Try first value "123 abc" and value of the second result "456 def".
--
StefanH - 31 Aug 2018
Still can't repro. I've got some local changes, which however shouldn't make a difference:
--- a/lib/Foswiki/Plugins/DateManipPlugin/Core.pm
+++ b/lib/Foswiki/Plugins/DateManipPlugin/Core.pm
@@ -167,8 +167,8 @@ sub DURATION {
if(defined $fromStr || defined $toStr) {
# date mode
- $fromStr //= "epoch ".time;
- $toStr //= "epoch ".time;
+ $fromStr = "epoch ".time if !defined($fromStr) || $fromStr eq '';
+ $toStr = "epoch ".time if !defined($toStr) || $toStr eq '';
my $fromDate = $this->getDate($params);
my $err = $fromDate->parse(_fixDateTimeString($fromStr));
@@ -318,6 +318,7 @@ sub compatParseTime {
# SMELL: currently ignores defaultLocale param
$params ||= {};
+ $params->{lang} ||= 'en'; # default to english dates
my $date = $this->getDate($params);
my $err = $date->parse(_fixDateTimeString($string));
... or maybe they do?
--
MichaelDaum - 31 Aug 2018
No, the patch doesn't make a difference. I still get the warnings. Strange...
--
StefanH - 31 Aug 2018
Ah, this reporting to
working/logs/error.log
. The "error" is fine as it is just reporting Foswiki::Search
trying to parse the string as a date. It fails and the code proceeds as normal.
So let's switch off the message with below hotfix (which also includes some upcoming changes
):
--- a/lib/Foswiki/Plugins/DateManipPlugin/Core.pm
+++ b/lib/Foswiki/Plugins/DateManipPlugin/Core.pm
@@ -167,8 +167,8 @@ sub DURATION {
if(defined $fromStr || defined $toStr) {
# date mode
- $fromStr //= "epoch ".time;
- $toStr //= "epoch ".time;
+ $fromStr = "epoch ".time if !defined($fromStr) || $fromStr eq '';
+ $toStr = "epoch ".time if !defined($toStr) || $toStr eq '';
my $fromDate = $this->getDate($params);
my $err = $fromDate->parse(_fixDateTimeString($fromStr));
@@ -318,12 +318,12 @@ sub compatParseTime {
# SMELL: currently ignores defaultLocale param
$params ||= {};
+ $params->{lang} ||= 'en'; # default to english dates
my $date = $this->getDate($params);
my $err = $date->parse(_fixDateTimeString($string));
if ($err) {
- #print STDERR $date->err.", string=$string\n";
- Foswiki::Func::writeWarning($date->err.", string=$string");
+ # silently ignore
return;
}
--
Main.MichaelDaum - 31 Aug 2018