Task "export_process_queue" fails on cron run

Bug #1912705 reported by Zander Potgieter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Gold
20.04
Fix Released
High
Unassigned
20.10
Fix Released
High
Gold
21.04
Fix Released
High
Gold
21.10
Fix Released
High
Unassigned

Bug Description

When submissions are set to be archived before being released back to the submitter, they are queued for export and an archived version is created. This processed failed for us and we were given a hint in the cron logs/output that the error was thrown at `htdocs/artefact/comment/blocktype/comment/lib.php:111`.

Adding a `debug_print_backtrace()` to the file reveals more in the cron output:
```
[INF] 35 (lib/cron.php:190) Running core cron export_process_queue
#0 PluginBlocktypeComment::render_instance_export(BlockInstance Object ([BlockInstanceid] => 320133,[BlockInstanceblocktype] => comment,[BlockInst............[truncated]
    , html) called at [<siteroot>/mahara/htdocs/lib/mahara.php:1818]
#1 call_static_method(PluginBlocktypeComment, render_instance_export, BlockInstance Object ([BlockInstanceid] => 320133,[BlockInstanceblocktype] => comment,[BlockInst............[truncated]
    , html) called at [<siteroot>/mahara/htdocs/blocktype/lib.php:1351]
#2 BlockInstance->render_viewing(html, ) called at [<siteroot>/mahara/htdocs/lib/view.php:2290]
#3 View->build_column(3, 1, , html, ) called at [<siteroot>/mahara/htdocs/lib/view.php:2241]
#4 View->build_columns(3, , html, ) called at [<siteroot>/mahara/htdocs/lib/view.php:2182]
#5 View->build_rows(, html) called at [<siteroot>/mahara/htdocs/export/html/lib.php:479]
#6 PluginExportHtml->dump_view_export_data() called at [<siteroot>/mahara/htdocs/export/html/lib.php:242]
#7 PluginExportHtml->export() called at [<siteroot>/mahara/htdocs/export/lib.php:1015]
#8 PluginExportAll->export() called at [<siteroot>/mahara/htdocs/export/lib.php:704]
#9 export_process_queue() called at [<siteroot>/mahara/htdocs/lib/cron.php:198]
[WAR] 35 (lib/errors.php:536) [Error]: Call to a member function get() on null at <siteroot>/mahara/htdocs/artefact/comment/blocktype/comment/lib.php:112
Call stack (most recent first):
  * exception(object(Error)) at Unknown:0
A nonrecoverable error occurred. This probably means you have encountered a bug in the system
```

We were able to fix it by explicitly declaring `global $exporter;` in `htdocs/export/lib.php:602` at the very start of the `export_process_queue` function - please refer to attached patch.

It also affects portfolio exports when the "Export to queue" settings is enabled in Configure site > Site options > Account settings.

------------------------------
Application/System version(s):
Mahara
$config->version = 2020013013;
$config->series = '20.04';
$config->release = '20.04.2';

OS
Ubuntu 18.04.5 LTS

DB
MySQL 5.7
------------------------------

Revision history for this message
Zander Potgieter (zpotgieter) wrote :
description: updated
description: updated
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Hi Zander,

Thank you for reporting this and also providing a possible solution. We will add it to our code review system so the team can take a look. Can you please provide your email address so we can attribute it correctly? You can send it to <email address hidden>

Thank you
Kristina

Changed in mahara:
status: New → Confirmed
importance: Undecided → High
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/11596

Revision history for this message
Gold (gold.catalyst) wrote :

Hello Zander,

Your patch has been applied and pushed to the review system at the link at #3.

Conversation around code review and testing will occur there.

Thanks for reporting this and especially for the patch.

Regards,
Gold

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

Here are some test instructions

Fresh install
Login as admin
Create group - Group X
- set allow submissions = yes
- set archive submissions = yes

Create 2 users A and B
Add them to group X as members

Login in as A
Make page
Add comment block to page
Share page with B

Login as B
Comment on page

Login in as A
Submit page to group X

Login as Admin
Release the page

Run cron via the command line
sudo -u www-data php htdocs/lib/cron.php

See
[Error]: Call to a member function get() on null at /home/robertl/code/mahara/htdocs/artefact/comment/blocktype/comment/lib.php:111

In Admin -> People -> Export queue re-queue the failed item

In database remove the lock

delete from config where field like '\_%';
update cron set nextrun = null where callfunction = 'export_process_queue';

Checkout patch

Run cron via the command line
sudo -u www-data php htdocs/lib/cron.php

Cron completes

Check that it has gone from the queue and is now in Admin -> Groups -> Archived submissions

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

Reviewed: https://reviews.mahara.org/11596
Committed: https://git.mahara.org/mahara/mahara/commit/134893377f65c5ef6abdfcfe57faa2c897541792
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 134893377f65c5ef6abdfcfe57faa2c897541792
Author: Zander Potgieter <email address hidden>
Date: Fri Mar 5 10:06:07 2021 +1300

Bug 1912705 - export_process_queue() fails on cron run.

Patch supplied by Zander Potgieter.

Change-Id: I7c4ed364d6e2d07ab0d3ef4c3f4b4852b4a07504

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

Patch for "21.04_STABLE" branch: https://reviews.mahara.org/11773

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

Patch for "20.10_STABLE" branch: https://reviews.mahara.org/11774

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

Patch for "20.04_STABLE" branch: https://reviews.mahara.org/11775

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

Reviewed: https://reviews.mahara.org/11774
Committed: https://git.mahara.org/mahara/mahara/commit/ab75ba958d78ac5a5408454d421c50bd415a2865
Submitter: Robert Lyon (<email address hidden>)
Branch: 20.10_STABLE

commit ab75ba958d78ac5a5408454d421c50bd415a2865
Author: Zander Potgieter <email address hidden>
Date: Fri Mar 5 10:06:07 2021 +1300

Bug 1912705 - export_process_queue() fails on cron run.

Patch supplied by Zander Potgieter.

Change-Id: I7c4ed364d6e2d07ab0d3ef4c3f4b4852b4a07504
(cherry picked from commit 134893377f65c5ef6abdfcfe57faa2c897541792)

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

Reviewed: https://reviews.mahara.org/11775
Committed: https://git.mahara.org/mahara/mahara/commit/9547360d9e78ea85eecb9a30254071e1288efa64
Submitter: Robert Lyon (<email address hidden>)
Branch: 20.04_STABLE

commit 9547360d9e78ea85eecb9a30254071e1288efa64
Author: Zander Potgieter <email address hidden>
Date: Fri Mar 5 10:06:07 2021 +1300

Bug 1912705 - export_process_queue() fails on cron run.

Patch supplied by Zander Potgieter.

Change-Id: I7c4ed364d6e2d07ab0d3ef4c3f4b4852b4a07504
(cherry picked from commit 134893377f65c5ef6abdfcfe57faa2c897541792)

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

Reviewed: https://reviews.mahara.org/11773
Committed: https://git.mahara.org/mahara/mahara/commit/e89e1c745b3bc023287a3e9eb7227c07ffd08744
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.04_STABLE

commit e89e1c745b3bc023287a3e9eb7227c07ffd08744
Author: Zander Potgieter <email address hidden>
Date: Fri Mar 5 10:06:07 2021 +1300

Bug 1912705 - export_process_queue() fails on cron run.

Patch supplied by Zander Potgieter.

Change-Id: I7c4ed364d6e2d07ab0d3ef4c3f4b4852b4a07504
(cherry picked from commit 134893377f65c5ef6abdfcfe57faa2c897541792)

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.