Skip to content
Browse files

ForumNG: Bad use of ->extra modinfo field causes invalid pages #4107

  • Loading branch information...
1 parent f554302 commit e79c1fc1d9ed1880344a5e230f27423eb918a7fa @sammarshallou sammarshallou committed Jul 9, 2012
Showing with 20 additions and 22 deletions.
  1. +7 −4 db/upgrade.php
  2. +2 −2 lib.php
  3. +7 −12 mod_forumng.php
  4. +4 −4 version.php
View
11 db/upgrade.php
@@ -23,10 +23,13 @@
*/
function xmldb_forumng_upgrade($oldversion=0) {
- global $CFG, $THEME, $db;
- require_once($CFG->dirroot.'/mod/forumng/mod_forumng.php');
+ global $CFG, $THEME, $DB;
- $result = true;
+ if ($oldversion < 2012070900) {
+ // Changed format of modinfo cache, so need to rebuild all courses.
+ rebuild_course_cache(0, true);
+ upgrade_mod_savepoint(true, 2012070900, 'forumng');
+ }
- return $result;
+ return true;
}
View
4 lib.php
@@ -198,8 +198,8 @@ function forumng_get_coursemodule_info($coursemodule) {
global $DB;
if ($forumng = $DB->get_record('forumng',
array('id' => $coursemodule->instance), 'id, name, type')) {
- $info = new object();
- $info->extra = 'class="forumng-type-' . $forumng->type . '"';
+ $info = new cached_cm_info();
+ $info->customdata = (object)array('type' => $forumng->type);
return $info;
}
}
View
19 mod_forumng.php
@@ -365,23 +365,18 @@ public static function get_activity_group($cm, $update=false) {
/**
* Obtains the forum type based on its 'info' object in modinfo (e.g. from
- * $modinfo->instances['forumng'][1234]). Usually this comes from a CSS
- * class inserted in the 'extra' field.
- * <p>
- * (To be honest the CSS class is not needed, it is mostly there as it's
- * the only place we could safely throw in random information so that we
- * can get this data without making extra queries!)
- * @param object $info Info object
+ * $modinfo->instances['forumng'][1234]). Usually this comes from the
+ * custom data in the cm_info object.
+ *
+ * @param object $info Info object (either cm_info or something else)
* @return string Forum type
*/
- private static function get_type_from_modinfo_info($info) {#
+ private static function get_type_from_modinfo_info(cm_info $info) {
if (isset($info->forumtype)) {
- // Only set when using get_modinfo_special for shared activity
- // modules
+ // Only set when using get_modinfo_special for shared activity modules.
return $info->forumtype;
}
- return str_replace('"', '',
- str_replace('class="forumng-type-', '', $info->extra));
+ return $info->get_custom_data()->type;
}
// Object variables and accessors
View
8 version.php
@@ -16,13 +16,13 @@
/**
* Version.
- * @package mod
- * @subpackage forumng
- * @copyright 2011 The Open University
+ *
+ * @package mod_forumng
+ * @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$module->version = 2012062701;
+$module->version = 2012070900;
$module->requires = 2011120100;
$module->cron = 60;

0 comments on commit e79c1fc

Please sign in to comment.
Something went wrong with that request. Please try again.