mantisbt-plugins / Announce

Announcements plugin for MantisBT, lets privileged accounts create and post announcements that can be shown to users on a global or per-project basis, and allow users to dismiss individual messages.
MIT License
20 stars 14 forks source link

APPLICATION ERROR #401 using announce plugin #35

Closed luzpaz closed 6 years ago

luzpaz commented 6 years ago

Running MantisBT 2.13.1 with most up to date Announce plugin.

Just tested it. I added an options for each role as per the screenshot: image

Steps to reproduce:

  1. click the + column
  2. add a rule for each user role
  3. repeat step 1 & 2 for each role
  4. When done press 'Edit' to finalize

I get this error:

APPLICATION ERROR #401

Database query failed. Error received from database was #1062: Duplicate entry '2-0-header' for key 'idx_plugin_announce_context' for the query: INSERT INTO mantis_plugin_Announce_context_table
(
message_id,
project_id,
location,
access,
ttl,
dismissable
) VALUES (
?,
?,
?,
?,
?,
?
).
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

Edit:
This error also occurs when submitting more than 1 entry

dregad commented 6 years ago

I was able to reproduce this on my dev box. Will look into it.

dregad commented 6 years ago

@luzpaz there are 2 distinct issues here

  1. The plugin should not crash with an SQL error due to user input
  2. It was not designed to have multiple entries with distinct access levels for a single location (and project)

You probably misunderstood the purpose of the context concept, which was meant to allow display of the same announcement in different ways, even though at the moment only Page Header is implemented.

Your intended usage is therefore not supported, and I would even say not fixable without important modifications. Even if the unique key were changed to include the access level, it would still not work as you intend, because of the way this is handled by MantisBT: specifying e.g. Reporter always implies "or higher". So in your setup, a Developer would see all the announcements for Viewer, Reporter, Updater and Reporter (and would not be able to dismiss the first two...)

I will fix 1, but I'm afraid there is nothing I can do for 2 at the moment.