X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/dd4dff03506c5c8f9dee1fa59548e4e653bb0053..bc4ef28f3ebc396096b7eccad04eea6febac8d38:/doc/bugs/inline_sort_order_and_meta_date_value.mdwn diff --git a/doc/bugs/inline_sort_order_and_meta_date_value.mdwn b/doc/bugs/inline_sort_order_and_meta_date_value.mdwn index 6357acdee..d4ec8f345 100644 --- a/doc/bugs/inline_sort_order_and_meta_date_value.mdwn +++ b/doc/bugs/inline_sort_order_and_meta_date_value.mdwn @@ -40,3 +40,275 @@ If I instead include them using creation_year in the pagespec, they are ordered > default sort order. > > -- [David A. Harding](http://dtrt.org), 2008-12-20 + +Here is the code. As you can see, sort="age" is equivilant to leaving +out the sort option. --[[Joey]] + + if (exists $params{sort} && $params{sort} eq 'title') { + @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list; + } + elsif (exists $params{sort} && $params{sort} eq 'mtime') { + @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list; + } + elsif (! exists $params{sort} || $params{sort} eq 'age') { + @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list; + } + else { + return sprintf(gettext("unknown sort type %s"), $params{sort}); + } + +> On further testing, I find that the bug is limited to the first time +> creation time should be used and has nothing to do with setting the sort +> parameter. Revised steps to reproduce: --[David A. Harding](http://dtrt.org), 2008-12-20 +> +> 1. Create pages that sort different by mtime and ctime +> +> 2. inline pages="somepages/*" +> +> 3. ikiwiki --setup setup_file +> +> 4. Pages are output incorrectly in mtime order +> +> 5. ikiwiki --setup setup_file +> +> 6. Pages are output correctly in ctime order +> +> 7. Create new page in somepages/, set its ctime to earlier than another +> page in sompages/ +> +> 8. ikiwiki --setup setup_file +> +> 9. All previously sorted pages output correctly in ctime order but new +> page is output incorrectly at the top as if its mtime was its ctime +> +> 10. ikiwiki --setup setup_file +> +> 11. All pages, including new page, are output correctly in ctime order + +You're confusing ctime and creation time. This is perhaps not suprising, as +ikiwiki uses the term 'ctime' to refer to creation time. However, the unix +ctime value is not the same thing. Unix ctime can change if a file changes +owner, or in some cases, permissions. Unix ctime also always changes +when the file is modified. Ikiwiki wants a first creation date of the file, +and it accomplishes this by recording the initial ctime of a file the first +time it processes it, and *preserving* that creation time forever, ignoring +later ctime changes. + +I suspect that this, coupled with the fact that ikiwiki sorts newest pages +first, explains everything you describe. If not, please send me a shell script +test case I can run, as instructions like "Create pages that sort different by +mtime and ctime" are not ones that I know how to follow (given that touch sets +*both*). --[[Joey]] + +> Sorry. I conflated Unix ctime and ikiwiki's creation time because I +> didn't think the difference was important to this case. I'm a writer, +> and I should have known better -- I appologize. Revised steps to +> reproduce are below; feel free to delete this whole misunderstanding +> to make the bug report more concise. +> +> 1. Create pages in the srcdir that should sort in one order by +> last-modification time and in a diffent order by original creation +> time. For example: +> +> $ echo -e '\[[!meta date="2007-01-01"]]\nNew.' > test/new.mdwn +> $ echo -e '\[[!meta date="2006-01-01"]]\nOld.' > test/old.mdwn +> +> 2. Create a page that includes the files. For example: +> +> +> $ echo '\[[!inline pages="test/*"]]' > sort-test.mdwn +> +> 3. Run ikiwiki. For example `ikiwiki --setup setup_file` +> +> 4. Pages are output incorrectly in modification time order. For example, +> actual partial HTML of the sort-test/index.html from commands used +> above (whitespace-only lines removed; one whitespace-only line +> added): +> +>
+> +> +> +> 5. Run ikiwiki again with the same command line. For example: `ikiwiki --setup setup_file` +> +> 6. Pages are output correctly in creation time order. For example, +> actual partial HTML of the sort-test/index.html from commands used +> above (whitespace-only lines removed; one whitespace-only line +> added): +> +> +> +> +> +> 7. Create a new page with the current Unix mtime and Unix ctime, but a +> !meta date before the most recent creation date of another page. +> For example: +> +> $ echo -e '\[[!meta date="2005-01-01"]]\nOlder.' > test/older.mdwn +> +> 8. Run ikiwiki again with the same command line. For example: `ikiwiki --setup setup_file` +> +> 9. All previously sorted pages output correctly in order of their +> creation time, but the new page is output incorrectly at the top as +> if its modification time was its creation time. For example, +> actual partial HTML of the sort-test/index.html from commands used +> above (whitespace-only lines removed; two whitespace-only +> lines added): +> +> +> +> +> +> +> +> 10. Run ikiwiki again with the same command line. For example: `ikiwiki --setup setup_file` +> +> 11. All pages, including new page, are output correctly in creation time +> order. For example, actual partial HTML of the sort-test/index.html +> from commands used above (whitespace-only lines removed; two +> whitespace-only lines added): +> +> +> +> +> +> +> +> File status after all the above actions: +> +> $ stat test/* +> File: `test/new.mdwn' +> Size: 33 Blocks: 8 IO Block: 4096 regular file +> Device: ca20h/51744d Inode: 684160 Links: 1 +> Access: (0644/-rw-r--r--) Uid: ( 1000/ harding) Gid: ( 1000/ harding) +> Access: 2008-12-20 21:48:32.000000000 -0500 +> Modify: 2008-12-20 21:27:03.000000000 -0500 +> Change: 2008-12-20 21:27:03.000000000 -0500 +> File: `test/older.mdwn' +> Size: 35 Blocks: 8 IO Block: 4096 regular file +> Device: ca20h/51744d Inode: 684407 Links: 1 +> Access: (0644/-rw-r--r--) Uid: ( 1000/ harding) Gid: ( 1000/ harding) +> Access: 2008-12-20 21:48:32.000000000 -0500 +> Modify: 2008-12-20 21:42:10.000000000 -0500 +> Change: 2008-12-20 21:42:10.000000000 -0500 +> File: `test/old.mdwn' +> Size: 33 Blocks: 8 IO Block: 4096 regular file +> Device: ca20h/51744d Inode: 684161 Links: 1 +> Access: (0644/-rw-r--r--) Uid: ( 1000/ harding) Gid: ( 1000/ harding) +> Access: 2008-12-20 21:48:32.000000000 -0500 +> Modify: 2008-12-20 21:27:09.000000000 -0500 +> Change: 2008-12-20 21:27:09.000000000 -0500 +> +> My ikiwiki configuration file (being used to port a blog from pyblosxom +> to ikiwiki): +> +> harding@mail:~$ sed 's/#.*//; /^[ ]*$/d' .ikiwiki/gnuisance.setup +> use IkiWiki::Setup::Standard { +> wikiname => "HardingBlog", +> adminemail => 'dave@dtrt.org', +> srcdir => "/srv/backup/git/gnuisance.net", +> destdir => "/srv/test.dtrt.org", +> url => "http://srv.dtrt.org", +> wrappers => [ +> ], +> atom => 1, +> syslog => 0, +> prefix_directives => 1, +> add_plugins => [qw{goodstuff tag}], +> disable_plugins => [qw{passwordauth}], +> tagbase => "tag", +> } +> +> --[David A. Harding](http://dtrt.org/), 2008-12-20 + +Thank you for a textbook excellent reproduction recipe. + +What appears to be going on here is that meta directives are not processed +until the leaf pages are rendered, and thus the ctime setting is not +available at the time that they are inlined, and the newer unix ctime is +used. On the second build, the meta data has already been recorded. + +This can probably be avoided by processing meta date at scan time. + +Verified, fix works. [[done]] +--[[Joey]]