Closed (fixed)
Project:
Course
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Dec 2015 at 17:09 UTC
Updated:
26 Jan 2016 at 17:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
djdevinHi,
This is due to a change in the course API.
Can you please check the course outline and make sure that you do not have any course content (node-based) objects that are linked to a node that no longer exists?
We can work on adding an error message instead of the fatal error happening.
Comment #3
prattrob commentedHi djdevin,
I am also working on this issue. Are you referring to the article here?
https://www.drupal.org/node/1534356
We are not able to access any of the course content objects for the affected courses. All the objects in the course display that same error...
Comment #4
djdevinHi,
I don't think it's related to that.
You can reproduce the issue pretty easily by
1) Create a course
2) Add a Poll object
3) Save the course outline
4) Delete the Poll content (not the course object)
5) Try and take the course
Comment #5
prattrob commentedHi djdevin,
I followed the steps and was able to take the course. I didn't actually add any objects to the course besides the poll, and the poll didn't contain any information besides what is created by default. Is there something else I did not do correctly to replicate the issue?
Is there anything we can do to get more information on this error? We haven't changed anything with the Drupal installation since these courses were made so it seems odd they would just throw this error randomly after working fine.
Comment #6
jcarkhuff commentedCould the errors be related to nodes being added that have duplicate titles? Such as multiple quizzes being named 'Quiz'? This is the only thing I noticed about the nodes that were part of these courses.
Comment #7
djdevinNah I don't think so.
The error happens here
But node is empty, so it dies. setNode is called when a course object is initializing. So if you were taking a course object that didn't have a node associated it would fatal out when it tries to load the object.
I think my steps reproduce it because we have some custom code doing things with the objects but let me see if I can get it to error on a clean D7.
The tests still come back okay so there has to be something with the course setup that causes this.
Comment #8
prattrob commentedThanks that would be good if you can reproduce it. We can give you the core version we're on if you need it, along with any module versions.
We meant to post that line earlier. Our lines 117-120 look like this:
public function setNode($node) {
$this->node = clone $node;
$this->setInstanceId($this->node->nid);
}
We saw the code but like Josh mentioned we are not programmers so we are having a tough time figuring out.
Comment #9
sapiusenator commentedTo fix this I made a TEMPORARY change to sites/all/modules/course/includes/CourseObjectNode.inc
After you make the change you shouldn't get an error or referenced content that you have deleted.
You can then go in there and remove the objects which you have referenced to the course
You will see errors when you try and do this but just save the course and you should be back where you started; after removing the references from the course that targeted deleted items. I would recommend changing your code back at that point to avoid any adverse effects.
117-120
public function setNode($node) {
$this->node = clone $node;
$this->setInstanceId($this->node->nid);
}
TO THIS
public function setNode($node) {
if(isset($node->nid)) {
$this->node = clone $node;
$this->setInstanceId($this->node->nid);
}else{
drupal_set_message('Missing course object.', 'status');
}
}
If you get the message, "Missing course object", you may have deleted a piece of course content which was being used as an object on the course without removing the object from the course itself; please review the objects in this course and delete any through object settings on outline and save outline.
I believe you can receive this message on most op requests for the course but if you goto outline you will see it there for sure and this is where you would work from to repair this issue.
Comment #10
sapiusenator commentedPLEASE also note if you had referenced a existing node when you created the object instead of supplying it through the course it appears that the object will require a substitute to delete it. Create a dummy piece of content you can reference and select it from the Content tab on "Course object settings" form. Under existing autocomplete field put your content title in there and select it then save. This should bring you back to the Course outline where you can save the course outline (you would be able to delete the object at that point also if you chose to do so).
Comment #11
djdevinThanks for your feedback.
I made changes inside of CourseObjectNode, using the built-in object warnings so that a message is displayed in the course outline editor.
I also implemented access() for object nodes to prevent access to an object without a node.
This will prevent any fatals and give the course admin a prompt to fix the course.
Comment #13
jcarkhuff commentedThank you all for the help, we're going to try applying this fix later today or early next week.
Comment #14
djdevinIf you could try it today that'd be great, it passed all the tests in d.o (and on our sites) so I could push it through.
Comment #15
prattrob commenteddjdevin,
Thanks for all the help. We tried running the patch using git and got this output:
[root@system course]# git apply -v /root/drupal.patch
/root/drupal.patch:11: trailing whitespace.
if ($node = node_load($this->getInstanceId())) {
/root/drupal.patch:12: trailing whitespace.
$this->setNode($node);
/root/drupal.patch:13: trailing whitespace.
}
/root/drupal.patch:22: trailing whitespace.
if ($this->getNode()) {
/root/drupal.patch:29: trailing whitespace.
if ($this->getNode()) {
fatal: corrupt patch at line 65
[root@system course]#
Comment #16
djdevinDrupal CI said it was okay :(
I usually do `patch -i file.patch -p1`
Unless you checked out Course via Git, the above is recommended
Comment #17
prattrob commentedI installed patch and tried your method, then received this message:
[root@system course]# patch -i /root/drupal.patch -p1
(Stripping trailing CRs from patch.)
patching file includes/CourseObjectNode.inc
patch unexpectedly ends in middle of line
Hunk #3 FAILED at 418.
1 out of 3 hunks FAILED -- saving rejects to file includes/CourseObjectNode.inc.rej
[root@system course]#
Comment #18
djdevinDid you copy/paste the patch? Looks like the whitespace got messed up.
Try getting the file directly:
cd course
wget https://www.drupal.org/files/issues/fatal_error_clone-2631940-11.patch
patch -i fatal_error_clone-2631940-11.patch -p1
Comment #19
prattrob commentedI think it worked...
[root@system course]# patch -i /root/fatal_error_clone-2631940-11.patch -p 1
patching file includes/CourseObjectNode.inc
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n] y
Hunk #1 FAILED at 10.
Hunk #2 FAILED at 68.
Hunk #3 succeeded at 418 (offset 1 line).
2 out of 3 hunks FAILED -- saving rejects to file includes/CourseObjectNode.inc. rej
[root@system course]# patch -i /root/fatal_error_clone-2631940-11.patch -p 1
patching file includes/CourseObjectNode.inc
Reversed (or previously applied) patch detected! Assume -R? [n] y
[root@system course]#
Wasn't sure which options to use since I've never patched Drupal before. I'll see if we can test it in a few.
Comment #20
prattrob commentedActually it looks like the first time I ran it, the patch managed to edit some of the lines before it failed so I reversed it when I ran it again. We had a backup of the file so we restored it and reran the patch and it looks good now. We'll do some testing in the GUI shortly.
Comment #21
djdevin@prattrob any luck?
Comment #22
prattrob commentedWe haven't gotten that error since we applied the patch as far as I know. Thanks for all your help!
Comment #23
djdevin