Error when adding an image block to a site page

Bug #1924949 reported by Kristina Hoeppner
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned

Bug Description

When you create a site page and add an image block, the warning below appears when you navigate away from the page.

Robert says:

"Why does htdocs/lib/form/elements/filebrowser.php expect there to be tabs made and then ignores this for site pages?"

---
if (!empty($element['tabs'])) {
    $tabdata = pieform_element_filebrowser_configure_tabs($element, $prefix);
 ...
---

Then

---
if ($viewowner['type'] == 'institution' && $viewowner['id'] == 'mahara') {
    // No filebrowser tabs for site views
    return null;
}
---

"I believe the problem relates to those two bits of code".

How to replicate:

1. Create a site page
2. Add the 'Image' block, upload an image, and save the block configuration.
3. Go to the 'Edit access' page (for example).

Expected result: The page loads correctly.
Actual result: The error message below.

[WAR] 6d (lib/form/elements/filebrowser.php:49) Trying to access array offset on value of type null
Call stack (most recent first):

    log_message("Trying to access array offset on value of type nul...", 8, true, true, "/home/kristina/code/mahara/htdocs/lib/form/element...", 49) at /home/kristina/code/mahara/htdocs/lib/errors.php:515
    error(8, "Trying to access array offset on value of type nul...", "/home/kristina/code/mahara/htdocs/lib/form/element...", 49, array(size 11)) at /home/kristina/code/mahara/htdocs/lib/form/elements/filebrowser.php:49
    pieform_element_filebrowser(object(Pieform), array(size 17)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:1605
    Pieform->build_element_html(array(size 17)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:760
    Pieform->build() at /home/kristina/code/mahara/htdocs/blocktype/lib.php:1656
    BlockInstance->build_configure_form(true) at /home/kristina/code/mahara/htdocs/blocktype/lib.php:1232
    BlockInstance->render_editing(true, true) at /home/kristina/code/mahara/htdocs/lib/view.php:2553
    View->changeblockinstance(array(size 5)) at /home/kristina/code/mahara/htdocs/lib/view.php:1930
    View->process_changes() at /home/kristina/code/mahara/htdocs/view/blocks.json.php:30

[WAR] 4e (lib/form/elements/filebrowser.php:49) Trying to access array offset on value of type null
Call stack (most recent first):

    log_message("Trying to access array offset on value of type nul...", 8, true, true, "/home/kristina/code/mahara/htdocs/lib/form/element...", 49) at /home/kristina/code/mahara/htdocs/lib/errors.php:515
    error(8, "Trying to access array offset on value of type nul...", "/home/kristina/code/mahara/htdocs/lib/form/element...", 49, array(size 11)) at /home/kristina/code/mahara/htdocs/lib/form/elements/filebrowser.php:49
    pieform_element_filebrowser(object(Pieform), array(size 17)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:1605
    Pieform->build_element_html(array(size 17)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:760
    Pieform->build() at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:1045
    Pieform->json_reply(0array(size 8), null) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:1012
    Pieform->reply(0array(size 7)) at /home/kristina/code/mahara/htdocs/blocktype/lib.php:1187
    BlockInstance->instance_config_store(object(Pieform), array(size 5)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:572
    Pieform->__construct(array(size 15)) at /home/kristina/code/mahara/htdocs/lib/mahara.php:5497
    pieform_instance(array(size 15)) at /home/kristina/code/mahara/htdocs/blocktype/lib.php:1649
    BlockInstance->build_configure_form() at /home/kristina/code/mahara/htdocs/view/blocks.php:72

Changed in mahara:
milestone: none → 21.04.1
summary: - Error when adding image block to site page
+ Error when adding an image block to a site page
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/11698

Robert Lyon (robertl-9)
Changed in mahara:
status: Confirmed → In Progress
Changed in mahara:
milestone: 21.04.1 → 21.04.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/11698
Committed: https://git.mahara.org/mahara/mahara/commit/c7fc1b89ec897ce0bacbb19e95cac060655c274c
Submitter: Lisa Seeto (<email address hidden>)
Branch: master

commit c7fc1b89ec897ce0bacbb19e95cac060655c274c
Author: Robert Lyon <email address hidden>
Date: Wed Apr 28 09:41:00 2021 +1200

Bug 1924949: Making sure $tabdata array is not empty

Before trying to get an array value in the file selector when setting
up tabular items

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

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/11708

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

Reviewed: https://reviews.mahara.org/11708
Committed: https://git.mahara.org/mahara/mahara/commit/2d26c1404290ea821e8ca6e539a5b279ca77f14d
Submitter: Lisa Seeto (<email address hidden>)
Branch: 21.04_STABLE

commit 2d26c1404290ea821e8ca6e539a5b279ca77f14d
Author: Robert Lyon <email address hidden>
Date: Wed Apr 28 09:41:00 2021 +1200

Bug 1924949: Making sure $tabdata array is not empty

Before trying to get an array value in the file selector when setting
up tabular items

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

Lisa Seeto (lisaseeto)
Changed in mahara:
status: In Progress → Fix Committed
Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
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/11744

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.