File: invalid_meta_date_or_updated_not_diagnosed.mdwn

package info (click to toggle)
ikiwiki 3.20200202.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 21,072 kB
  • sloc: perl: 31,115; python: 428; sh: 185; makefile: 124
file content (89 lines) | stat: -rw-r--r-- 5,808 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
I'm having a hard time figuring out how the creation time, modification time, internal `ctime` and `mtime` fields (in `indexdb`) play along with the [[plugins/meta]] directive.

In some articles I write, I hardcode the creation and modification time, because they are imported from LWN.net, as such:

    \[[!meta title="The cost of hosting in the cloud"]]
    \[[!meta date="2018-02-281T12:00:00-0500"]]
    \[[!meta updated="2018-03-12T14:22:45-0500"]]

But strangely, [that article](https://anarc.at/blog/2018-03-12-cost-of-hosting/) does *not* show up as "created" on "february 28th": it shows up as "Created 6 days and 20 hours ago", ie. "march 12th" (`2018-03-12T18:29:12Z`). That is strange, because that's the *modification* date (`meta updated`), not the *creation* date. Similarly, the "edited" date is `2018-03-19T14:47:45Z` (40 minutes ago), which is more or less accurate: the page *was* modified some time ago, but shouldn't the `meta` tag override that? Note that the `edited` date matches the file's `mtime` field in the source directory:

    w-anarcat@marcos:~$ LANG=C stat source/blog/2018-03-12-cost-of-hosting.mdwn 
      File: source/blog/2018-03-12-cost-of-hosting.mdwn
      Size: 14022           Blocks: 32         IO Block: 4096   regular file
    Device: fd05h/64773d    Inode: 7905532     Links: 1
    Access: (0644/-rw-r--r--)  Uid: ( 1026/w-anarcat)   Gid: ( 1026/w-anarcat)
    Access: 2018-03-19 11:19:21.237074935 -0400
    Modify: 2018-03-19 10:47:45.000000000 -0400
    Change: 2018-03-19 11:19:20.509065456 -0400
     Birth: -

This wouldn't be so much of a problem if that stuff was consistent: but it's not really. What's supposed to be the [following article](https://anarc.at/blog/2018-03-19-sigal/) actually shows up *before* in the [blog index](https://anarc.at/blog/) which is rather annoying. It's also [backwards in the RSS feed](https://anarc.at/blog/index.rss), which will possibly break some feed readers who will miss the new article.

That newer article shows up as `Created 12 days and 15 hours ago` (`2018-03-07T00:00:00Z`) and also "edited 40 minutes ago" (`2018-03-19T14:51:29Z`). It has the following meta:

   \[[!meta title="Easy photo galleries with Sigal"]]
   \[[!meta date="2018-03-07T00:00:00+0000"]]
   \[[!meta updated="2018-03-19T10:26:12-0400"]]

So *there* the `date` meta tag *works*: the creation date is correct, but obviously, it means it comes *before* the other article, because *that* one doesn't get loaded correctly.

By now, clever folks will have noticed the problem: it's with the first timestamp:

    \[[!meta date="2018-02-281T12:00:00-0500"]]

There's an extra one in there! Obviously, february 281 is not a valid date... What happened is that I sometimes modify those dates by hand, and I sometimes mess it up. I actually messed it up twice there, the original timestamps were:

    \[[!meta date="2018-02-281T12:00:00-0500"]]
    \[[!meta updated="2018-14-22T14:22:45-0500"]]

The error, in the second one, is that I put the time instead of the date (!). I must have been very distracted, but still it's kind of hard to edit those timestamps correctly. I think the fundamental problem here is that Ikiwiki doesn't say anything when those timestamps can't be parsed properly. It seems to me there should be an error somewhere, if not directly in the page, at least in the rendering logs or somewhere, if the date cannot be parsed correctly.

So, long story short: shouldn't invalid dates in meta tags yield an error of some sort instead of being silently ignored? I spent half an hour figuring this one out, going as far as regenerating the whole wiki to try and see if it was a caching issue in indexdb...

Thanks!

-- [[anarcat]]

> If you're reporting a bug, it would be helpful to lead with the actual bug and save
> the account of how you tried to debug it for later (or omit it).
> I've moved this from a forum post into a bug report.
>
> The meta plugin uses Date::Parse::str2time from the TimeDate Perl library, so it has
> whatever error handling that has. However, historically any error has essentially
> been ignored, which I think is a bug.
>
> `\[[!meta date]]` and `\[[!meta updated]]` have two purposes:
>
> * they create `<meta name="date" content="xxx">` and `<meta name="updated" content="xxx">`
> * they change the ctime/mtime used by ikiwiki for sorting, etc.
>
> I think the historical assumption was that even if the date can't be parsed for the
> second purpose, you still want the first purpose. However, you're right that this is
> really fragile, and the first purpose seems fairly niche anyway.
> In ikiwiki git master (to be released as 3.20180321 or later) I've made `\[[!meta date=...]]`
> and `\[[!meta updated=...]]`
> produce an error message if you don't have `Date::Parse` or if the date/time is
> malformed.
> 
> In the unlikely event that someone really wants `<meta name="date" content="xxx">`
> without parsing the date, they can still use `\[[!meta name="date" content="xxx"]]`.
>
> [[!tag done]] --[[smcv]]

> > To my defense, when I wrote this, I didn't consider this a bug: I
> > was assuming the problem I was seeing was just some dumb mistake
> > that I made and, indeed, there *was* one such formatting mistake.
> >
> > But yeah, I could have re-edited this whole thing to make it look
> > better. I'm sorry, but I was at the end of an already long
> > yak-shaving session...
> >
> > I wasn't sure if doing an error was the right way to go, as this
> > might break rendering for existing sites... But I'm glad you fixed
> > this anyways!
> >
> > Thank you for the super-fast-response! :) I also tried updating
> > the [[meta directive documentation|ikiwiki/directive/meta]] so
> > that it's a little more detailed about that stuff. I hope that's 
> > alright... -- [[anarcat]]