sugar-framework / sugar

Modular web framework for Elixir
https://sugar-framework.github.io/
MIT License
430 stars 29 forks source link

Plug.Builder.compile/1 and Plug.Builder.compile/2 deprecation in Sugar controllers #77

Closed YellowApple closed 8 years ago

YellowApple commented 9 years ago

On first run of an iex session involving a minimal Sugar app (router, one controller, minimal mix.exs and config.exs):

DixonCider:mission_log rnorthrup$ iex -S mix
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

warning: Plug.Builder.compile/1 and compile/2 is deprecated, please use compile/3 instead
    lib/sugar/controller.ex:123: Sugar.Controller.build_calls_for/3
    lib/sugar/controller.ex:106: Sugar.Controller.build_plug_stacks_for/2
    (elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
    (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
warning: Plug.Builder.compile/1 and compile/2 is deprecated, please use compile/3 instead
    lib/sugar/controller.ex:123: Sugar.Controller.build_calls_for/3
    lib/sugar/controller.ex:107: Sugar.Controller.build_plug_stacks_for/2
    (elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
    (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
warning: Plug.Builder.compile/1 and compile/2 is deprecated, please use compile/3 instead
    lib/http_router.ex:143: HttpRouter."MACRO-__before_compile__"/2
    (elixir) src/elixir_dispatch.erl:187: :elixir_dispatch.expand_macro_fun/6
    (elixir) src/elixir_dispatch.erl:171: :elixir_dispatch.expand_require/5
    (elixir) src/elixir_dispatch.erl:97: :elixir_dispatch.dispatch_require/6
Compiled lib/mission_log/controllers/main.ex
Compiled lib/mission_log/router.ex
Generated mission_log app
Interactive Elixir (1.0.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

It looks like Plug.Builder.compile/3 expects an env to be the first argument, followed by the pipeline as the second and a list of objects as the third. Creating a bug report to track this and remind myself to get around to doing the necessary refactoring in Sugar.Controller (and in HttpRouter, which - per the above console vomiting - is also affected by this). Not sure why Jose felt the need to swap the args around, but it shouldn't be difficult to work around it on our end.

slogsdon commented 9 years ago

Thanks for filling this issue! I've been meaning to update this. I should have done it back when I pushed that commit but didn't really notice it. :frowning:

Good news is that it should be a straightforward fix. I'll try to get to this soon if you haven't already.

ghost commented 8 years ago

I have tried to use Sugar recently and apparently this is still a problem…

slogsdon commented 8 years ago

@Annwenn Sorry about that! I must have forgotten to push the changes that I did for this a while ago. It should be fixed as of v0.4.9. Let me know if you have any issues with that

ghost commented 8 years ago

v0.4.9 seems to have fixed it.