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

Bugfix: Squash empty tags when saving an edit to a page

This commit is contained in:
Starbeamrainbowlabs 2020-02-04 01:45:14 +00:00
parent 1d540d3d8a
commit 83c9d527cb
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 10 additions and 6 deletions

View file

@ -28,7 +28,8 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Add new `email_debug_dontsend` setting for debugging emails sent by Pepperminty Wiki
- Fixed pressing alt + enter to open a search in a new tab - it should no longer fail and briefly prompt to allow pop-ups
- Squashed a bug in the new upgraded get/set_array_simple search optimisation
- Update Parsedown to squash warning in PHP 7.4+
- Updated Parsedown to squash warning in PHP 7.4+
- Trailing commas in the tags box will no longer result in empty tags being added to pages.
### Changed
- Improved the search indexing system performance - again

View file

@ -108,8 +108,7 @@ register_module([
$content = "<h1>$title</h1>\n";
$page_tags = implode(", ", (!empty($pageindex->{$env->page}->tags)) ? $pageindex->{$env->page}->tags : []);
if(!$env->is_logged_in and $settings->anonedits)
{
if(!$env->is_logged_in and $settings->anonedits) {
$content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>";
}
@ -410,12 +409,16 @@ window.addEventListener("load", function(event) {
// Read in the new page tags, so long as there are actually some
// tags to read in
$page_tags = [];
if(strlen(trim($_POST["tags"])) > 0)
{
if(strlen(trim($_POST["tags"])) > 0) {
$page_tags = explode(",", $_POST["tags"]);
// Trim off all the whitespace
foreach($page_tags as &$tag)
foreach($page_tags as &$tag) {
$tag = trim($tag);
}
// Ignore empty tags
$page_tags = array_filter($page_tags, function($value) {
return !is_null($value) && $value !== '';
});
}
// Check for edit conflicts