hubzero / hubzero-cms

Platform for Scientific Collaboration
https://hubzero.org
GNU General Public License v2.0
47 stars 57 forks source link

[fix] Plugin parameters were being overwritten on save #1706

Closed mdlama closed 4 months ago

mdlama commented 5 months ago

JIRA card or HubZero ticket reference

I have not submitted a ticket on this.

Brief summary of the issue

Plugin parameters are being overwritten on save. Casting of jos_plugin_params database table fields in the \Hubzero\Plugin\Params::oneByPlugin method was causing the issue. Effect was to only allow for one row per object id, causing for example all group plugins to share the same row in the database, leading to lost parameter settings.

Brief summary of fixed code

Changed the oneByPlugin method to NOT cast the two string fields to integer. Also made it a oneByPluginOrNew to account for first-time save of settings. I refactored a bit by removing the sending of the settings to the view, which seemed unnecessary. Another goal of the refactor was a reduction in code redundancy.

Testing

Doing a search on "oneByPlugin," it appeared to me that only four plugins were affected by this: the blog, collections, and forum group plugins, and the member blog plugin. I tested the changes by starting from scratch on a new group and initializing settings for the three group plugins. They each got their own row in the jos_plugin_params table, and their settings were not overwritten on other plugin setting saves (i.e. they persisted). I also changed the settings in multiple plugins, with the changes persisting as well. Finally, I set the settings on a member's blog, which persisted. There was no other member plugin to test to make sure it didn't share the same row in the table.

Hotfixing??

Well, that might be up to you all, but any loss of data (even if it is just settings) seems to be somewhat problematic, but mostly for usability I think.

Before you submit this pull request, please make sure:

Thanks!