1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23: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"; $glob_str = $env->storage_prefix . "*.md";
$existingpages = glob_recursive($glob_str); $existingpages = glob_recursive($glob_str);
$existingpages_count = count($existingpages);
// Debug statements. Uncomment when debugging the pageindex regenerator. // Debug statements. Uncomment when debugging the pageindex regenerator.
// var_dump($env->storage_prefix); // var_dump($env->storage_prefix);
// var_dump($glob_str); // var_dump($glob_str);
@ -15,7 +16,7 @@ if(!file_exists($paths->pageindex))
$pageindex = new stdClass(); $pageindex = new stdClass();
// We use a for loop here because foreach doesn't loop over new values inserted // We use a for loop here because foreach doesn't loop over new values inserted
// while we were looping // while we were looping
for($i = 0; $i < count($existingpages); $i++) for($i = 0; $i < $existingpages_count; $i++)
{ {
$pagefilename = $existingpages[$i]; $pagefilename = $existingpages[$i];
@ -76,6 +77,19 @@ if(!file_exists($paths->pageindex))
$existingpages[] = $subpage_parent_filename; $existingpages[] = $subpage_parent_filename;
} }
} }
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 // Store the new entry in the new page index
$pageindex->$pagekey = $newentry; $pageindex->$pagekey = $newentry;