Forums | Mahara Community

Support /
Embedded Image Journal Entries Problem - Mahara 15.04.3


Ali Hastie's profile picture
Posts: 145

01 October 2015, 21:54

We have recently upgraded to Mahara 15.04.3 version and our students are having problems relating to embedded images within  journal entries. Their Text if fine.

With using Chrome and Firefox, the students create or edit a journal entry and use the Insert/edit image facility and either select a file from their Mahara Files area and/or directly upload and once they click on the Insert and submit the image does not appear within their Journal entry. Adding text only and click on the Save entry save the journal entry. 

Not sure if this is related to this bug: https://bugs.launchpad.net/mahara/+bug/1487222

With using Internet Explorer V10, their images are successfully embedded within the journal entry but when they click on the Save entry button, the button is stuck on Processing... If you wait a while and click on the Cancel button, the entry saves with the embedded image(s) and any text added to the entry. As with above, adding text only saves the journal entry without any problems.

We have a few projects that count on the journals for our students.

Cheers

Ali

 

Aaron Wells's profile picture
Posts: 896

09 October 2015, 10:56

Hi Ali,

I haven't been able to replicate the problem that you're describing. I did a clean install of 15.04.3, and was able to successfully embed a journal entry into it. You can also test it out here on mahara.org, and on demo.mahara.org, both of which are running Mahara 15.04.3.

The bug 1487222 shouldn't be related to this, because it only applies to the theme rework we were doing for Mahara 15.10.

Do you see any error messages in your site's error logs?

Cheers,

Aaron

Ali Hastie's profile picture
Posts: 145

19 October 2015, 22:05

Hi Aaron

Thanks for the reply and apologies for the delay, was off on holiday.

I contact our hosting company who provided me with an error once I made a journal post with text and embedding an image using IE 10:

PHP Fatal error:  Call to a member function StartTrans() on a non-object in /u0/webroot/virtual/mahara.sruc.ac.uk/www/lib/dml.php on line 1525, referer: http://mahara.sruc.ac.uk/artefact/blog/post.php?blog=24823

Cheers

 

Ali

 

Aaron Wells's profile picture
Posts: 896

22 October 2015, 10:26

Wow, that is a weird error. That line of code is called by db_begin(), which is the function Mahara uses when starting a database transaction:

$db->StartTrans();

The thing is, $db is a global variable which holds the current database connection. It gets initialized in the file "init.php", which is included as the first step in every Mahara page. So, that should always be an object, unless maybe you're having intermittent problems connecting to your database?

It would be more helpful if you could get the full PHP error stack, which indicates which function was calling db_begin(), and which function was calling that, etc. That should look something like this:

PHP Fatal error:  Call to undefined function foo() in /home/aaronw/www/mahara/htdocs/lib/dml.php on line 1529
PHP Stack trace:
PHP   1. {main}() /home/aaronw/www/mahara/htdocs/view/index.php:0
PHP   2. pieform() /home/aaronw/www/mahara/htdocs/view/index.php:50
PHP   3. Pieform::process() /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:71
PHP   4. Pieform->__construct() /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:164
PHP   5. call_user_func_array() /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:537
PHP   6. createview_submit() /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:537
PHP   7. View::create_from_template() /home/aaronw/www/mahara/htdocs/lib/view.php:6392
PHP   8. db_begin() /home/aaronw/www/mahara/htdocs/lib/view.php:362

Cheers,

Aaron

Yaju Mahida's profile picture
Posts: 131

05 November 2015, 17:10

Hi Aaron,

We are facing the same PHP Fatal error message for this behavior.

PHP Fatal Error - $db->StartTrans();

[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP Fatal error:  Call to a member function StartTrans() on a non-object in /opt/mahara/mahara15040/lib/dml.php on line 1525, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP Stack trace:, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   1. {main}() /var/www/html/mahara15040/artefact/blog/post.php:0, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   2. pieform() /var/www/html/mahara15040/artefact/blog/post.php:169, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   3. Pieform::process() /var/www/html/mahara15040/lib/pieforms/pieform.php:71, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   4. Pieform->__construct() /var/www/html/mahara15040/lib/pieforms/pieform.php:162, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   5. call_user_func_array() /var/www/html/mahara15040/lib/pieforms/pieform.php:532, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   6. editpost_submit() /var/www/html/mahara15040/lib/pieforms/pieform.php:532, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   7. Pieform->json_reply() /var/www/html/mahara15040/artefact/blog/post.php:278, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   8. ArtefactType->__destruct() /var/www/html/mahara15040/artefact/lib.php:0, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP   9. ArtefactType->commit() /var/www/html/mahara15040/artefact/lib.php:572, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost
[Thu Nov 05 14:01:15 2015] [error] [client x.x.x.x] PHP  10. db_begin() /var/www/html/mahara15040/artefact/lib.php:594, referer: https://localhost/mahara15040/artefact/blog/post.php?blog=localhost

 

Apart from this we are also getting another PHP Fatal error for - auth_generate_login_form(). This doesn't happen all the time but it is recorded in the log for so many times and still we are seeing this.

 

PHP Fatal error:  auth_generate_login_form(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Pieform" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition  in /var/www/html/mahara15040/auth/lib.php on line 1948, referer: https://localhost/view/blocks.php?id=75555

 

We are investigating both of these errors as we are planning the upgrade very soon.

Regards,

Yaju Mahida

Aaron Wells's profile picture
Posts: 896

06 November 2015, 18:27

Thanks for the error stack, Yaju! :)

I can see exactly what's going on... and unfortunately it may not be that easy to fix it. :-P

The problem here appears to be the ArtefactType class's "__destruct()" method. This is a method that gets called by the PHP garbage destructor when an object is being deleted at the end of its lifetime. The destructor in ArtefactType under some circumstances calls ArtefactType->commit(), which in turn uses the $db object to save unsaved changes into the database.

In this case, it's getting called because some artefact object is still around at the time the script ends (via an exit() call in Pieform->json_reply()). The error is happening, because the PHP garbage collector is no guaranteed to destroy the objects in any particular order. Apparently on your server, it is deleting the global $db variable before it deletes this artefact variable.

This kind of thing is why global variables, and destructor methods, are both considered harmful design patterns. :)

Unfortunately, this is some pretty old code in Mahara. Some of the lines involved in this process date back to 2006! I'm actually rather surprised this problem has not arisen before. Perhaps it's a change to the PHP garbage collector in recent versions, or perhaps there's some new code in Mahara that is forgetting to commit an artefact when it's done with it.

In any case, since it's such old code, it'll be tricky to be certain that it doesn't cause problems if we remove it... But we'll have to give it a shot.

I've filed a Launchpad bug here: https://bugs.launchpad.net/mahara/+bug/1513710

Cheers,

Aaron

Yaju Mahida's profile picture
Posts: 131

06 November 2015, 13:22

PHP error stack for auth_generate_login_form()

[Fri Nov 06 10:17:12 2015] [error] [client x.x.x.x] PHP Fatal error:  auth_generate_login_form() [<a href='function.auth-generate-login-form'>function.auth-generate-login-form</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;Pieform&quot; of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition  in  /var/www/html/mahara15040/auth/lib.php on line 1948
[Fri Nov 06 10:17:12 2015] [error] [client x.x.x.x] PHP Stack trace:
[Fri Nov 06 10:17:12 2015] [error] [client x.x.x.x] PHP   1. {main}()  /var/www/html/mahara15040/index.php:0
[Fri Nov 06 10:17:12 2015] [error] [client x.x.x.x] PHP   2. smarty()  /var/www/html/mahara15040/index.php:88
[Fri Nov 06 10:17:12 2015] [error] [client x.x.x.x] PHP   3. auth_generate_login_form()  /var/www/html/mahara15040/lib/web.php:703

Robert Lyon's profile picture
Posts: 756

06 November 2015, 14:28

Hi Yaju,

The error PHP error stack for auth_generate_login_form() has been reported here

https://bugs.launchpad.net/mahara/+bug/1473817

We are looking into it - it seems to due to when one's session times out in the browser from inactivity then reactivity

Cheers

Robert

8 results