original_string: public function get_contexts_to_reindex() {
          global $DB;
  
          list ($extrajoins, $dborder) = $this->get_contexts_to_reindex_extra_sql();
          $contexts = [];
          $selectcolumns = \context_helper::get_preload_record_columns_sql('x');
          $groupbycolumns = '';
          foreach (\context_helper::get_preload_record_columns('x') as $column => $thing) {
              if ($groupbycolumns !== '') {
                  $groupbycolumns .= ',';
              }
              $groupbycolumns .= $column;
          }
          $rs = $DB->get_recordset_sql("
                  SELECT $selectcolumns
                    FROM {course_modules} cm
                    JOIN {context} x ON x.instanceid = cm.id AND x.contextlevel = ?
                         $extrajoins
                   WHERE cm.module = (SELECT id FROM {modules} WHERE name = ?)
                GROUP BY $groupbycolumns
                ORDER BY $dborder", [CONTEXT_MODULE, $this->get_module_name()]);
          return new \core\dml\recordset_walk($rs, function($rec) {
              $id = $rec->ctxid;
              \context_helper::preload_from_record($rec);
              return \context::instance_by_id($id);
          });
      }
code: public function get_contexts_to_reindex() {
          global $DB;
  
          list ($extrajoins, $dborder) = $this->get_contexts_to_reindex_extra_sql();
          $contexts = [];
          $selectcolumns = \context_helper::get_preload_record_columns_sql('x');
          $groupbycolumns = '';
          foreach (\context_helper::get_preload_record_columns('x') as $column => $thing) {
              if ($groupbycolumns !== '') {
                  $groupbycolumns .= ',';
              }
              $groupbycolumns .= $column;
          }
          $rs = $DB->get_recordset_sql("
                  SELECT $selectcolumns
                    FROM {course_modules} cm
                    JOIN {context} x ON x.instanceid = cm.id AND x.contextlevel = ?
                         $extrajoins
                   WHERE cm.module = (SELECT id FROM {modules} WHERE name = ?)
                GROUP BY $groupbycolumns
                ORDER BY $dborder", [CONTEXT_MODULE, $this->get_module_name()]);
          return new \core\dml\recordset_walk($rs, function($rec) {
              $id = $rec->ctxid;
              \context_helper::preload_from_record($rec);
              return \context::instance_by_id($id);
          });
      }
code_tokens: public function get_contexts_to_reindex ( ) { global $ DB ; list ( $ extrajoins , $ dborder ) = $ this -> get_contexts_to_reindex_extra_sql ( ) ; $ contexts = [ ] ; $ selectcolumns = \ context_helper :: get_preload_record_columns_sql ( 'x' ) ; $ groupbycolumns = '' ; foreach ( \ context_helper :: get_preload_record_columns ( 'x' ) as $ column => $ thing ) { if ( $ groupbycolumns !== '' ) { $ groupbycolumns .= ',' ; } $ groupbycolumns .= $ column ; } $ rs = $ DB -> get_recordset_sql ( "
                  SELECT $selectcolumns
                    FROM {course_modules} cm
                    JOIN {context} x ON x.instanceid = cm.id AND x.contextlevel = ?
                         $extrajoins
                   WHERE cm.module = (SELECT id FROM {modules} WHERE name = ?)
                GROUP BY $groupbycolumns
                ORDER BY $dborder" , [ CONTEXT_MODULE , $ this -> get_module_name ( ) ] ) ; return new \ core \ dml \ recordset_walk ( $ rs , function ( $ rec ) { $ id = $ rec -> ctxid ; \ context_helper :: preload_from_record ( $ rec ) ; return \ context :: instance_by_id ( $ id ) ; } ) ; }
docstring: Gets a list of all contexts to reindex when reindexing this search area.
  
  For modules, the default is to return all contexts for modules of that type, in order of
  time added (most recent first).
  
  @return \Iterator Iterator of contexts to reindex
  @throws \moodle_exception If any DB error
docstring_tokens: Gets a list of all contexts to reindex when reindexing this search area .