Closed TsXor closed 10 months ago
I located (prefix)/flarum/vendor/flarum/core/src/Foundation/DispatchEventsTrait.php:31
:
$event->actor = $actor;
after digging around, I found the class of $event
: DiscussionWas(Un)Stickied
in sticky
plugin (the similar also in lock
plugin)
Look at the following declaration:
class DiscussionWasStickied
{
public function __construct(
public Discussion $discussion,
public User $user
) {
}
}
There is no actor
attribute.
Then I modified (prefix)/flarum/vendor/flarum/core/src/Foundation/DispatchEventsTrait.php:31
to the following
if(property_exists($event, 'actor')) {
$event->actor = $actor;
}
and the error was gone.
But this is only a workaround. I don't know if actor
is necessary, or actor
was set dynamically elsewhere, or some of my environment configuations went wrong.
Also, adding actor
property to an event can fix that event.
Adding public $actor;
to DiscussionWasLocked
will fix locking a discussion but not unlocking.
please open the log file located in storage/logs and past the actual error
please open the log file located in storage/logs and past the actual error
I'd like to, but there's nothing in (prefix)/storage/logs
when I reproduce the error.
So sorry: the actual error was just in the beginning of what is sent back, but I ignored it as it was only a deprecation:
Deprecated: Creation of dynamic property Flarum\Sticky\Event\DiscussionWasStickied::$actor is deprecated in /var/www/HIT_feedback_forum/flarum/vendor/flarum/core/src/Foundation/DispatchEventsTrait.php on line 31
you have to turn off deprecation warnings in production.
Current Behavior
When I tried to set a discussion sticky, an error alert will pop up. Inspecting XHR in browser console shows that the following PHP error was sent back:
The same happens when I tried to lock one.
Note: the discussion is actually stickied or locked after the operation. The operation did not fail but the error did happen.
Steps to Reproduce
Expected Behavior
The discussion was set sticky without alert.
Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
see my analysis below
Additional Context
No response