1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-24 17:13:01 +00:00

For #204: Implement initial (untested!) page history algorithm.

TODO: Search for existing page history revisions
This commit is contained in:
Starbeamrainbowlabs 2020-08-08 02:07:35 +01:00
parent 3b799cbcba
commit 6e7ff16041
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -8,6 +8,7 @@ if(!file_exists($paths->pageindex))
{
$glob_str = $env->storage_prefix . "*.md";
$existingpages = glob_recursive($glob_str);
$existingpages_count = count($existingpages);
// Debug statements. Uncomment when debugging the pageindex regenerator.
// var_dump($env->storage_prefix);
// var_dump($glob_str);
@ -15,7 +16,7 @@ if(!file_exists($paths->pageindex))
$pageindex = new stdClass();
// We use a for loop here because foreach doesn't loop over new values inserted
// while we were looping
for($i = 0; $i < count($existingpages); $i++)
for($i = 0; $i < $existingpages_count; $i++)
{
$pagefilename = $existingpages[$i];
@ -77,6 +78,19 @@ if(!file_exists($paths->pageindex))
}
}
if(function_exists("history_add_revision") && !file_exists("{$pagefilename}.r0")) { // Can't use module_exists - too early
copy($pagefilename, "{$pagefilename}.r0");
$newentry->history = [ (object) [
"type" => "edit",
"rid" => 0,
"timestamp" => $newentry->lastmodified,
"filename" => "{$pagefilename}.r0",
"newsize" => $newentry->size,
"sizediff" => $newentry->size,
"editor" => "unknown"
] ];
}
// Store the new entry in the new page index
$pageindex->$pagekey = $newentry;
}