← Back to team overview

mahara-contributors team mailing list archive

[Bug 1519989] [NEW] Refactor duplicate collections access code in index.php & index.json.php

 

Public bug reported:

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.

** Affects: mahara
     Importance: Low
         Status: Confirmed


** Tags: collections snack-sized

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1519989

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

Status in Mahara:
  Confirmed

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1519989/+subscriptions


Follow ups