funktechno/kanboard-plugin-wiki

Error creating a wiki page

Closed this issue · 6 comments

ovruni commented

This issue is:

  • Bug report
  • Feature request
  • Improvement

Actual behaviour

After clicking the save button when trying to create a wiki page no wiki page is created

Expected behaviour

A new wiki page is expected to be created

Steps to reproduce

Click on "New Wiki page", fill in "Title", "Content" and click "Save".

Screenshots

Logs

Fatal error: Uncaught TypeError: Symfony\Component\EventDispatcher\EventDispatcher::dispatch(): Argument #1 ($event) must be of type object, string given, called in /var/www/app/plugins/Wiki/Model/WikiEventJob.php on line 42 and defined in /var/www/app/vendor/symfony/event-dispatcher/EventDispatcher.php:48 Stack trace: #0 /var/www/app/plugins/Wiki/Model/WikiEventJob.php(42): Symfony\Component\EventDispatcher\EventDispatcher->dispatch() #1 /var/www/app/plugins/Wiki/Model/Wiki.php(270): Kanboard\Plugin\Wiki\Model\WikiEventJob->execute() #2 /var/www/app/plugins/Wiki/Controller/WikiController.php(326): Kanboard\Plugin\Wiki\Model\Wiki->createpage() #3 /var/www/app/app/Core/Controller/Runner.php(77): Kanboard\Plugin\Wiki\Controller\WikiController->save() #4 /var/www/app/app/Core/Controller/Runner.php(31): Kanboard\Core\Controller\Runner->executeController() #5 /var/www/app/index.php(9): Kanboard\Core\Controller\Runner->execute() #6 {main} thrown in /var/www/app/vendor/symfony/event-dispatcher/EventDispatcher.php on line 48

Configuration

  • Kanboard version: 1.2.32
  • Plugin version: 0.3.2
  • Database type and version: Mariadb 10.5.19
  • PHP version: 7.4.33
  • OS: GNU/Linux
  • Browser: Firefox
  • Application settings Language: English
ovruni commented

Synfony 4.3 has changed the signature of the EventDispatcherInterface::dispatch() method, changing the order of the parameters.

It is necessary to modify the dispatch method in https://github.com/funktechno/kanboard-plugin-wiki/blob/dev/Model/WikiEventJob.php

$this->dispatcher->dispatch($eventName, $event); to $this->dispatcher->dispatch($event, $eventName);

Yes, but to avoid breaking with earlier versions of Kanboard:

diff --git a/Model/WikiEventJob.php b/Model/WikiEventJob.php
index 5590cbc..3734cad 100644
--- a/Model/WikiEventJob.php
+++ b/Model/WikiEventJob.php
@@ -39,8 +39,11 @@ class WikiEventJob extends BaseJob
             ->buildEventWiki($wikiPage);
 
         if ($event !== null) {
-            $this->dispatcher->dispatch($eventName, $event);
-
+            if (APP_VERSION < '1.2.31') {
+                $this->dispatcher->dispatch($eventName,$event);
+            } else {
+                $this->dispatcher->dispatch($event, $eventName);
+            }
             // if ($eventName === Wiki::EVENT_CREATE) {
             //     $userMentionJob = $this->userMentionJob->withParams($event['comment']['comment'], Wiki::EVENT_USER_MENTION, $event);
             //     $this->queueManager->push($userMentionJob);

Seems I suffer from the same problem, see discourse forum "Update to 1.2.32: WIKI-plugin no longer works!"

imfx77 commented

Yes, but to avoid breaking with earlier versions of Kanboard:

diff --git a/Model/WikiEventJob.php b/Model/WikiEventJob.php
index 5590cbc..3734cad 100644
--- a/Model/WikiEventJob.php
+++ b/Model/WikiEventJob.php
@@ -39,8 +39,11 @@ class WikiEventJob extends BaseJob
             ->buildEventWiki($wikiPage);
 
         if ($event !== null) {
-            $this->dispatcher->dispatch($eventName, $event);
-
+            if (APP_VERSION < '1.2.31') {
+                $this->dispatcher->dispatch($eventName,$event);
+            } else {
+                $this->dispatcher->dispatch($event, $eventName);
+            }
             // if ($eventName === Wiki::EVENT_CREATE) {
             //     $userMentionJob = $this->userMentionJob->withParams($event['comment']['comment'], Wiki::EVENT_USER_MENTION, $event);
             //     $this->queueManager->push($userMentionJob);

Seems a valid solution to both keep the backward compatibility and fix the new problem.
I don't see a pull request about it ... but is it really necessary when both the problem and the solution are known?
I guess many of us are up to date with Kanboard and keep those local plugin changes just so the Wiki works.
So? What is keeping an official fix from happening? Any contributor with push access?

Also, as I can see the symphony dependencies were actually updated in Kanboard v.1.2.31
So the correct check should be:
if (APP_VERSION <= '1.2.31')
or
if (APP_VERSION < '1.2.32')
Am I wrong?

You're wrong.

Also, as I can see the symphony dependencies were actually updated in Kanboard v.1.2.31

This means that the 31 was broken by the update.
So if (APP_VERSION < '1.2.31') is correct for running the old code.

Thanks for describing how to fix the issue!

Additionally, you should change line 58 of the same file [the one related to "public function executeWithId"] if you want to be able to delete any page.