By devin carlson on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
7.x-2.x
Introduced in version:
7.x-2.0-alpha4
Issue links:
Description:
The media_access() function has been removed in favor of the File Entity access API introduced in #1227706: Add a file entity access API.
Modules that previously relied on media_access() can either switch to file_entity_access() or, if they need to provide compatibility with both Media 1.x and 2.x can include their own wrapper function.
Before:
media_access('create', $account);
After:
file_entity_access('create', NULL, $account);
Wrapper around both media_access() and file_entity_access():
/**
* Determine if a user may perform the given operation on the specified file.
*
* Enables compatibility with Media 1.x and 2.x by providing a wrapper around
* both media_access() and file_entity_access().
*
* @return boolean
* TRUE if the operation may be performed, FALSE otherwise.
*
* @see media_access()
* @see file_entity_access()
*/
function MODULENAME_access($op, $file = NULL, $account = NULL) {
if (function_exists('file_entity_access')) {
$access = file_entity_access($op, $file, $account);
}
elseif (function_exists('media_access')) {
$access = media_access($op, $account);
}
else {
$access = FALSE;
}
return $access;
}
Impacts:
Module developers