Refactor duplicate collections access code in index.php & index.json.php

Bug #1519989 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Confirmed
Low
Unassigned

Bug Description

After patch https://reviews.mahara.org/#/c/5695/6 for Bug1514374, we've now got duplicate code it htdocs/collection/index.php and htdocs/collection/index.json.php, for checking whether the user has access to the particular collections they're trying to look at.

This kind of duplication stands a high likelihood of falling out of sync if changes are made to the access code in the future, so we should abstract it out into a common access method that gets called by both scripts.

The code is not *exactly* the same in both places. index.php intersperses it with code to set the menu headers, and index.json.php sends an error via json_reply on failure, while index.php throws an AccessDeniedException(). So it will require a little bit of thinking to do it. But it's not impossible.

Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 16.04.0 → 16.10.0
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 16.10.0 → 16.10.1
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 16.10.1 → 17.04.0
Changed in mahara:
milestone: 17.04.0 → 17.10.0
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 17.10.0 → 18.04.0
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 18.04.0 → 18.10.0
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

When tackling that, it should be looked at whether we can set coding standards / guidelines when we have a json.php and a .php file so we don't end up in a situation like this again.

tags: added: code-cleanup
Changed in mahara:
milestone: 18.10.0 → none
Lisa Seeto (lisaseeto)
tags: added: refactoring
removed: code-cleanup
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.