1 I have a directory containing two files. f1 (<http://alcopop.org/~jon/repro2/src/blog/debgtd.html>) has
3 meta date="2008-07-02 14:13:17"
5 f2 (<http://alcopop.org/~jon/repro2/src/blog/moving.html>) has
7 meta date="2008-07-02 21:04:21"
9 They have both been modified recently:
12 (33188, 459250L, 65027L, 1, 1000, 1000, 1686L, 1227967177, 1227966706, 1227966706)
14 (33188, 458868L, 65027L, 1, 1000, 1000, 938L, 1227967187, 1227966705, 1227966705)
16 Note that f1 is fractionally newer than f2 in terms of ctime and mtime, but f2 is much newer in terms of the meta information.
18 Another page includes them both via inline:
20 inline pages="blog/*" show=5
22 The resulting page is rendered with f1 above f2, seemingly not using the meta directive information: <http://alcopop.org/~jon/repro2/dest/blog/>. The footer in the inline pages does use the correct time e.g. <em>Posted Wed 02 Jul 2008 14:13:17 BST</em>.
24 If I instead include them using creation_year in the pagespec, they are ordered correctly.
26 <http://alcopop.org/~jon/repro2/> contains the src used to reproduce this, the precise ikiwiki invocation (inside Makefile) and the results (dest).
31 > On Ikiwiki 2.53.3 (Debian Lenny), my inlines are also sorted using mtime
32 > by default -- despite what the [[documentation|/ikiwiki/directive/inline]]
33 > says -- but setting the supposed default sort order manually produces the
34 > correct results. For example, the following inline sorts my blog
35 > entires using their meta date or ctime:
37 > inline pages="blog/*" show="10" sort="age"
39 > I'll try to look at the code this weekend and see if age is really the
42 > -- [David A. Harding](http://dtrt.org), 2008-12-20
44 Here is the code. As you can see, sort="age" is equivilant to leaving
45 out the sort option. --[[Joey]]
47 if (exists $params{sort} && $params{sort} eq 'title') {
48 @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
50 elsif (exists $params{sort} && $params{sort} eq 'mtime') {
51 @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
53 elsif (! exists $params{sort} || $params{sort} eq 'age') {
54 @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
57 return sprintf(gettext("unknown sort type %s"), $params{sort});
60 > On further testing, I find that the bug is limited to the first time
61 > creation time should be used and has nothing to do with setting the sort
62 > parameter. Revised steps to reproduce: --[David A. Harding](http://dtrt.org), 2008-12-20
64 > 1. Create pages that sort different by mtime and ctime
66 > 2. inline pages="somepages/*"
68 > 3. ikiwiki --setup setup_file
70 > 4. Pages are output incorrectly in mtime order
72 > 5. ikiwiki --setup setup_file
74 > 6. Pages are output correctly in ctime order
76 > 7. Create new page in somepages/, set its ctime to earlier than another
79 > 8. ikiwiki --setup setup_file
81 > 9. All previously sorted pages output correctly in ctime order but new
82 > page is output incorrectly at the top as if its mtime was its ctime
84 > 10. ikiwiki --setup setup_file
86 > 11. All pages, including new page, are output correctly in ctime order
88 You're confusing ctime and creation time. This is perhaps not suprising, as
89 ikiwiki uses the term 'ctime' to refer to creation time. However, the unix
90 ctime value is not the same thing. Unix ctime can change if a file changes
91 owner, or in some cases, permissions. Unix ctime also always changes
92 when the file is modified. Ikiwiki wants a first creation date of the file,
93 and it accomplishes this by recording the initial ctime of a file the first
94 time it processes it, and *preserving* that creation time forever, ignoring
97 I suspect that this, coupled with the fact that ikiwiki sorts newest pages
98 first, explains everything you describe. If not, please send me a shell script
99 test case I can run, as instructions like "Create pages that sort different by
100 mtime and ctime" are not ones that I know how to follow (given that touch sets
103 > Sorry. I conflated Unix ctime and ikiwiki's creation time because I
104 > didn't think the difference was important to this case. I'm a writer,
105 > and I should have known better -- I appologize. Revised steps to
106 > reproduce are below; feel free to delete this whole misunderstanding
107 > to make the bug report more concise.
109 > 1. Create pages in the srcdir that should sort in one order by
110 > last-modification time and in a diffent order by original creation
113 > $ echo -e '\[[!meta date="2007-01-01"]]\nNew.' > test/new.mdwn
114 > $ echo -e '\[[!meta date="2006-01-01"]]\nOld.' > test/old.mdwn
116 > 2. Create a page that includes the files. For example:
119 > $ echo '\[[!inline pages="test/*"]]' > sort-test.mdwn
121 > 3. Run ikiwiki. For example `ikiwiki --setup setup_file`
123 > 4. Pages are output incorrectly in modification time order. For example,
124 > actual partial HTML of the sort-test/index.html from commands used
125 > above (whitespace-only lines removed; one whitespace-only line
128 > <div class="inlinepage">
129 > <span class="header">
130 > <a href="./../test/old/">old</a>
133 > <span class="pagedate">
134 > Posted Sun 01 Jan 2006 12:00:00 AM EST
138 > <div class="inlinepage">
139 > <span class="header">
140 > <a href="./../test/new/">new</a>
143 > <span class="pagedate">
144 > Posted Mon 01 Jan 2007 12:00:00 AM EST
148 > 5. Run ikiwiki again with the same command line. For example: `ikiwiki --setup setup_file`
150 > 6. Pages are output correctly in creation time order. For example,
151 > actual partial HTML of the sort-test/index.html from commands used
152 > above (whitespace-only lines removed; one whitespace-only line
155 > <div class="inlinepage">
156 > <span class="header">
157 > <a href="./../test/new/">new</a>
160 > <span class="pagedate">
161 > Posted Mon 01 Jan 2007 12:00:00 AM EST
165 > <div class="inlinepage">
166 > <span class="header">
167 > <a href="./../test/old/">old</a>
170 > <span class="pagedate">
171 > Posted Sun 01 Jan 2006 12:00:00 AM EST
175 > 7. Create a new page with the current Unix mtime and Unix ctime, but a
176 > !meta date before the most recent creation date of another page.
179 > $ echo -e '\[[!meta date="2005-01-01"]]\nOlder.' > test/older.mdwn
181 > 8. Run ikiwiki again with the same command line. For example: `ikiwiki --setup setup_file`
183 > 9. All previously sorted pages output correctly in order of their
184 > creation time, but the new page is output incorrectly at the top as
185 > if its modification time was its creation time. For example,
186 > actual partial HTML of the sort-test/index.html from commands used
187 > above (whitespace-only lines removed; two whitespace-only
190 > <div class="inlinepage">
191 > <span class="header">
192 > <a href="./../test/older/">older</a>
195 > <span class="pagedate">
196 > Posted Sat 01 Jan 2005 12:00:00 AM EST
200 > <div class="inlinepage">
201 > <span class="header">
202 > <a href="./../test/new/">new</a>
205 > <span class="pagedate">
206 > Posted Mon 01 Jan 2007 12:00:00 AM EST
210 > <div class="inlinepage">
211 > <span class="header">
212 > <a href="./../test/old/">old</a>
215 > <span class="pagedate">
216 > Posted Sun 01 Jan 2006 12:00:00 AM EST
220 > 10. Run ikiwiki again with the same command line. For example: `ikiwiki --setup setup_file`
222 > 11. All pages, including new page, are output correctly in creation time
223 > order. For example, actual partial HTML of the sort-test/index.html
224 > from commands used above (whitespace-only lines removed; two
225 > whitespace-only lines added):
227 > <div class="inlinepage">
228 > <span class="header">
229 > <a href="./../test/new/">new</a>
232 > <span class="pagedate">
233 > Posted Mon 01 Jan 2007 12:00:00 AM EST
237 > <div class="inlinepage">
238 > <span class="header">
239 > <a href="./../test/old/">old</a>
242 > <span class="pagedate">
243 > Posted Sun 01 Jan 2006 12:00:00 AM EST
247 > <div class="inlinepage">
248 > <span class="header">
249 > <a href="./../test/older/">older</a>
252 > <span class="pagedate">
253 > Posted Sat 01 Jan 2005 12:00:00 AM EST
257 > File status after all the above actions:
260 > File: `test/new.mdwn'
261 > Size: 33 Blocks: 8 IO Block: 4096 regular file
262 > Device: ca20h/51744d Inode: 684160 Links: 1
263 > Access: (0644/-rw-r--r--) Uid: ( 1000/ harding) Gid: ( 1000/ harding)
264 > Access: 2008-12-20 21:48:32.000000000 -0500
265 > Modify: 2008-12-20 21:27:03.000000000 -0500
266 > Change: 2008-12-20 21:27:03.000000000 -0500
267 > File: `test/older.mdwn'
268 > Size: 35 Blocks: 8 IO Block: 4096 regular file
269 > Device: ca20h/51744d Inode: 684407 Links: 1
270 > Access: (0644/-rw-r--r--) Uid: ( 1000/ harding) Gid: ( 1000/ harding)
271 > Access: 2008-12-20 21:48:32.000000000 -0500
272 > Modify: 2008-12-20 21:42:10.000000000 -0500
273 > Change: 2008-12-20 21:42:10.000000000 -0500
274 > File: `test/old.mdwn'
275 > Size: 33 Blocks: 8 IO Block: 4096 regular file
276 > Device: ca20h/51744d Inode: 684161 Links: 1
277 > Access: (0644/-rw-r--r--) Uid: ( 1000/ harding) Gid: ( 1000/ harding)
278 > Access: 2008-12-20 21:48:32.000000000 -0500
279 > Modify: 2008-12-20 21:27:09.000000000 -0500
280 > Change: 2008-12-20 21:27:09.000000000 -0500
282 > My ikiwiki configuration file (being used to port a blog from pyblosxom
285 > harding@mail:~$ sed 's/#.*//; /^[ ]*$/d' .ikiwiki/gnuisance.setup
286 > use IkiWiki::Setup::Standard {
287 > wikiname => "HardingBlog",
288 > adminemail => 'dave@dtrt.org',
289 > srcdir => "/srv/backup/git/gnuisance.net",
290 > destdir => "/srv/test.dtrt.org",
291 > url => "http://srv.dtrt.org",
296 > prefix_directives => 1,
297 > add_plugins => [qw{goodstuff tag}],
298 > disable_plugins => [qw{passwordauth}],
302 > --[David A. Harding](http://dtrt.org/), 2008-12-20
304 Thank you for a textbook excellent reproduction recipe.
306 What appears to be going on here is that meta directives are not processed
307 until the leaf pages are rendered, and thus the ctime setting is not
308 available at the time that they are inlined, and the newer unix ctime is
309 used. On the second build, the meta data has already been recorded.
311 This can probably be avoided by processing meta date at scan time.