marcoarment / secondcrack

A static-file Markdown blogging engine.

Home Page:http://www.marco.org/secondcrack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Month archives only show a few posts

cdevroe opened this issue · comments

These are taken from Marco's own Readme. I figured I'd put them as issues that can be discussed, resolved.

"The month archives sometimes only contain a few posts."

Further information welcome.

More specifically, the updater says its updating the month archive but doesn't actually. A wipe of the cache and a full rebuild has fixed it every time for me. The first potential culprit is, I think, engine/update.sh I just haven't had a chance to dig into it yet.

ok, so update.sh is a wrapper for calling update.php, update.php wraps a call to Updater::update(), since its not useful to post the entirety of the architecture I'll stop there.

I'm looking at Updater::post_filenames_in_year_month and how its different from Updater::most_recent_post_filenames because the issue seems to be (at least in my specific test case) that the most recent post isn't making it into the posts array thats passed to the Post::write_index for the archives, when it does for the frontpage.

the difference is post_filenames_in_year_month calls posts_in_year_month which reads from cache/posts-[year]-[month]-[md5 of require_tag . " " . require_type]

and most_recent_post_filenames reads from cache/dir-[md5 of source_path . /posts]

for some reason the post doesn't make its way into the posts in year month cache, although it does in the dir- cache, so thats the next place I'll look into, how/when those caches are created.

Its entirely possible that I'm missing something, but it seems like once the cache file is created for the month archive it never gets updated unless its manually deleted because of the following lines:

engine/Updater.php 48 - 50

if (file_exists($cache_fname)) {
        $files = unserialize(file_get_contents($cache_fname));
    }

since the $cache_fname value is set to:

$cache_fname = self::$cache_path . "/posts-$year-$month-" . md5($require_tag . ' ' . $require_type);

and that filename won't change for the month's archive, it will only reach the else statement and update the archive cache file when it has been deleted.

By eliminating that if statement, it correctly updates the archive for me, but I feel like I'm missing something.