mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #66719
[Bug 1979921] [NEW] Potential issue with artefact chooser and getting group artefacts
Public bug reported:
There is an issue with View::get_artefactchooser_artefacts() if we pass
it a $group identifier as a integer rather than a string or a class.
We need to fix that up so a group ID passed in as integer is also
handled other wise the error below can occur.
The was reported by a community member and the only way I could
replicate it was doing the following.
Make this change:
diff --git a/htdocs/blocktype/lib.php b/htdocs/blocktype/lib.php
index 1bb21f32af..816969a241 100644
--- a/htdocs/blocktype/lib.php
+++ b/htdocs/blocktype/lib.php
@@ -2337,7 +2337,7 @@ class BlockInstance {
list($allowed, $count) = View::get_artefactchooser_artefacts(
$searchdata,
$this->get_view()->get('owner'),
- $this->get_view()->get('group'),
+ (int)$this->get_view()->get('group'),
$this->get_view()->get('institution'),
true
);
Then create a new group and on the group homepage click 'edit'.
Add a new block of content type 'image' to the page, upload an image to 'group files' tab, select it and click save.
Then resize the image by dragging its corner to make it wider and higher.
Reload page and see the error.
But as they got the error without altering the code it would be best to
harden the View::get_artefactchooser_artefacts() so it can deal with
integer correctly.
[WAR] f1 (lib/view.php:3841) get_class() expects parameter 1 to be object, int given
Call stack (most recent first):
log_message("get_class() expects parameter 1 to be object, int ...", 8, true, true, "/var/www/html/mahara.abc.xyz/lib/v...", 3841) at /var/www/html/mahara.abc.xyz/lib/errors.php:515
error(2, "get_class() expects parameter 1 to be object, int ...", "/var/www/html/mahara.abc.xyz/lib/v...", 3841, array(size 19)) at /var/www/html/mahara.abc.xyz/lib/view.php:3841
View::get_artefactchooser_artefacts(array(size 2), null, 603, null, true) at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2336
BlockInstance->rebuild_artefact_list() at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2275
BlockInstance->commit() at /var/www/html/mahara.abc.xyz/lib/view.php:2829
View->moveblockinstance(array(size 7)) at /var/www/html/mahara.abc.xyz/lib/view.php:2107
View->process_changes() at /var/www/html/mahara.abc.xyz/view/blocks.json.php:30
[WAR] f1 (lib/errors.php:853) Failed to get a recordset: mysqli error: [0: ] in EXECUTE("SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b FROM "artefact" a LEFT JOIN "tag" t ON t.resourcetype = 'artefact' AND a.id = t.resourceid
LEFT OUTER JOIN (
SELECT
r.artefact, r.can_view, r.can_edit, m.group
FROM
"group_member" m
JOIN "artefact" aa ON aa.group = m.group
JOIN "artefact_access_role" r ON aa.id = r.artefact AND r.role = m.role
WHERE
m.group = ?
AND m.member = ?
AND r.can_view = 1
) ga ON (ga.group = a.group AND a.id = ga.artefact) WHERE (a.institution = 'mahara' OR ga.can_view = 1 OR a.owner = ?) AND a.id = 291249) AS agg")Command was: SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b FROM "artefact" a LEFT JOIN "tag" t ON t.resourcetype = 'artefact' AND a.id = t.resourceid
LEFT OUTER JOIN (
SELECT
r.artefact, r.can_view, r.can_edit, m.group
FROM
"group_member" m
JOIN "artefact" aa ON aa.group = m.group
JOIN "artefact_access_role" r ON aa.id = r.artefact AND r.role = m.role
WHERE
m.group = ?
AND m.member = ?
AND r.can_view = 1
) ga ON (ga.group = a.group AND a.id = ga.artefact) WHERE (a.institution = 'mahara' OR ga.can_view = 1 OR a.owner = ?) AND a.id = 291249) AS agg and values was (0:1135)
Call stack (most recent first):
log_message("Failed to get a recordset: mysqli error: [0: ] in ...", 8, true, true) at /var/www/html/mahara.abc.xyz/lib/errors.php:89
log_warn("Failed to get a recordset: mysqli error: [0: ] in ...") at /var/www/html/mahara.abc.xyz/lib/errors.php:853
SQLException->__construct("Failed to get a recordset: mysqli error: [0: ] in ...") at /var/www/html/mahara.abc.xyz/lib/dml.php:540
get_recordset_sql("SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b...", array(size 1), null, null) at /var/www/html/mahara.abc.xyz/lib/dml.php:720
get_records_sql_assoc("SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b...", array(size 1), null, null) at /var/www/html/mahara.abc.xyz/lib/view.php:3967
View::get_artefactchooser_artefacts(array(size 2), null, 603, null, true) at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2336
BlockInstance->rebuild_artefact_list() at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2275
BlockInstance->commit() at /var/www/html/mahara.abc.xyz/lib/view.php:2829
View->moveblockinstance(array(size 7)) at /var/www/html/mahara.abc.xyz/lib/view.php:2107
View->process_changes() at /var/www/html/mahara.abc.xyz/view/blocks.json.php:30
** Affects: mahara
Importance: Medium
Status: In Progress
** Changed in: mahara
Milestone: None => 22.10.0
** Changed in: mahara
Status: New => In Progress
** Changed in: mahara
Importance: Undecided => Medium
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: mahara-contributors
https://bugs.launchpad.net/bugs/1979921
Title:
Potential issue with artefact chooser and getting group artefacts
Status in Mahara:
In Progress
Bug description:
There is an issue with View::get_artefactchooser_artefacts() if we
pass it a $group identifier as a integer rather than a string or a
class.
We need to fix that up so a group ID passed in as integer is also
handled other wise the error below can occur.
The was reported by a community member and the only way I could
replicate it was doing the following.
Make this change:
diff --git a/htdocs/blocktype/lib.php b/htdocs/blocktype/lib.php
index 1bb21f32af..816969a241 100644
--- a/htdocs/blocktype/lib.php
+++ b/htdocs/blocktype/lib.php
@@ -2337,7 +2337,7 @@ class BlockInstance {
list($allowed, $count) = View::get_artefactchooser_artefacts(
$searchdata,
$this->get_view()->get('owner'),
- $this->get_view()->get('group'),
+ (int)$this->get_view()->get('group'),
$this->get_view()->get('institution'),
true
);
Then create a new group and on the group homepage click 'edit'.
Add a new block of content type 'image' to the page, upload an image to 'group files' tab, select it and click save.
Then resize the image by dragging its corner to make it wider and higher.
Reload page and see the error.
But as they got the error without altering the code it would be best
to harden the View::get_artefactchooser_artefacts() so it can deal
with integer correctly.
[WAR] f1 (lib/view.php:3841) get_class() expects parameter 1 to be object, int given
Call stack (most recent first):
log_message("get_class() expects parameter 1 to be object, int ...", 8, true, true, "/var/www/html/mahara.abc.xyz/lib/v...", 3841) at /var/www/html/mahara.abc.xyz/lib/errors.php:515
error(2, "get_class() expects parameter 1 to be object, int ...", "/var/www/html/mahara.abc.xyz/lib/v...", 3841, array(size 19)) at /var/www/html/mahara.abc.xyz/lib/view.php:3841
View::get_artefactchooser_artefacts(array(size 2), null, 603, null, true) at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2336
BlockInstance->rebuild_artefact_list() at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2275
BlockInstance->commit() at /var/www/html/mahara.abc.xyz/lib/view.php:2829
View->moveblockinstance(array(size 7)) at /var/www/html/mahara.abc.xyz/lib/view.php:2107
View->process_changes() at /var/www/html/mahara.abc.xyz/view/blocks.json.php:30
[WAR] f1 (lib/errors.php:853) Failed to get a recordset: mysqli error: [0: ] in EXECUTE("SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b FROM "artefact" a LEFT JOIN "tag" t ON t.resourcetype = 'artefact' AND a.id = t.resourceid
LEFT OUTER JOIN (
SELECT
r.artefact, r.can_view, r.can_edit, m.group
FROM
"group_member" m
JOIN "artefact" aa ON aa.group = m.group
JOIN "artefact_access_role" r ON aa.id = r.artefact AND r.role = m.role
WHERE
m.group = ?
AND m.member = ?
AND r.can_view = 1
) ga ON (ga.group = a.group AND a.id = ga.artefact) WHERE (a.institution = 'mahara' OR ga.can_view = 1 OR a.owner = ?) AND a.id = 291249) AS agg")Command was: SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b FROM "artefact" a LEFT JOIN "tag" t ON t.resourcetype = 'artefact' AND a.id = t.resourceid
LEFT OUTER JOIN (
SELECT
r.artefact, r.can_view, r.can_edit, m.group
FROM
"group_member" m
JOIN "artefact" aa ON aa.group = m.group
JOIN "artefact_access_role" r ON aa.id = r.artefact AND r.role = m.role
WHERE
m.group = ?
AND m.member = ?
AND r.can_view = 1
) ga ON (ga.group = a.group AND a.id = ga.artefact) WHERE (a.institution = 'mahara' OR ga.can_view = 1 OR a.owner = ?) AND a.id = 291249) AS agg and values was (0:1135)
Call stack (most recent first):
log_message("Failed to get a recordset: mysqli error: [0: ] in ...", 8, true, true) at /var/www/html/mahara.abc.xyz/lib/errors.php:89
log_warn("Failed to get a recordset: mysqli error: [0: ] in ...") at /var/www/html/mahara.abc.xyz/lib/errors.php:853
SQLException->__construct("Failed to get a recordset: mysqli error: [0: ] in ...") at /var/www/html/mahara.abc.xyz/lib/dml.php:540
get_recordset_sql("SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b...", array(size 1), null, null) at /var/www/html/mahara.abc.xyz/lib/dml.php:720
get_records_sql_assoc("SELECT DISTINCT agg.* FROM (SELECT a.id, a.id AS b...", array(size 1), null, null) at /var/www/html/mahara.abc.xyz/lib/view.php:3967
View::get_artefactchooser_artefacts(array(size 2), null, 603, null, true) at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2336
BlockInstance->rebuild_artefact_list() at /var/www/html/mahara.abc.xyz/blocktype/lib.php:2275
BlockInstance->commit() at /var/www/html/mahara.abc.xyz/lib/view.php:2829
View->moveblockinstance(array(size 7)) at /var/www/html/mahara.abc.xyz/lib/view.php:2107
View->process_changes() at /var/www/html/mahara.abc.xyz/view/blocks.json.php:30
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1979921/+subscriptions
Follow ups
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Kristina Hoeppner, 2022-11-22
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Gold, 2022-11-01
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Gold, 2022-11-01
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Doris Tam, 2022-11-01
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Doris Tam, 2022-11-01
-
[Bug 1979921] A change has been merged
From: Mahara Bot, 2022-08-16
-
[Bug 1979921] A change has been merged
From: Mahara Bot, 2022-08-16
-
[Bug 1979921] A change has been merged
From: Mahara Bot, 2022-08-16
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Robert Lyon, 2022-08-16
-
[Bug 1979921] A patch has been submitted for review
From: Mahara Bot, 2022-08-16
-
[Bug 1979921] A patch has been submitted for review
From: Mahara Bot, 2022-08-16
-
[Bug 1979921] A patch has been submitted for review
From: Mahara Bot, 2022-08-16
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Robert Lyon, 2022-08-16
-
[Bug 1979921] Re: Potential issue with artefact chooser and getting group artefacts
From: Robert Lyon, 2022-07-22
-
[Bug 1979921] A change has been merged
From: Mahara Bot, 2022-07-22
-
[Bug 1979921] A patch has been submitted for review
From: Mahara Bot, 2022-06-26