I see that function oa_contextual_tabs_access calls function trash_flag_flag_access, but i do not see a dependency on trash_flag module in oa_contextual_tabs.info.

Comments

Argus’s picture

Status: Active » Postponed (maintainer needs more info)

Please add a step to step description on how to reproduce this bug

paean99’s picture

StatusFileSize
new388 bytes

It isn't a bug that appeared on the site, only a situation that i saw while browsing the code in OA.
oa_contextual_tabs module is calling code in trash_flag module, but there is not a dependency between them. Therefore it is possible to disable trash_flag module at admin/modules, and then a bug should appear once function oa_contextual_tabs_access is executed.

Here is the culprit in oa_contextual_tabs file. It is calling trash_flag_flag_access() function of trash_flag module.

/**
 * Perform access control on the flag.
 *
 * Just piggyback off what trash_flag_flag_access already does.
 */
function oa_contextual_tabs_access($node) {
  global $user;
  $account = $user;
  $flag = flag_load('trash');
  $op = $flag->is_flagged($node->nid) ? 'unflag' : 'flag';
  return trash_flag_flag_access($flag, $node->nid, $op, $account);
}

I added a simple patch that should solve the potential bug.

Argus’s picture

Status: Postponed (maintainer needs more info) » Needs review

Okey...

paean99’s picture

The dependency arise because oa_contextual_tabs is creating a contextual menu tab for node/%node/archive-content. It assumes several times in the code that the trash_flag module is enabled, without confirming it.

Another way to do it would be to add a module_exists() test, this way the dependency would be only conditional.

paean99’s picture

StatusFileSize
new769 bytes

This patch implements the module_exists() solution.
I didn't tried it but it should be ok.

hefox’s picture

Status: Needs review » Fixed

Added check for module_exists oa_archive in the hook_menu item (sorry, totally forgot to mention you in commit message). Thanks!

paean99’s picture

No problem.
It is a very small check for an extreme situation.

But i think i saw others similar situations.
If i remember what those were or encounter them or others again (i have to browse the code from time to time),
i will create a new issue.

Status: Fixed » Closed (fixed)

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