1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-22 13:45:02 +00:00

Standardise error_log prefixes to aid clarity in multi-wiki environments

This commit is contained in:
Starbeamrainbowlabs 2020-07-28 19:42:41 +01:00
parent 7d93aa6a10
commit 1ec1705a62
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
10 changed files with 26 additions and 20 deletions

View file

@ -32,7 +32,11 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Don't worry, we've absorbed all the useful features (see above)
- NOTE TO SELF: Don't forget to update wikimatrix.org when we next make a stable release! (if you are reading this in the release notes for a stable release, please get in touch)
- Enabled horizontal resize handle on sidebar (but it doesn't persist yet)
- `SameSite=Strict` is now set on all cookies in PHP 7.3+ to comply with the [new samesite cookies rules](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite#SameSiteNone_requires_Secure). A warning is generated in PHP 7.2 and below = [please upgrade](https://www.php.net/supported-versions.php) to PHP 7.3+! (#200)
- `SameSite=Strict` is now set on all cookies in PHP 7.3+
- This prevents session-stealing attacks from third-party origins
- This complies with the [new samesite cookies rules](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite#SameSiteNone_requires_Secure).
- A warning is generated in PHP 7.2 and below = [please upgrade](https://www.php.net/supported-versions.php) to PHP 7.3+! (#200)
- The `Secure` cookie flag is now automatically added when clients use HTTPS to prevent downgrade-based session stealing attacks (control this with the new `cookie_secure` setting)
### Fixed
- Squashed a warning when using the fenced code block syntax

View file

@ -53,7 +53,7 @@ if($settings === null) {
$settings_upgraded = false;
foreach($guiConfig as $key => $propertyData) {
if(!property_exists($settings, $key)) {
error_log("[settings] Upgrading $key");
error_log("[PeppermintyWiki/$settings->sitename/settings] Upgrading $key");
$settings->$key = $propertyData->default;
$settings_upgraded = true;
}

View file

@ -758,7 +758,7 @@ function email_user(string $username, string $subject, string $body, bool $ignor
$compiled_headers .= "$header: $value\r\n";
if($settings->email_debug_dontsend) {
error_log("[email] Username: $username ({$settings->users->{$username}->emailAddress})
error_log("[PeppermintyWiki/$settings->sitename/email] Username: $username ({$settings->users->{$username}->emailAddress})
Subject: $subject
----- Headers -----
$compiled_headers

View file

@ -65,7 +65,7 @@ function parse_page_source($source, $untrusted = false, $use_cache = true) {
// If we should use the cache and we failed to write to it, warn the admin.
// It's not terribible if we can't write to the cache directory (so we shouldn't stop dead & refuse service), but it's still of concern.
if($use_cache && !file_put_contents($cache_file, $result))
error_log("[Pepperminty Wiki] Warning: Failed to write to cache file $cache_file.");
error_log("[PeppermintyWiki/$settings->sitename/parser_engine] Warning: Failed to write to cache file $cache_file.");
$result .= "\n<!-- cache: " . ($use_cache ? "miss" : "n/a") . ", id: $cache_id, took: " . round((microtime(true) - $start_time)*1000, 5) . "ms -->\n";
}

View file

@ -2,7 +2,7 @@
register_module([
"name" => "First run wizard",
"version" => "0.1",
"version" => "0.1.1",
"author" => "Starbeamrainbowlabs",
"description" => "Displays a special page to aid in setting up a new wiki for the first time.",
"id" => "feature-firstrun",
@ -61,7 +61,7 @@ register_module([
}
}
else {
error_log("Warning: The public peppermint.json access check has been disabled (either manually or because you're using a local PHP development server with php -S ....). It's strongly recommended you ensure that access from outside is blocked to peppermint.json to avoid (many) security issues and other nastiness such as stealing of site secrets and password hashes.");
error_log("[PeppermintyWiki/firstrun] Warning: The public peppermint.json access check has been disabled (either manually or because you're using a local PHP development server with php -S ....). It's strongly recommended you ensure that access from outside is blocked to peppermint.json to avoid (many) security issues and other nastiness such as stealing of site secrets and password hashes.");
}
// TODO: Check the environment here first

View file

@ -1,7 +1,7 @@
<?php
register_module([
"name" => "Did you mean? support",
"version" => "0.1",
"version" => "0.1.1",
"author" => "Starbeamrainbowlabs",
"description" => "*Experimental* Ever searched for something but couldn't find it because you couldn't spell it correctly? This module is for you! It adds spelling correction for search queries based on the words in the inverted search index.",
"id" => "feature-search-didyoumean",
@ -252,9 +252,10 @@ class BkTree {
* @return bool Whether the removal was successful.
*/
public function remove(string $string) : bool {
global $settings;
// Not allowed to remove the seed word
if($string == $this->seed_word) {
error_log("[PeppermintyWiki/DidYouMean-BkTree] Blocked an attempt to remove the seed word $this->seed_word");
error_log("[PeppermintyWiki/$settings->sitename/DidYouMean-BkTree] Blocked an attempt to remove the seed word $this->seed_word");
return false;
}
@ -349,7 +350,8 @@ class BkTree {
* @return array<string> Similar resultant strings from the BK-Tree.
*/
public function lookup(string $string, int $max_distance = 1, int $count = 0) : array {
error_log("[BkTree/lookup]".var_export($string, true).", dist ".var_export($max_distance, true).", count:".var_export($count, true));
// global $settings;
// error_log("[PeppermintyWiki/$settings->sitename/BkTree/lookup]".var_export($string, true).", dist ".var_export($max_distance, true).", count:".var_export($count, true));
if($this->get_node_count() == 0) return null;
$result = []; $result_count = 0;

View file

@ -1,7 +1,7 @@
<?php
register_module([
"name" => "Search",
"version" => "0.13.1",
"version" => "0.13.2",
"author" => "Starbeamrainbowlabs",
"description" => "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"id" => "feature-search",
@ -154,7 +154,7 @@ register_module([
foreach($results as $key => &$result) {
$filepath = $env->storage_prefix . $result["pagename"] . ".md";
if(!file_exists($filepath)) {
error_log("[pepperminty wiki/$settings->sitename/search] Search engine returned {$result["pagename"]} as a result (maps to $filepath), but it doesn't exist on disk (try rebuilding the search index).");
error_log("[PeppermintyWiki/$settings->sitename/search] Search engine returned {$result["pagename"]} as a result (maps to $filepath), but it doesn't exist on disk (try rebuilding the search index).");
continue; // Something strange is happening
}
$result["context"] = search::extract_context(

View file

@ -1,7 +1,7 @@
<?php
register_module([
"name" => "Theme Gallery",
"version" => "0.4",
"version" => "0.4.1",
"author" => "Starbeamrainbowlabs",
"description" => "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.",
"id" => "feature-theme-gallery",
@ -143,7 +143,7 @@ register_module([
foreach($gallery_urls as $url) {
$next_index = json_decode(@file_get_contents($url));
if(empty($next_index)) {
error_log("Error: Failed to download theme idnex file from '$url' when setting the wiki theme.");
error_log("[PeppermintyWiki/$settings->sitename/theme_gallery] Error: Failed to download theme index file from '$url' when setting the wiki theme.");
continue;
}
foreach($next_index as $next_theme) {
@ -156,7 +156,7 @@ register_module([
}
if($theme_autoupdate_url === null) {
http_response_code(503);
exit(page_renderer::render_main("Failed to set theme - Error - $settings->sitename)", "<p>Oops! $settings->sitename couldn't find the theme you selected. Perhaps it has been changed or deleted, or perhaps there was an error during the download process.</p>
exit(page_renderer::render_main("[PeppermintyWiki/$settings->sitename/theme_gallery] Failed to set theme - Error - $settings->sitename)", "<p>Oops! $settings->sitename couldn't find the theme you selected. Perhaps it has been changed or deleted, or perhaps there was an error during the download process.</p>
<p>Try <a href='?action=theme-gallery'>heading back to the theme gallery</a> and trying again.</p>"));
}
$settings->css_theme_autoupdate_url = $theme_autoupdate_url;
@ -204,7 +204,7 @@ function theme_update($force_update = false) : bool {
$new_css = @file_get_contents($settings->css_theme_autoupdate_url);
// Make sure it's valid
if(empty($new_css)) {
error_log("[Pepperminty Wiki/$settings->sitename] Error: Failed to update theme: Got an error while trying to download theme update from $settings->css_theme_autoupdate_url");
error_log("[PeppermintyWiki/$settings->sitename/theme_gallery] Error: Failed to update theme: Got an error while trying to download theme update from $settings->css_theme_autoupdate_url");
return false;
}
@ -213,7 +213,7 @@ function theme_update($force_update = false) : bool {
$min_version_loc = strpos($new_css, "@minversion") + strlen("@minversion");
$min_version = substr($new_css, $min_version_loc, strpos($new_css, "\n", $min_version_loc));
if(version_compare($version, $min_version) == -1) {
error_log("[Pepperminty Wiki/$settings->sitename] Error: Failed to update theme: $settings->css_theme_gallery_selected_id requires Pepperminty Wiki $min_version, but $version is installed.");
error_log("[PeppermintyWiki/$settings->sitename/theme_gallery] Error: Failed to update theme: $settings->css_theme_gallery_selected_id requires Pepperminty Wiki $min_version, but $version is installed.");
return false;
}

View file

@ -1,7 +1,7 @@
<?php
register_module([
"name" => "User watchlists",
"version" => "0.1.2",
"version" => "0.1.3",
"author" => "Starbeamrainbowlabs",
"description" => "Adds per-user watchlists. When a page on a user's watchlist is edited, a notification email is sent.",
"id" => "feature-watchlist",
@ -215,7 +215,7 @@ register_module([
});
if(!module_exists("page-edit")) {
error_log("[module/feature-watchlist] Note: Without the page-edit module, the feature-watchlist module doesn't make much sense. If you don't want anonymous people to edit your wiki, try the 'anonedits' setting.");
error_log("[PeppermintyWiki/$settings->sitename/feature-watchlist] Note: Without the page-edit module, the feature-watchlist module doesn't make much sense. If you don't want anonymous people to edit your wiki, try the 'anonedits' setting.");
return false;
}

View file

@ -1,7 +1,7 @@
<?php
register_module([
"name" => "Login",
"version" => "0.9.4",
"version" => "0.9.5",
"author" => "Starbeamrainbowlabs",
"description" => "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.",
"id" => "page-login",
@ -133,7 +133,7 @@ register_module([
exit(page_renderer::render_main("Login Error - $settings->sitename", "<p>Your credentials were correct, but $settings->sitename was unable to log you in as an updated hash of your password couldn't be saved. Updating your password hash to the latest and strongest hashing algorithm is an important part of keeping your account secure.</p>
<p>Please contact $settings->admindetails_name, $settings->sitename's adminstrator, for assistance (their email address can be found at the bottom of every page, including this one).</p>"));
}
error_log("[Pepperminty Wiki] Updated password hash for $user.");
error_log("[PeppermintyWiki/$settings->sitename/login] Updated password hash for $user.");
}
// If the email address is still in the old field, migrate it