Defect #15044

Patch for giving controller_issues_edit_after_save api hook the correct context

Added by Jordan Hollinger about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Plugin API
Target version:2.4.0
Resolution:Fixed Affected version:2.3.3

Description

The API hooks "controller_issues_edit_before/after_save" are not given the correct context (i.e. the same context that "controller_issues_new_before/after_save" get.)

Expected behavior: "controller_issues_new_after_save" and "controller_issues_edit_after_save" should be given the same context.

Actual behavior: "controller_issues_edit_after_save"'s context lacks a controller, project, request, and hook_caller. Plugins must use crazy work-arounds to gain access to them.

Fix: Issue#save_issue_with_child_records has no particular need to be in the Issue model. Moving it to IssuesController allows for a simple fix with minimal impact.

This is my first Redmine patch, and I'm happy to submit it through github, svn, etc, but I've attached it here for comment.

git.patch Magnifier (3.25 KB) Jordan Hollinger, 2013-10-04 23:12

Associated revisions

Revision 12219
Added by Jean-Philippe Lang about 4 years ago

Fixed that controller_issues_edit_before/after_save hooks have no controller context (#15044).

Patch by Jordan Hollinger.

History

#1 Updated by Jean-Philippe Lang about 4 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.4.0
  • Resolution set to Fixed

You're right about this, patch committed in r12219.

Note that your patch broke a few tests with a undefined local variable or method `project' error, project had to be replaced with @issue.project.

Also available in: Atom PDF