Intermittent error "Call to a member function StartTrans() on a non-object" when saving a blog post in 15.04

Bug #1513716 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells
15.04
Fix Released
Medium
Aaron Wells
15.10
Fix Released
Medium
Aaron Wells

Bug Description

See https://mahara.org/interaction/forum/topic.php?id=7397
Also https://bugs.launchpad.net/mahara/+bug/1513710

The Embedded Image code ( https://reviews.mahara.org/#/c/5128/ ) adds a line to blog/post.php that does "set()" on an artefact without subsequently calling "commit()". This causes the (buggy) artefact destructor method to try to save the object to the database when the script ends, and that can cause an intermittent fatal error if $db got garbage collected before the artefact destructor was called.

Revision history for this message
Aaron Wells (u-aaronw) wrote :

This appears to be an intermittent or at least platform-specific problem. But if you were going to try to replicate it, these would be the steps:

1. Create a blog post.
2. Save the blog post.
3. Open the blog post back up for editing.
4. Make a change to the blog post.
5. Save the blog post again.

If you use xdebug or another debugging tool, you can see that on that second save attempt, at least one ArtefactTypeBlogPost object will get its destructor called while $this->dirty is true, causing a database commit to happen during the destructor call.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/5666

Aaron Wells (u-aaronw)
Changed in mahara:
status: New → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5666
Committed: https://git.mahara.org/mahara/mahara/commit/294fa9a4edc5580cdc7a1c3c0c021e2f4b562884
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 294fa9a4edc5580cdc7a1c3c0c021e2f4b562884
Author: Aaron Wells <email address hidden>
Date: Fri Nov 6 18:55:40 2015 +1300

Explicitly commit artefact to avoid buggy destructor (Bug 1513716)

Since this blog post object wasn't committed after having its
description updated, it causes the destructor to try to save
the changes to the database, and that sometimes throws a fatal
error if PHP garbage-collects the global $db variable before it
calls this constructor.

behatnotneeded: Covered by existing "edit_journal.feature"

Change-Id: I5056ecce91b823b245cb5bd29f0676a35a6afd45

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.10_STABLE" branch: https://reviews.mahara.org/6163

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/6164

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/6163
Committed: https://git.mahara.org/mahara/mahara/commit/875f1806be1e5a6931bb863b78698d67e1a96c24
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.10_STABLE

commit 875f1806be1e5a6931bb863b78698d67e1a96c24
Author: Aaron Wells <email address hidden>
Date: Fri Nov 6 18:55:40 2015 +1300

Explicitly commit artefact to avoid buggy destructor (Bug 1513716)

Since this blog post object wasn't committed after having its
description updated, it causes the destructor to try to save
the changes to the database, and that sometimes throws a fatal
error if PHP garbage-collects the global $db variable before it
calls this constructor.

behatnotneeded: Covered by existing "edit_journal.feature"

Change-Id: I5056ecce91b823b245cb5bd29f0676a35a6afd45
(cherry picked from commit 294fa9a4edc5580cdc7a1c3c0c021e2f4b562884)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/6164
Committed: https://git.mahara.org/mahara/mahara/commit/cfad522e53c796e6817f57778910edfa7daf32be
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit cfad522e53c796e6817f57778910edfa7daf32be
Author: Aaron Wells <email address hidden>
Date: Fri Nov 6 18:55:40 2015 +1300

Explicitly commit artefact to avoid buggy destructor (Bug 1513716)

Since this blog post object wasn't committed after having its
description updated, it causes the destructor to try to save
the changes to the database, and that sometimes throws a fatal
error if PHP garbage-collects the global $db variable before it
calls this constructor.

behatnotneeded: Covered by existing "edit_journal.feature"

Change-Id: I5056ecce91b823b245cb5bd29f0676a35a6afd45
(cherry picked from commit 294fa9a4edc5580cdc7a1c3c0c021e2f4b562884)

no longer affects: mahara/16.04
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.