From a0dffaa94664840e7a215200d46cb2de3f9c8d1f Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 16 Jun 2015 09:03:28 +0100 Subject: [PATCH] MDL-42192 accesslib: tweak get_all_capabilities Tony thinks its bike shed painting, I think its a bit more readable and memory efficient. I am using integrator dictatorship for sure. --- lib/accesslib.php | 13 +++++++------ version.php | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 369e3eb2183..985fd5866d2 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2976,18 +2976,19 @@ function get_capability_info($capabilityname) { /** * Returns all capabilitiy records, preferably from MUC and not database. * - * @return array All capability records + * @return array All capability records indexed by capability name */ function get_all_capabilities() { global $DB; $cache = cache::make('core', 'capabilities'); if (!$allcaps = $cache->get('core_capabilities')) { - $allcaps = $DB->get_records('capabilities', null, '', 'name as uniquename, *'); - foreach ($allcaps as $k => $v) { - unset($v->uniquename); - $v->riskbitmask = (int) $v->riskbitmask; - $allcaps[$k] = (array) $v; + $rs = $DB->get_recordset('capabilities'); + $allcaps = array(); + foreach ($rs as $capability) { + $capability->riskbitmask = (int) $capability->riskbitmask; + $allcaps[$capability->name] = (array) $capability; } + $rs->close(); $cache->set('core_capabilities', $allcaps); } return $allcaps; diff --git a/version.php b/version.php index a362da5f014..298b31120bf 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2015061200.01; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2015061600.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.