Skip to content

fix: use prepend instead of alias_method pattern - #206

Draft
mhier wants to merge 1 commit into
alphanodes:mainfrom
mhier:mhier/fix-method-pattern
Draft

fix: use prepend instead of alias_method pattern#206
mhier wants to merge 1 commit into
alphanodes:mainfrom
mhier:mhier/fix-method-pattern

Conversation

@mhier

@mhier mhier commented Jun 17, 2026

Copy link
Copy Markdown

When combining the additionals plugin with other plugins, e.g. the redmine_products plugin by RedmineUp, some pages like /my/page will crash with the following stack trace:

I, [2026-06-17T16:01:47.314842 #21255]  INFO -- : [97a23156-7a96-493a-b256-2a332adf5f9d] Started GET "/my/page" for 131.169.132.62 at 2026-06-17 16:01:47 +0000                                                                                                    
I, [2026-06-17T16:01:47.316080 #21255]  INFO -- : [97a23156-7a96-493a-b256-2a332adf5f9d] Processing by MyController#page as HTML                                                                                                                                   
I, [2026-06-17T16:01:47.323266 #21255]  INFO -- : [97a23156-7a96-493a-b256-2a332adf5f9d]   Current user: mhier (id=108)                                                                                                                                            
I, [2026-06-17T16:01:47.354849 #21255]  INFO -- : [97a23156-7a96-493a-b256-2a332adf5f9d]   Rendered layout layouts/base.html.erb (Duration: 17.6ms | GC: 1.6ms)                                                                                                    
I, [2026-06-17T16:01:47.355437 #21255]  INFO -- : [97a23156-7a96-493a-b256-2a332adf5f9d] Completed 500 Internal Server Error in 39ms (ActiveRecord: 6.2ms (9 queries, 0 cached) | GC: 2.1ms)                                                                       
F, [2026-06-17T16:01:47.406690 #21255] FATAL -- : [97a23156-7a96-493a-b256-2a332adf5f9d]                                                                                                                                                                           
[97a23156-7a96-493a-b256-2a332adf5f9d] SystemStackError (stack level too deep):                                                                                                                                                                                    
[97a23156-7a96-493a-b256-2a332adf5f9d]                                                                                                                                                                                                                             
[97a23156-7a96-493a-b256-2a332adf5f9d] plugins/redmine_products/lib/redmine_products/patches/query_patch.rb:14:in `add_filter'                                                                                                                                     
[97a23156-7a96-493a-b256-2a332adf5f9d] plugins/additionals/lib/additionals/patches/query_patch.rb:49:in `add_filter_with_additionals'                                                                                                                              
[97a23156-7a96-493a-b256-2a332adf5f9d] plugins/redmine_products/lib/redmine_products/patches/query_patch.rb:14:in `add_filter'                                                                                                                                     
[97a23156-7a96-493a-b256-2a332adf5f9d] plugins/additionals/lib/additionals/patches/query_patch.rb:49:in `add_filter_with_additionals' 
<<<countless repeats of these two lines>>>
[97a23156-7a96-493a-b256-2a332adf5f9d] app/helpers/my_helper.rb:98:in `render_issuesassignedtome_block'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/helpers/my_helper.rb:64:in `render_block_content'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/helpers/my_helper.rb:35:in `render_block'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/helpers/my_helper.rb:27:in `block in render_blocks'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/helpers/my_helper.rb:26:in `each'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/helpers/my_helper.rb:26:in `render_blocks'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/views/my/page.html.erb:14
[97a23156-7a96-493a-b256-2a332adf5f9d] app/views/my/page.html.erb:12:in `each'
[97a23156-7a96-493a-b256-2a332adf5f9d] app/views/my/page.html.erb:12
[97a23156-7a96-493a-b256-2a332adf5f9d] lib/redmine/sudo_mode.rb:78:in `sudo_mode'

This PR aims at fixing this, by changing the way how the plugin overrides methods to the modern prepend-based pattern instead of using the outdated alias_method pattern.

Note: I am not a ruby expert, so maybe I am doing it in the wrong way here. I apologise in that case.

Note2: This is a draft, because I am using a pre-release version of the redmine_products plugin. The current release also uses the old alias_method. Unfortunately, this is incompatible in both directions. I know, other plugins also move to the new prepend-based pattern, so this plugin should eventually do it as well, but maybe it is not the right timing yet?

@alexandermeindl

Copy link
Copy Markdown
Collaborator

Thanks for digging into this, @mhier - and no need to apologise, your analysis is spot on.

You've actually identified exactly the reason we haven't switched to prepend yet: compatibility with RedmineUp plugins. As you noticed, the old alias_method and the new prepend pattern are incompatible in both directions, so as long as RedmineUp ships with alias_method we're stuck on the old pattern to stay compatible with their plugins.

The good news: we very much want to move to prepend and we'll happily celebrate the day we can. As soon as RedmineUp publishes their plugins with the prepend-based pattern (i.e. once it's a real release, not just a pre-release), we'll switch additionals over to prepend across the board.

So the timing isn't quite right yet, but you're pushing in exactly the direction we'll go. Let's keep this open / on the radar until RedmineUp's release lands.

@mhier

mhier commented Jun 18, 2026

Copy link
Copy Markdown
Author

Thanks, that's good news. I am currently in contact with RedmineUp and working with them to move their plugins to the prepend-based pattern. It was only right before submitting this ticket that I realised that I am using their pre-release version for testing :-) So it should not be long before they publish their plugins following the new pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants