Missing files crashing 19.10.4 upgrade when updating skins

Bug #1890258 reported by Ghada El-Zoghbi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
New
Undecided
Unassigned

Bug Description

Mahara: 19.10.4
OS: Linux 18.04
DB: Postgres
Browser: N/A (this is CLI)

This is a follow-on to Bug #1877001

When upgrading a Mahara (from 19.10.3 to 19.10.4), if artefact files are missing for some reason, the upgrade crashes.

Also, there was a missing artefact in the DB which also crashed the upgrade when calling:

$fileobj = artefact_instance_from_id($fileid);

In Dev and Staging, we work with the DB sometimes restored from Prod. But, we don't always copy the site data as it can be quite large. Mahara has generally gracefully handled missing files.

As for the missing artefact, I have not dug into why it is missing.

Unfortunately, this time, the upgrade seems to not handle missing files for skins.

Here is a small subset of the errors that are thrown (there were thousands and eventually ran out of memory).

[WAR] b4 (lib/skin.php:915) imagesx() expects parameter 1 to be resource, boolean given
Call stack (most recent first):
• log_message("imagesx() expects parameter 1 to be resource, bool...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagesx() expects parameter 1 to be resource, bool...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagesx(false) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

[WAR] b4 (lib/skin.php:915) imagesy() expects parameter 1 to be resource, boolean given
Call stack (most recent first):
• log_message("imagesy() expects parameter 1 to be resource, bool...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagesy() expects parameter 1 to be resource, bool...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagesy(false) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

[WAR] b4 (lib/skin.php:915) imagesx() expects parameter 1 to be resource, boolean given
Call stack (most recent first):
• log_message("imagesx() expects parameter 1 to be resource, bool...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagesx() expects parameter 1 to be resource, bool...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagesx(false) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

[WAR] b4 (lib/skin.php:915) imagesy() expects parameter 1 to be resource, boolean given
Call stack (most recent first):
• log_message("imagesy() expects parameter 1 to be resource, bool...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagesy() expects parameter 1 to be resource, bool...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagesy(false) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

[WAR] b4 (lib/skin.php:915) imagesx() expects parameter 1 to be resource, boolean given
Call stack (most recent first):
• log_message("imagesx() expects parameter 1 to be resource, bool...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagesx() expects parameter 1 to be resource, bool...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagesx(false) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

[WAR] b4 (lib/skin.php:915) imagesy() expects parameter 1 to be resource, boolean given
Call stack (most recent first):
• log_message("imagesy() expects parameter 1 to be resource, bool...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagesy() expects parameter 1 to be resource, bool...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagesy(false) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

[WAR] b4 (lib/skin.php:915) imagecopyresampled() expects parameter 2 to be resource, boolean given
Call stack (most recent first):
• log_message("imagecopyresampled() expects parameter 2 to be res...", 8, true, true, "/var/www/site/lib/skin.php", 915) at /var/www/site/lib/errors.php:521
• error(2, "imagecopyresampled() expects parameter 2 to be res...", "/var/www/site/lib/skin.php", 915, array(size 11)) at Unknown:0
• imagecopyresampled(resource(#3027), false, 120, 67.5, 0, 0, null, null, null, null) at /var/www/site/lib/skin.php:915
• Skin::imagebackgroundfill(resource(#3027), false, 0.125, 4, 5) at /var/www/site/lib/skin.php:975
• Skin::generate_thumbnail("1698") at /var/www/site/lib/skin.php:261
• Skin->commit() at /var/www/site/lib/db/upgrade.php:1579
• xmldb_core_upgrade("2019093015") at /var/www/site/lib/upgrade.php:376
• upgrade_core(object(stdClass)) at /var/www/site/lib/mahara.php:274
• upgrade_mahara(array(size 1)) at /var/www/site/admin/cli/upgrade.php:74

description: updated
description: updated
Revision history for this message
Ghada El-Zoghbi (ghada-z) wrote :

More on this. It turns out the skin is owned by user that was deleted.

Revision history for this message
Ghada El-Zoghbi (ghada-z) wrote :

Steps to reproduce:

1. Create a new vanilla Mahara version 19.04.6
2. Login as Admin and create User1
3. Login as User1
4. Create a skin with a background image.
5. Create a page that uses the skin
6. Login as admin
7. Delete User1
8. Upgrade to 19.10.4

Upgrade fails with:

[DBG] e3 (lib/db/upgrade.php:1565) Fixing skins for new format options
The page you are looking for could not be found.

Artefact with id 10 not found

Revision history for this message
Cecilia Vela Gurovic (ceciliavg) wrote :

Hi Ghada, this patch should help with that https://reviews.mahara.org/#/c/11112/

let me know if it does, we have another bug report for it

Revision history for this message
Ghada El-Zoghbi (ghada-z) wrote :

The steps in #2 above is for the missing artefact (i.e. the background image with artefact id 10).

So, when a user is deleted, the skins they created are not getting deleted (if private or not shared) or cleaned up to cater for deleted artefacts linked to them (if public).

Revision history for this message
Ghada El-Zoghbi (ghada-z) wrote :

Thanks Cecilia. It unfortunately didn't fix the issue when a file is missing from disk (or storage area).

The issue are missing files. They are referenced in the skin definition. When the thumbnail is getting generated, it fails because it's not in the file system.

We are also using the objectfs plugin with S3. I had to ensure the file exists when making the thumbnail.

It finally succeeded.

I've attached the patch I implemented but I'm not sure you want it in core Mahara.

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.