Patch #41678
closedFix lost backward compatibility about return type of ProjectQuery#results_scope
0%
Description
r22811 changed return type of ProjectQuery#results_scope
: Project::ActiveRecord_Relation
=> Array
of Project
instance
That change is no impact for Redmine end users. But it is broken backward compatibility for some Redmine plugins which uses ProjectQuery#results_scope
. This patch fixes it.
In addition, UserQuery#results_scope
(same name method) still returns User::ActiveRecord_Relation
. And TimeEntryQuery#results_scope
ditto.
Related issue: #23954
Files
Related issues
Updated by Nishida Yuya about 2 months ago
After apply fix_lost_backward_compatibility_about_return_type_of_ProjectQuery_results_scope.patch , Project.load_last_activity_date
's effect still lives as following:
Apply following patch for check.
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index f9a390c58..11078d89a 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -335,7 +335,9 @@ def bulk_destroy
# Returns the ProjectEntry scope for index
def project_scope(options={})
- @query.results_scope(options)
+ @query.results_scope(options).tap do |result|
+ binding.b
+ end
end
def retrieve_project_query
Open /projects with "Last activity" column.
Then, @last_activity_date
instance variable is exists following:
[334, 343] in ~/src/github.com/agileware-jp/redmine-dev-mirror/app/controllers/projects_controller.rb
334| private
335|
336| # Returns the ProjectEntry scope for index
337| def project_scope(options={})
338| @query.results_scope(options).tap do |result|
=> 339| binding.b
340| end
341| end
342|
343| def retrieve_project_query
=>#0 block {|result=[#<Project:0x00007fe246c212c8 id: 1, name...|} in project_scope at ~/src/github.com/agileware-jp/redmine-dev-mirror/app/controllers/projects_controller.rb:339
#1 Kernel#tap at <internal:kernel>:90
# and 70 frames (use `bt' command for all frames)
(ruby) result.to_a.first.instance_variable_get(:@last_activity_date)
Fri, 01 Nov 2024 17:10:02.900305000 UTC +00:00
(ruby) result.to_a.first.instance_variable_get(:@last_activity_date).class
ActiveSupport::TimeWithZone
Updated by Nishida Yuya about 2 months ago
Updated by Mizuki ISHIKAWA about 2 months ago
- File add-test.patch add-test.patch added
I confirmed that the method works without issues after applying the patch.
For the plugin, there might be problems if the class of the returned instance changes, so I would like this patch to be incorporated.
I wrote a simple test and attached it.
Updated by Marius BĂLTEANU about 2 months ago
- Related to Feature #23954: Shows the date of the last activity on Projects administration added
Updated by Marius BĂLTEANU about 2 months ago
- Status changed from New to Closed
- Assignee set to Marius BĂLTEANU
Committed the patches as part of #23954, thank you for finding and fixing this issue.
Updated by Nishida Yuya about 2 months ago
Mizuki ISHIKAWA Awesome!
Marius BĂLTEANU Thank you for your response!