spacewander commented on code in PR #7273:
URL: https://github.com/apache/apisix/pull/7273#discussion_r901194054


##########
apisix/plugin.lua:
##########
@@ -398,6 +406,49 @@ function _M.filter(ctx, conf, plugins, route_conf)
 
     trace_plugins_info_for_debug(ctx, plugins)
 
+
+    if custom_sort then
+        local tmp_plugin_objs = core.tablepool.fetch("tmp_plugin_objs", 0, 
#plugins / 2)
+        local tmp_plugin_confs = core.tablepool.fetch("tmp_plugin_confs", 
#plugins / 2, 0)
+
+        for i = 1, #plugins, 2 do
+            local plugin_obj = plugins[i]
+            local plugin_conf = plugins[i + 1]
+
+            -- in the rewrite phase, the plugin executes in the following 
order:
+            -- 1. execute the rewrite phase of the plugins on route(including 
the auth plugins)
+            -- 2. merge plugins from consumer and route
+            -- 3. execute the rewrite phase of the plugins on consumer(phase: 
rewrite_in_consumer)
+            -- in this case, we need to skip the plugins that was already 
executed(step 1)
+            if phase and phase == "rewrite_in_consumer" and not 
plugin_conf._from_consumer then
+                plugin_conf._skip_rewrite_in_consumer = true
+            end
+
+            tmp_plugin_objs[tostring(plugin_conf)] = plugin_obj
+            core.table.insert(tmp_plugin_confs, plugin_conf)
+
+            if not plugin_conf._meta or not plugin_conf._meta.priority then
+                plugin_conf._meta = core.table.new(0, 1)

Review Comment:
   Why add `type(plugin_conf._meta) ~= "table"`?



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to