Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying plugin realm registration files and description not supported #2322

ddb4github opened this issue Jan 19, 2019 · 3 comments
resolved A fixed issue


Copy link

Currently, api_plugin_register_realm only check 'file' and 'plugin' column. And 'file' column can be a file-list
Actually, most plugin frequently change file list, or change permission display with or without prefix "Plugin ->".
Then plugin Dev has to handle realm upgrade by self.

'monitor', 'monitor.php', 'View Monitoring Dashboard', 1);
'monitor', 'monitor.php', 'View Monitoring', 1);
'thold', 'notify_lists.php', 'Manage Notification Lists', 1);
'thold', 'notify_lists.php', 'Plugin -> Manage Notification Lists', 1);
'thold', 'thold.php', __('Configure Thresholds', 'thold'), 1);
'thold', 'thold_add.php,thold.php,listthold.php', 'Configure Thresholds', 1);
'flowview', 'flowview.php', 'Plugin -> Flow Viewer', 1);
'flowview', 'flowview.php,flowview_devices.php,flowview_schedules.php', 'Flow Viewer', 1);

So I prefer new diff as below to more flexible detect plugin realm existing. I'll create PR as soon:

--- lib/plugins.php
+++ lib/plugins.php
@@ -742,8 +742,8 @@
        $exists = db_fetch_cell_prepared('SELECT id
                FROM plugin_realms
                WHERE plugin = ?
-               AND file = ?',
-               array($plugin, $file));
+               AND (file LIKE ? OR display LIKE ?)',
+               array($plugin, "%$file%", "%$display%"));

        if ($exists === false) {
                db_execute_prepared('REPLACE INTO plugin_realms
@@ -777,10 +777,10 @@
        } else {
                db_execute_prepared('UPDATE plugin_realms
-                       SET display = ?
+                       SET display = ?, file = ?
                        WHERE plugin = ?
-                       AND file = ?',
-                       array($display, $plugin, $file));
+                       AND id = ?',
+                       array($display, $file, $plugin, $exists));
ddb4github pushed a commit to ddb4github/cacti that referenced this issue Jan 19, 2019
Copy link

netniV commented Jan 19, 2019

Thanks for the PR but I think this functionality is a bad idea because it could easily match too many and select the wrong plugin. If there is a specific reason for this, I'm open to hearing it, but the change itself as it currently stands could end up giving replacing a different plugin.

cigamit added a commit that referenced this issue Jan 19, 2019
Modifying relam registration files and description not supported in
plugin api
Additionally removing 'Management' from plugins since we have it removed
everywhere else.
Copy link
Contributor Author

Ha! the first condition is 'plugin name' in both of select and update clause.
So if there are some misleading, it is more about each plugin self. New code should not impact cross plugin

@netniV netniV added the resolved A fixed issue label Jan 20, 2019
Copy link

netniV commented Jan 20, 2019

I believe that @cigamit has committed a change for this which is slightly different to your proposed request in b586e2f. Please check that out to see if resolves your issue and if so close this issue.

@ronytomen ronytomen changed the title Plugin Realm should support to be more easily registered about existing checking Modifying plugin realm registration files and description not supported Jan 20, 2019
@cigamit cigamit closed this as completed Feb 9, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
resolved A fixed issue
None yet

No branches or pull requests

3 participants