mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-21 16:13:00 +00:00
settings: fix firstrun_complete handling if preset to false before wiki initialisation
This commit is contained in:
parent
b0fde1df77
commit
b1e28a0e06
2 changed files with 12 additions and 2 deletions
|
@ -7,6 +7,7 @@ This is the next release of Pepperminty Wiki, that hasn't been released yet.
|
||||||
|
|
||||||
- **Fixed:** Fixed link to the interwiki links documentation on the help page if interwiki links have not yet been setup.
|
- **Fixed:** Fixed link to the interwiki links documentation on the help page if interwiki links have not yet been setup.
|
||||||
- **Fixed:** Fixed typos in system text
|
- **Fixed:** Fixed typos in system text
|
||||||
|
- **Fixed:** Fixed handling of [`firstrun_complete`](https://starbeamrainbowlabs.com/labs/peppermint/peppermint-config-info.php#config_firstrun_complete) setting if `peppermint.json` is prefilled with a `firstrun_complete` directive but the Wiki hasn't been initialised for the first time yet - useful for installations inside Docker
|
||||||
- **Changed:** Catch and deal with more unpacking issues on first run (thanks, @daveschroeter in [#249](https://github.com/sbrl/Pepperminty-Wiki/issues/249))
|
- **Changed:** Catch and deal with more unpacking issues on first run (thanks, @daveschroeter in [#249](https://github.com/sbrl/Pepperminty-Wiki/issues/249))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,18 +55,27 @@ if($settings === null) {
|
||||||
|
|
||||||
// Fill in any missing properties
|
// Fill in any missing properties
|
||||||
$settings_upgraded = false;
|
$settings_upgraded = false;
|
||||||
|
$did_upgrade_firstrun_key = false;
|
||||||
foreach($guiConfig as $key => $propertyData) {
|
foreach($guiConfig as $key => $propertyData) {
|
||||||
if(!property_exists($settings, $key)) {
|
if(!property_exists($settings, $key)) {
|
||||||
error_log("[PeppermintyWiki/$settings->sitename/settings] Upgrading $key");
|
error_log("[PeppermintyWiki/$settings->sitename/settings] Upgrading $key");
|
||||||
$settings->$key = $propertyData->default;
|
$settings->$key = $propertyData->default;
|
||||||
$settings_upgraded = true;
|
$settings_upgraded = true;
|
||||||
|
if($key == "firstrun_complete")
|
||||||
|
$did_upgrade_firstrun_key = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($settings_upgraded)
|
if($settings_upgraded)
|
||||||
file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT));
|
file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
// If the first-run wizard hasn't been completed but we've filled in 1 or more new settings, then we must be a pre-existing wiki upgrading from a previous version. We can guarantee this because of the new firstrun_complete setting
|
// If:
|
||||||
if(!$settings->firstrun_complete && $settings_upgraded) {
|
// * The first-run wizard hasn't been completed
|
||||||
|
// * We've filled in 1 or more new settings
|
||||||
|
// * One of those new settings was firstrun_complete
|
||||||
|
// ...then we must be a pre-existing wiki upgrading from a previous version. We can guarantee this because if the firstrun_complete setting didn't exist before but it was added to an EXISTING peppermint.json (creating a NEW peppermint.json would add firstrun_complete to a new peppermint.json file, which is handled separately above)
|
||||||
|
// This is very important for when a Pepperminty Wiki instance didn't have the firstrun wizard previously but does now. This avoids the first run wizard running when it shouldn't.
|
||||||
|
// Note we added this additional specific check because in Docker containers we recommend that firstrun_complete be manually preset to false, which would previously get autset to true as we thought it was a pre-existing wiki when it isn't! Note also we don't yet have access to the pageindex at this stage, so we can't check that either.
|
||||||
|
if(!$settings->firstrun_complete && $settings_upgraded && $did_upgrade_firstrun_key) {
|
||||||
$settings->firstrun_complete = true;
|
$settings->firstrun_complete = true;
|
||||||
file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT));
|
file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue