original_string: protected static function inner_build_course_cache($course, \core\lock\lock $lock) {
          global $DB, $CFG;
          require_once("{$CFG->dirroot}/course/lib.php");
  
          // Ensure object has all necessary fields.
          foreach (self::$cachedfields as $key) {
              if (!isset($course->$key)) {
                  $course = $DB->get_record('course', array('id' => $course->id),
                          implode(',', array_merge(array('id'), self::$cachedfields)), MUST_EXIST);
                  break;
              }
          }
          // Retrieve all information about activities and sections.
          // This may take time on large courses and it is possible that another user modifies the same course during this process.
          // Field cacherev stored in both DB and cache will ensure that cached data matches the current course state.
          $coursemodinfo = new stdClass();
          $coursemodinfo->modinfo = get_array_of_activities($course->id);
          $coursemodinfo->sectioncache = self::build_course_section_cache($course);
          foreach (self::$cachedfields as $key) {
              $coursemodinfo->$key = $course->$key;
          }
          // Set the accumulated activities and sections information in cache, together with cacherev.
          $cachecoursemodinfo = cache::make('core', 'coursemodinfo');
          $cachecoursemodinfo->set($course->id, $coursemodinfo);
          return $coursemodinfo;
      }
code: protected static function inner_build_course_cache($course, \core\lock\lock $lock) {
          global $DB, $CFG;
          require_once("{$CFG->dirroot}/course/lib.php");
  
          // Ensure object has all necessary fields.
          foreach (self::$cachedfields as $key) {
              if (!isset($course->$key)) {
                  $course = $DB->get_record('course', array('id' => $course->id),
                          implode(',', array_merge(array('id'), self::$cachedfields)), MUST_EXIST);
                  break;
              }
          }
          // Retrieve all information about activities and sections.
          // This may take time on large courses and it is possible that another user modifies the same course during this process.
          // Field cacherev stored in both DB and cache will ensure that cached data matches the current course state.
          $coursemodinfo = new stdClass();
          $coursemodinfo->modinfo = get_array_of_activities($course->id);
          $coursemodinfo->sectioncache = self::build_course_section_cache($course);
          foreach (self::$cachedfields as $key) {
              $coursemodinfo->$key = $course->$key;
          }
          // Set the accumulated activities and sections information in cache, together with cacherev.
          $cachecoursemodinfo = cache::make('core', 'coursemodinfo');
          $cachecoursemodinfo->set($course->id, $coursemodinfo);
          return $coursemodinfo;
      }
code_tokens: protected static function inner_build_course_cache ( $ course , \ core \ lock \ lock $ lock ) { global $ DB , $ CFG ; require_once ( "{$CFG->dirroot}/course/lib.php" ) ; // Ensure object has all necessary fields. foreach ( self :: $ cachedfields as $ key ) { if ( ! isset ( $ course -> $ key ) ) { $ course = $ DB -> get_record ( 'course' , array ( 'id' => $ course -> id ) , implode ( ',' , array_merge ( array ( 'id' ) , self :: $ cachedfields ) ) , MUST_EXIST ) ; break ; } } // Retrieve all information about activities and sections. // This may take time on large courses and it is possible that another user modifies the same course during this process. // Field cacherev stored in both DB and cache will ensure that cached data matches the current course state. $ coursemodinfo = new stdClass ( ) ; $ coursemodinfo -> modinfo = get_array_of_activities ( $ course -> id ) ; $ coursemodinfo -> sectioncache = self :: build_course_section_cache ( $ course ) ; foreach ( self :: $ cachedfields as $ key ) { $ coursemodinfo -> $ key = $ course -> $ key ; } // Set the accumulated activities and sections information in cache, together with cacherev. $ cachecoursemodinfo = cache :: make ( 'core' , 'coursemodinfo' ) ; $ cachecoursemodinfo -> set ( $ course -> id , $ coursemodinfo ) ; return $ coursemodinfo ; }
docstring: Called to build course cache when there is already a lock obtained.
  
  @param stdClass $course object from DB table course
  @param \core\lock\lock $lock Lock object - not actually used, just there to indicate you have a lock
  @return stdClass Course object that has been stored in MUC
docstring_tokens: Called to build course cache when there is already a lock obtained .