Skip to content

Commit

Permalink
41937: Anonymous user can activate notifications for wiki - leading t…
Browse files Browse the repository at this point in the history
…o notifications to crash
  • Loading branch information
alex40724 committed Nov 12, 2024
1 parent 97cc552 commit fc8905d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Modules/Wiki/Setup/class.Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Agent extends Setup\Agent\NullAgent
public function getUpdateObjective(Setup\Config $config = null): Setup\Objective
{
return new Setup\ObjectiveCollection(
"Updates of Services/Skill",
"Updates of Wiki",
false,
...$this->getObjectives()
);
Expand Down Expand Up @@ -62,6 +62,7 @@ protected function getObjectives(): array

// db update steps
$objectives[] = new \ilDatabaseUpdateStepsExecutedObjective(new ilWikiDBUpdateSteps());
$objectives[] = new \ilDatabaseUpdateStepsExecutedObjective(new ilWiki8HotfixDBUpdateSteps());

return $objectives;
}
Expand Down
43 changes: 43 additions & 0 deletions Modules/Wiki/Setup/class.ilWiki8HotfixDBUpdateSteps.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\Wiki\Setup;

/**
* @author Alexander Killing <[email protected]>
*/
class ilWiki8HotfixDBUpdateSteps implements \ilDatabaseUpdateSteps
{
protected \ilDBInterface $db;

public function prepare(\ilDBInterface $db): void
{
$this->db = $db;
}

public function step_1(): void
{
$db = $this->db;
$db->manipulateF(
"DELETE FROM notification WHERE " .
" user_id = %s",
["integer"],
[13]
);
}
}
3 changes: 2 additions & 1 deletion Modules/Wiki/classes/class.ilWikiPageGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public function executeCommand(): string
self::initEditingJS($this->tpl);
}

if ($this->wiki_request->getNotification() > 0) {
if ($this->wiki_request->getNotification() > 0
&& $ilUser->getId() !== ANONYMOUS_USER_ID) {
switch ($this->wiki_request->getNotification()) {
case 1:
ilNotification::setNotification(ilNotification::TYPE_WIKI, $ilUser->getId(), $this->getPageObject()->getParentId(), false);
Expand Down

0 comments on commit fc8905d

Please sign in to comment.