nic-6443 commented on code in PR #12800:
URL: https://github.com/apache/apisix/pull/12800#discussion_r2600673750
##########
apisix/plugin.lua:
##########
@@ -1283,6 +1297,22 @@ function _M.run_global_rules(api_ctx, global_rules,
phase_name)
core.table.clear(plugins)
plugins = _M.filter(api_ctx, global_rule, plugins, route)
+
+ -- Remove duplicate plugins from the plugins table
+ local i = 1
+ while i <= #plugins do
+ local plugin = plugins[i]
+ local plugin_name = plugin.name
+ if duplicate_plugins[plugin_name] then
+ -- Remove duplicate plugin and its config
+ core.table.remove(plugins, i)
+ core.table.remove(plugins, i)
+ else
+ -- Move to next plugin pair
+ i = i + 2
+ end
+ end
+
Review Comment:
We not only need to remove duplicate plugins that appear in the global rule,
but also merge the remaining plugins into a `plugins` table before executing
them. Otherwise, the execution order of the plugins will depend on the order of
the `values` array rather than plugin priority, which is unintended.。
```
for _, global_rule in config_util.iterate_values(values) do
...
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]