Skip to content

Commit

Permalink
Save .comment data only when modified #66 #59
Browse files Browse the repository at this point in the history
This fixes the problem that .comment files were written whenever the
page was parsed which made the order in the threads syntax and in the
admin interface meaningless.
Old dates will still be meaningless but at least the pages with new
comments should appear in the correct order now though pages will still
move to the top when the comment status is changed. This could be
properly fixed by storing the date of the last comment in the metadata
and indexing the metadata, then it would be easy to get all dates.
  • Loading branch information
michitux committed Sep 13, 2012
1 parent ae836b7 commit 1eedfbc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions syntax/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ function handle($match, $state, $pos, &$handler) {
if (@file_exists($file)) {
$data = unserialize(io_readFile($file, false));
}
$data['title'] = $title;
$data['status'] = $status;
io_saveFile($file, serialize($data));
// only save when the status or title was actually changed, the timestamp of the .comments file is used
// as sorting criteria for the threads view!
// note that isset can't be used for the first test as isset returns false for NULL values!
if (!array_key_exists('title', $data) || $data['title'] !== $title || !isset($data['status']) || $data['status'] !== $status) {
$data['title'] = $title;
$data['status'] = $status;
io_saveFile($file, serialize($data));
}

return $status;
}
Expand Down

0 comments on commit 1eedfbc

Please sign in to comment.