View Issue Details

IDProjectCategoryView StatusLast Update
0031892mantisbtplug-inspublic2023-01-25 14:02
Reportersederther Assigned Todregad  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version2.25.5 
Summary0031892: Error occurs when adding bugnote through API in PHP8
Description

Hello,

I received the following error when calling

<pre><code>
/api/rest/issues/:issue_id/notes
</code></pre>

<pre><code>[Tue Jan 10 15:08:16.309432 2023] [proxy_fcgi:error] [pid 2366:tid 140321925056256] [client 10.0.2.2:57660] AH01071: Got error 'PHP message: Slim Application Error:\nType: Error\nMessage: Unknown named parameter $files\nFile: /projects/mantisbt/core/event_api.php\nLine: 206\nTrace: #0 /projects/mantisbt/core/event_api.php(232): event_callback()\n#1 /projects/mantisbt/core/event_api.php(164): event_type_execute()\n#2 /projects/mantisbt/core/commands/IssueNoteAddCommand.php(281): event_signal()\n#3 /projects/mantisbt/core/commands/Command.php(137): IssueNoteAddCommand->process()\n#4 /projects/mantisbt/api/rest/restcore/issues_rest.php(266): Command->execute()\n#5 [internal function]: rest_issue_note_add()\n#6 /projects/mantisbt/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(40): call_user_func()\n#7 /projects/mantisbt/vendor/slim/slim/Slim/Route.php(281): Slim\Handlers\Strategies\RequestResponse->invoke()\n#8 /projects/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->invoke()\n#9 /projects/mantisbt/vendor/slim/slim/Slim/Route.php(268): Slim\Route->callMiddlewareStack()\n#10 /projects/mantisbt/ven...'
</code></pre>

Steps To Reproduce

Its happening when there is a plugin that implements hook EVENT_BUGNOTE_ADD and the function called does not have parameter named $files.

Additional Information

I have submitted this pull request in github
https://github.com/mantisbt/mantisbt/pull/1863

TagsNo tags attached.

Activities

dregad

dregad

2023-01-11 19:25

developer   ~0067288

Its happening when there is a plugin that implements hook EVENT_BUGNOTE_ADD and the function called does not have parameter named $files.

This is the root cause, actually...

Your Plugin's event hook's signature must match the parameters as called by the event signal. In this case the documentation clearly states that there are 3 parameters, and the 3rd one's key must be files.

IMO the appropriate fix here is to update your plugin, not to change MantisBT's core (event API).

sederther

sederther

2023-01-12 03:17

reporter   ~0067290

I understand. I will fix the plugin and close the pull request. thank you!

dregad

dregad

2023-01-12 07:16

developer   ~0067291

Thanks for your understanding