I think there is a case where one could argue that the project object should be passed as an argument to hook_project_permission_info() so that permissions can be made available contextually for each project. The use case of this is checking that a project has the relevant features enabled before displaying permissions for those features. For example some project on drupal.org don't have repositories associated with them, such as http://drupal.org/project/webmasters. The way that versioncontrol_project will attempt to save these permissions will fail if no repo is associated with a project, and I feel it'd be cleaner to not show the permissions if they won't be saved.

Comments

mikey_p’s picture

Issue tags: +git phase 2, +git sprint 7

tagging

mikey_p’s picture

Here's a first attempt at this for project itself, and project_release module.

mikey_p’s picture

Status: Active » Needs review

Here's a first attempt at this for project itself, and project_release module.

mikey_p’s picture

settings to needs review.

mikey_p’s picture

Guess the patch failed to attach.

dww’s picture

Status: Needs review » Needs work

Yeah, this makes sense, and I agree this is a worthy addition to the API. However, it's unfortunate we have to call this from places that don't even have a real project $node yet. Not sure there's much we can do about that. Anyway, reviewing and testing, here's what I've found:

A) The project_release_project_permission_info() hunk should either use $project = NULL as the arg or not exist at all. I think PHP does something sane if you invoke a function with more arguments than its expecting, but I'm not sure. Might be cleaner to add it (but it should default to NULL).

B) If we're going to change project_release like this, we should probably have a patch for project_issue.

C) This is missing a patch against project.api.php (for both hook_project_permission_info() and _alter()).

D) The caching in project_permission_load() is all fubar now. If the results of the info() and alter() hook can vary per project, we need to use the project nid as the cache id for our static cache. Basically, we need an array of cached info arrays indexed by nid.

mikey_p’s picture

Status: Needs work » Needs review
StatusFileSize
new6.35 KB

Thanks, I was planning on rolling the hunk for project_release later, this was just enough to get some feedback. You're definitely right that it doesn't complain about extra args, only missing ones.

A) Fixed this

B) Opened #1005736: Update hook_project_permission_info() to accept project agrument

C) Fixed

D) Fixed

I also ran tests, and they all passed, and ran through the patch at #781344: Extend project maintainer UI for manipulating git project ACLs manually.

dww’s picture

Status: Needs review » Reviewed & tested by the community

Yup, perfect. Ship it!

mikey_p’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)
Issue tags: -git phase 2, -git sprint 7

Automatically closed -- issue fixed for 2 weeks with no activity.