Blocktype rendering error when artefact is not found

Bug #1514641 reported by Ghada El-Zoghbi on 2015-11-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Low
Robert Lyon
15.10
Low
Unassigned

Bug Description

Mahara 15.10:

version = 2015092910
release = 15.10.0

If an artefact is not found while rending a block instance, the try/catch catches the error - which is good.

But, further down the page when it sets pieformcss => $css (on line 916):

        return array('html' => $smarty->fetch('view/blocktypecontainerediting.tpl'), 'javascript' => $js, 'pieformcss' => $css);

the variable $css has not been declared - giving this error:

[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] [WAR] 63 (blocktype/lib.php:913) Undefined variable: css, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] Call stack (most recent first):, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] * log_message("Undefined variable: css", 8, true, true, "/var/www/acttqi/mahara/htdocs/blocktype/lib.php", 913) at /var/www/acttqi/mahara/htdocs/lib/errors.php:441, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] * error(8, "Undefined variable: css", "/var/www/acttqi/mahara/htdocs/blocktype/lib.php", 913, array(size 14)) at /var/www/acttqi/mahara/htdocs/blocktype/lib.php:913, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] * BlockInstance->render_editing() at /var/www/acttqi/mahara/htdocs/lib/view.php:2082, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] * View->build_column(1, 3, true, false) at /var/www/acttqi/mahara/htdocs/lib/view.php:2043, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] * View->build_columns(1, true, false) at /var/www/acttqi/mahara/htdocs/lib/view.php:2028, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] * View->build_rows(true) at /var/www/acttqi/mahara/htdocs/view/blocks.php:191, referer: http://d.acttqi.mahara/view/blocks.php?id=2149&
[Tue Nov 10 11:47:20 2015] [error] [client 192.168.124.138] , referer: http://d.acttqi.mahara/view/blocks.php?id=2149&

So, before calling the static methods (on lines 822+), we should instantiate the $css variable first.

So when it does fail, $css has already been defined.

Aaron Wells (u-aaronw) wrote :

Hi Ghada,

Do you have any instructions on how to replicate this error? I tried putting an image in an image block and then deleting the image, but it seems like that particular use case successfully unsets the block instance so this error doesn't happen.

Cheers,
Aaron

Ghada El-Zoghbi (ghada-z) wrote :

Hi Aaron,

We're upgrading a Mahara site from 1.10 to 15.10.

In 1.10, we are getting this:

Nov 10 12:25:28 TQIDEB001 mahara-site-acttqi: [Tue Nov 10 12:25:28 2015] [error] [client 203.29.131.142] [DBG] 43 (blocktype/lib.php:692) Artefact not found when rendering a block instance. There might be a bug with deleting artefacts of this type? Original error follows:, referer: https://uatmahara.tqi.act.edu.au/view/index.php
Nov 10 12:25:28 TQIDEB001 mahara-site-acttqi: [Tue Nov 10 12:25:28 2015] [error] [client 203.29.131.142] [DBG] 43 (blocktype/lib.php:693) Collection with id 1211 not found, referer: https://uatmahara.tqi.act.edu.au/view/index.php

The page was originally copied from institution pages/collection.

The institution pages and collection were then deleted.

I think that's probably when it started to happen but I'm not 100% sure.

I hope this helps.

Thanks,
Ghada

Aaron Wells (u-aaronw) wrote :

Hm, that could be it. I think when you copy a page, in some cases it continues to point to the original artefacts instead of giving you a copy. (Specifically, some of the blog blocks can do this.) If that's the case, then perhaps there's a bug in the institution page delete code that fails to clean up those links.

So, probably best to fix it on both sides. Correct the code that is failing to delete the link, and change the BlockInstance rendering methods to be more robust against missing artefacts.

By the way, is that an actual error that crashes the page and makes it impossible to edit the block? Or is it just a warning message in the logs?

Cheers,
Aaron

Ghada El-Zoghbi (ghada-z) wrote :

Hi Aaron,

It's a warning in the log files (in 1.10).

But, because we've got debugging on while upgrading (15.10), we just noticed it now.

You can still edit the page.

Ghada

Aaron Wells (u-aaronw) wrote :

Okay, since it's just a warning I'll mark this bug "Low" priority.

Cheers,
Aaron

There's a patch that might solve this: https://reviews.mahara.org/#/c/6021/

I haven't been able to replicate the issue yet and thus can't really test whether the patch works or not.

Reviewed: https://reviews.mahara.org/6021
Committed: https://git.mahara.org/mahara/mahara/commit/f600592d3ba07abd5d71d5a74ac03f7695e6aead
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit f600592d3ba07abd5d71d5a74ac03f7695e6aead
Author: Robert Lyon <email address hidden>
Date: Tue Feb 9 10:21:10 2016 +1300

Bug #1514641: Avoid undefined variable 'css' in block render

To avoid lines in error log

Behatnotneeded

Change-Id: I7024d0c1aa764d27c7d3a03dc8c01ae2e6031562
Signed-off-by: Robert Lyon <email address hidden>

Reviewed: https://reviews.mahara.org/6425
Committed: https://git.mahara.org/mahara/mahara/commit/865fa5b1a6866005532467177211e8109eac29e9
Submitter: Aaron Wells (<email address hidden>)
Branch: 16.04_STABLE

commit 865fa5b1a6866005532467177211e8109eac29e9
Author: Robert Lyon <email address hidden>
Date: Tue Feb 9 10:21:10 2016 +1300

Bug #1514641: Avoid undefined variable 'css' in block render

To avoid lines in error log

Behatnotneeded

Change-Id: I7024d0c1aa764d27c7d3a03dc8c01ae2e6031562
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit f600592d3ba07abd5d71d5a74ac03f7695e6aead)

Reviewed: https://reviews.mahara.org/6426
Committed: https://git.mahara.org/mahara/mahara/commit/fe149db7ac638776a2c436482593c6496d4d6186
Submitter: Aaron Wells (<email address hidden>)
Branch: 15.10_STABLE

commit fe149db7ac638776a2c436482593c6496d4d6186
Author: Robert Lyon <email address hidden>
Date: Tue Feb 9 10:21:10 2016 +1300

Bug #1514641: Avoid undefined variable 'css' in block render

To avoid lines in error log

Behatnotneeded

Change-Id: I7024d0c1aa764d27c7d3a03dc8c01ae2e6031562
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit f600592d3ba07abd5d71d5a74ac03f7695e6aead)
(cherry picked from commit 865fa5b1a6866005532467177211e8109eac29e9)

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  Edit
Everyone can see this information.

Other bug subscribers