Affects Version/s: 2.2.3
Fix Version/s: None
Obtained latest ForumNG from git. (https://github.com/moodleou/moodle-mod_forumng)
upgrade runs, Says upgrade OK, Moodle 2.2.3, running on Ubuntu 10.04, MySQL version 5.1.63, php 220.127.116.11.4.17. Database is InnoDB converted from MYSQL (grrrr)
Original version was 1.9.9, upgraded and forumng working at 1.9.18.
Then inside course, an existing forum gives dmlreadexception, Same problem with a newly created course.
Debug info: Unknown column 'cfd.forumngid' in 'where clause'
I have scoured looking for this and found
CONTRIB-3480 & http://learn.open.ac.uk/mod/oublog/viewpost.php?post=104925, "looking for f.id". However I am not so sure that this is the issue here.
Expanded Debug info:
f.id as f_id,f.course as f_course,f.name as f_name,f.type as f_type,f.intro as f_intro,f.ratingscale as f_ratingscale,f.ratingfrom as f_ratingfrom,f.ratinguntil as f_ratinguntil,f.grading as f_grading,f.attachmentmaxbytes as f_attachmentmaxbytes,f.reportingemail as f_reportingemail,f.subscription as f_subscription,f.feedtype as f_feedtype,f.feeditems as f_feeditems,f.maxpostsperiod as f_maxpostsperiod,f.maxpostsblock as f_maxpostsblock,f.postingfrom as f_postingfrom,f.postinguntil as f_postinguntil,f.typedata as f_typedata,f.magicnumber as f_magicnumber,f.originalcmid as f_originalcmid,f.shared as f_shared,
cm.id as cm_id,cm.course as cm_course,cm.module as cm_module,cm.instance as cm_instance,cm.section as cm_section,cm.added as cm_added,cm.score as cm_score,cm.indent as cm_indent,cm.visible as cm_visible,cm.visibleold as cm_visibleold,cm.groupmode as cm_groupmode,cm.groupingid as cm_groupingid,cm.idnumber as cm_idnumber,cm.groupmembersonly as cm_groupmembersonly,cm.completion as cm_completion,cm.completiongradeitemnumber as cm_completiongradeitemnumber,cm.completionview as cm_completionview,cm.completionexpected as cm_completionexpected,cm.availablefrom as cm_availablefrom,cm.availableuntil as cm_availableuntil,cm.showavailability as cm_showavailability,
c.id as c_id,c.shortname as c_shortname,c.fullname as c_fullname,
FROM mdl_forumng_discussions cfd
WHERE cfd.forumngid = f.id AND cfd.deleted = 0
((cfd.timestart = 0 OR cfd.timestart <= ?)
AND (cfd.timeend = 0 OR cfd.timeend > ?))
OR (cfd.forumngid IN (?,?,?,?,?,?))
) AS f_numdiscussions,
INNER JOIN mdl_forumng_posts fplast ON fd.lastpostid = fplast.id
INNER JOIN mdl_forumng_posts fpfirst ON fd.postid = fpfirst.id
LEFT JOIN mdl_forumng_read fr ON fd.id = fr.discussionid AND fr.userid = ?
fd.forumngid = f.id AND fplast.modified>?
(fd.groupid IS NULL)
OR (fd.groupid = ?)
OR cm.groupmode = 2
OR (fd.forumngid IN (?,?,?,?,?,?))
AND fd.deleted = 0
((fd.timestart = 0 OR fd.timestart <= ?)
AND (fd.timeend = 0 OR fd.timeend > ?))
OR (fd.forumngid IN (?,?,?,?,?,?))
AND ((fplast.edituserid IS NOT NULL AND fplast.edituserid<>?)
AND (fr.time IS NULL OR fplast.modified>fr.time)
) AS f_hasunreaddiscussions
INNER JOIN mdl_course_modules cm ON cm.instance = f.id
AND cm.module = (SELECT id from mdl_modules WHERE name = 'forumng')
INNER JOIN mdl_course c ON c.id = f.course
f.course = ? AND cm.id IN (?,?,?,?,?,?)
0 => 1341910921,
1 => 1341910921,
2 => '26',
3 => '27',
4 => '7',
5 => '13',
6 => '14',
7 => '20',
8 => '5',
9 => 1336726921,
10 => '2210',
11 => '26',
12 => '27',
13 => '7',
14 => '13',
15 => '14',
16 => '20',
17 => 1341910921,
18 => 1341910921,
19 => '26',
20 => '27',
21 => '7',
22 => '13',
23 => '14',
24 => '20',
25 => '5',
26 => '5',
27 => '472',
28 => '6856',
29 => '7188',
30 => '5031',
31 => '5439',
32 => '5512',
33 => '6135',
line 394 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 809 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 3159 of /mod/forumng/mod_forumng.php: call to mysqli_native_moodle_database->get_records_sql()
line 2886 of /mod/forumng/mod_forumng.php: call to mod_forumng::query_forums()
line 425 of /mod/forumng/lib.php: call to mod_forumng::get_course_forums()
line 1026 of /lib/modinfolib.php: call to mod_forumng_cm_info_view()
line 1056 of /lib/modinfolib.php: call to cm_info->call_mod_function()
line 637 of /lib/modinfolib.php: call to cm_info->obtain_view_data()
line 1537 of /course/lib.php: call to cm_info->get_extra_classes()
line 241 of /course/format/topics/format.php: call to print_section()
line 255 of /course/view.php: call to require()
Tables do not have a field of forumngid that much code seems to require.
Table: forumng_discussions. Index: not unique (forumngid)
Table: forumng_subscriptions. Index: not unique (forumngid)
Table: forumng_drafts. Index: not unique (forumngid)
For each of these tables, there is a field forumid, but not forumngid as referenced by fd.forumngid etc within mod_forumng.php at least.
On exploring Current 2.2.3 db/install.xml Fresh install tables are created with forumngid.
On previous Version in 1.9.18 db/install.xml Fresh install tables were created with forumid
I suspect that On upgrade these tables: forumng_discussions, subscriptions & Drafts and perhaps others are already present with forumid and refuse a change to forumngid, or as tables exist, no such checking takes place.
Ran SQL Queries against the moodle database:
alter table mdl_forumng_discussions change forumid forumngid bigint (10);
alter table mdl_forumng_drafts change forumid forumngid bigint (10);
alter table mdl_forumng_subscriptions change forumid forumngid bigint (10);
And the Existing Forums are Viewable again.
I am struggling to understand what might happen in a upgrade, but I do not think this is being accounted for or changed.
Created a new forum (oddly it created two instances at once) Now found another issue on creating a post in a new forum. field 'format' doesn't have a default value... INSERT INTO mdl-forumngposts.. Looks like another issue related to the database tables.
SQL: alter table mdl_forumng_posts change format messageformat tinyint (1);
Working so far with database changes, however beyond that i cannot see why upgrade does not do this.