Undefined property: stdClass::$logoxs due to wrong order of the upgrade tasks (upgrading from 16.10.9 to 17.10.4)

Bug #1773043 reported by Yaju Mahida
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned
17.10
Fix Released
Medium
Unassigned
18.04
Fix Released
Medium
Unassigned
18.10
Fix Released
Medium
Unassigned

Bug Description

We are working on upgrading from 16.10.9 to 17.10.4 (skipping 17.04 release) and noticed that the upgrade task "Realease all collections that are still submitted but to a deleted group" throws numerous warnings about undefined property $logoxs as it tries to update affected collections records and can't find logoxs column as it is not yet added in our case!

[Tue Apr 24 15:54:57.831640 2018] [:error] [pid 2181] [client 172.28.128.1:61016] [DBG] b8 (lib/db/upgrade.php:4822) Realease all collections that are still submitted but to a deleted group, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949311 2018] [:error] [pid 2181] [client 172.28.128.1:61016] [WAR] b8 (auth/user.php:946) Undefined property: stdClass::$logoxs, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949344 2018] [:error] [pid 2181] [client 172.28.128.1:61016] Call stack (most recent first):, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949347 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * log_message("Undefined property: stdClass::$logoxs", 8, true, true, "/htdocs/auth/user.ph...", 946) at /htdocs/lib/errors.php:521, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949349 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * error(8, "Undefined property: stdClass::$logoxs", "/htdocs/auth/user.ph...", 946, array(size 12)) at /htdocs/auth/user.php:946, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949351 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * User->reset_institutions() at /htdocs/auth/user.php:119, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949353 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * User->find_by_id("10896") at /htdocs/lib/view.php:858, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949355 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * View->get_owner_object() at /htdocs/lib/view.php:2974, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949357 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * View->is_staff_or_admin_for_page() at /htdocs/lib/view.php:5566, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949359 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * View::get_extra_view_info(array(size 7), false, false) at /htdocs/lib/collection.php:616, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949361 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * Collection->views() at /htdocs/lib/collection.php:1195, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949363 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * Collection->get_viewids() at /htdocs/lib/collection.php:1141, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949365 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * Collection->release() at /htdocs/lib/db/upgrade.php:4831, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949405 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * xmldb_core_upgrade("2016090236") at /htdocs/lib/upgrade.php:347, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949453 2018] [:error] [pid 2181] [client 172.28.128.1:61016] * upgrade_core(object(stdClass)) at /htdocs/admin/upgrade.json.php:87, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.949469 2018] [:error] [pid 2181] [client 172.28.128.1:61016] , referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS
[Tue Apr 24 15:54:59.954950 2018] [:error] [pid 2181] [client 172.28.128.1:61016] [WAR] b8 (auth/user.php:946) Undefined property: stdClass::$logoxs, referer: https://localhost/admin/upgrade.php?urlsecret=WhoKnOwS

Call stack (most recent first):
log_message("Undefined property: stdClass::$logoxs", 8, true, true, "/htdocs/auth/user.ph...", 946) at /htdocs/lib/errors.php:521
error(8, "Undefined property: stdClass::$logoxs", "/htdocs/auth/user.ph...", 946, array(size 12)) at /htdocs/auth/user.php:946
User->reset_institutions() at /htdocs/auth/user.php:119
User->find_by_id("27969") at /htdocs/lib/view.php:858
View->get_owner_object() at /htdocs/lib/view.php:6193
View->get_url(false) at /htdocs/lib/view.php:5585
View::get_extra_view_info(array(size 6), false, false) at /htdocs/lib/collection.php:616
Collection->views() at /htdocs/lib/collection.php:1200
Collection->get_viewids() at /htdocs/lib/collection.php:1141
Collection->release() at /htdocs/lib/db/upgrade.php:4831
xmldb_core_upgrade("2016090236") at /htdocs/lib/upgrade.php:347
upgrade_core(object(stdClass)) at /htdocs/admin/upgrade.json.php:87

This erroring task is a fix for the "Mahara Bug 1642389 Deleting a group with collections submission does not really release them" and if not wrong was released with Mahara 17.04 series. This task calls a public function find_by_id and within it reset_institutions (/htdocs/auth/user.php line 119 – Mahara 17.10.4) which is expecting a logoxs column.

Later on, a new feature “Bug 1676214: Added institution small logo upload” was released with Mahara 17.10 series and adds a new column logoxs.

Simply, changing the order of upgrade tasks starting from 17.10 series will fix this issue. Note that anyone who is upgrading from pre-17.04 release to 17.10 and affected with bug 1642389 will experience the same issue.

As of Mahara 17.10, the order of upgrade tasks (/htdocs/lib/db/upgrade.php) should change as following

1. Add logoxs column

    if ($oldversion < 2017061200) {
        log_debug('Add new logoxs column in institution table for small logos');
        $table = new XMLDBTable('institution');
        $field = new XMLDBField('logoxs');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, 10);
            add_field($table, $field);
        }
    }

2. Release all collections

    if ($oldversion < 2016112400) {
        log_debug('Realease all collections that are still submitted but to a deleted group');
        require_once(get_config('libroot') . 'collection.php');
        if ($collections = get_records_sql_array("
            SELECT c.id
            FROM {collection} c JOIN {group} g ON c.submittedgroup=g.id
            WHERE c.submittedstatus = ".Collection::SUBMITTED." AND g.deleted = 1 "
            )) {
            foreach ($collections as $collectionid) {
                $collection = new Collection($collectionid->id);
                $collection->release();
            }
        }
    }

Revision history for this message
Yaju Mahida (yvm) wrote :
Revision history for this message
Yaju Mahida (yvm) wrote :

Tried to push this through make push (gerrit) and minaccept fails. Seems the section number is not incremented correctly. Updating it to 2017061200 will run this twice who are upgrading from 17.04 to 17.10 and don't think it can harm!

make minaccept
Running minimum acceptance test...
No syntax errors detected in htdocs/lib/db/upgrade.php
New htdocs/lib/db/upgrade.php: 2016112400
ERROR: htdocs/lib/db/upgrade.php section number 2016112400 not incremented correctly.
ERROR: Version in htdocs/lib/version.php should match version of last new section in htdocs/lib/db/upgrade.php
make: *** [minaccept] Error 1

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

Patch for "17.10_STABLE" branch: https://reviews.mahara.org/8898

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

Patch for "18.04_STABLE" branch: https://reviews.mahara.org/8899

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

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

Revision history for this message
Robert Lyon (robertl-9) wrote :

Hi Yaju Mahida,

Moving things around in the DB upgrade is not a good idea as can cause other problems - a better fix is to check for logoxs, eg isset($institutions[$themeinstitution]->logoxs) see the patch I made
https://reviews.mahara.org/#/c/8900/

Revision history for this message
Yaju Mahida (yvm) wrote :

Sounds good

Robert Lyon (robertl-9)
Changed in mahara:
importance: Undecided → Medium
Revision history for this message
Yaju Mahida (yvm) wrote :

Collections tables records are updated that is sure but not sure about all the other tables it attempts after throwing this error as didn't spend much time to investigate this. Assuming this as failed, I thought moving the upgrade task is a quick & safe bet.

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

Reviewed: https://reviews.mahara.org/8900
Committed: https://git.mahara.org/mahara/mahara/commit/7845d8b7d3e1e8318b72d2ebc99418618efbdb0b
Submitter: Cecilia Vela Gurovic (<email address hidden>)
Branch: master

commit 7845d8b7d3e1e8318b72d2ebc99418618efbdb0b
Author: Robert Lyon <email address hidden>
Date: Mon May 28 11:26:08 2018 +1200

Bug 1773043: Check for logoxs object param

This can be missing in collection object when upgrading from older
site and new db field is not created yet

behatnotneeded

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

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

Reviewed: https://reviews.mahara.org/8899
Committed: https://git.mahara.org/mahara/mahara/commit/518bb2aebcaaab2e7b9520fe4bba8ca585ab2fa4
Submitter: Cecilia Vela Gurovic (<email address hidden>)
Branch: 18.04_STABLE

commit 518bb2aebcaaab2e7b9520fe4bba8ca585ab2fa4
Author: Robert Lyon <email address hidden>
Date: Mon May 28 11:26:08 2018 +1200

Bug 1773043: Check for logoxs object param

This can be missing in collection object when upgrading from older
site and new db field is not created yet

behatnotneeded

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

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

Reviewed: https://reviews.mahara.org/8898
Committed: https://git.mahara.org/mahara/mahara/commit/f4b69cd9af4e224e94e783d1637301f472967435
Submitter: Cecilia Vela Gurovic (<email address hidden>)
Branch: 17.10_STABLE

commit f4b69cd9af4e224e94e783d1637301f472967435
Author: Robert Lyon <email address hidden>
Date: Mon May 28 11:26:08 2018 +1200

Bug 1773043: Check for logoxs object param

This can be missing in collection object when upgrading from older
site and new db field is not created yet

behatnotneeded

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

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.