Embedly export format incorrect (stdClass vs array)

Bug #1960399 reported by Mark Sharp
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Dianne Tennent
20.10
Fix Released
Medium
Unassigned
21.04
Fix Released
Medium
Unassigned
21.10
Fix Released
Medium
Unassigned
22.04
Fix Released
Medium
Dianne Tennent

Bug Description

When you export a page that has external embedly content (example below), and then import it, the block's $configdata['embed'] element is saved as a stdClass instead of an array.
This then throws an exception when being displayed/processed e.g. /blocktype/externalvideo/lib.php:202

1. The data is not being exported correctly (I'm new to Mahara, so don't know where that happens)
2. The data isn't being correctly handled in line 202.

As a work-around we could cast the embed element as an array
202: $configdata['embed'] = (array)$configdata['embed'];

To reproduce:
1. Create a page
2. Add "External media" content type
3. Paste in the following: <a class="embedly-card" href="https://issuu.com/penndesign/docs/pm9_layout_pro02_singlelow/20"></a>
4. Save
5. Check the database that this has been saved as an array. SELECT * FROM block_instance WHERE configdata LIKE '%embedly%'; If you know the id you can search for that. The result should be something like:
146 | externalvideo | Penn design embedly-card | a:8:{s:7:"videoid";s:98:"<a class="embedly-card" href="http://issuu.com/penndesign/docs/pm9_layout_pro02_singlelow/20"></a>";s:5:"width";s:1:"0";s:6:"height";s:1:"0";s:4:"tags";N;s:11:"retractable";i:0;s:15:"retractedonload";i:0;s:4:"html";s:98:"<a class="embedly-card" href="http://issuu.com/penndesign/docs/pm9_layout_pro02_singlelow/20"></a>";s:5:"embed";a:4:{s:7:"service";s:7:"embedly";s:4:"type";s:4:"link";s:3:"url";s:62:"http://issuu.com/penndesign/docs/pm9_layout_pro02_singlelow/20";s:5:"title";s:0:"";}}
  | 40 | 0 | 0 | 0

where "embed";a:4

6. Now export this page (Manage -> Export -> Just some of my pages) and select the page you just created.
7. Now import the exported page
8. View imported page. You will get the following error.
[WAR] ad (lib/errors.php:530) [Error]: Cannot use object of type stdClass as array at /mahara/htdocs/blocktype/externalvideo/lib.php:202

Mahara: 21.10
Using Mahara docker in local dev with default set up for 21.10

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

Patch for "main" branch: https://reviews.mahara.org/12440

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

Reviewed: https://reviews.mahara.org/12440
Committed: https://git.mahara.org/mahara/mahara/commit/4af232d954649562bb2ecd4c50ca3101bbdc04a3
Submitter: Robert Lyon (<email address hidden>)
Branch: main

commit 4af232d954649562bb2ecd4c50ca3101bbdc04a3
Author: Dianne Tennent <email address hidden>
Date: Fri Feb 18 16:23:58 2022 +1300

Bug 1960399: Embedly export format incorrect

(stdClass vs array)

Handle stdClass object type when rendering imported embed data

Change-Id: Iacddea1d1905692d2f8252dfef5c9e4b4422616b

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

Patch for "21.10_DEV" branch: https://reviews.mahara.org/12493

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

Patch for "21.04_DEV" branch: https://reviews.mahara.org/12494

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

Patch for "20.10_DEV" branch: https://reviews.mahara.org/12495

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

Reviewed: https://reviews.mahara.org/12493
Committed: https://git.mahara.org/mahara/mahara/commit/7ac0c7f5e4d2c33a4f97a809b15d9dbd9a8dfa7d
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.10_DEV

commit 7ac0c7f5e4d2c33a4f97a809b15d9dbd9a8dfa7d
Author: Dianne Tennent <email address hidden>
Date: Fri Feb 18 16:23:58 2022 +1300

Bug 1960399: Embedly export format incorrect

(stdClass vs array)

Handle stdClass object type when rendering imported embed data

Change-Id: Iacddea1d1905692d2f8252dfef5c9e4b4422616b
(cherry picked from commit 4af232d954649562bb2ecd4c50ca3101bbdc04a3)

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

Reviewed: https://reviews.mahara.org/12494
Committed: https://git.mahara.org/mahara/mahara/commit/43144964538388518f6b25d0e0057b1d26125462
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.04_DEV

commit 43144964538388518f6b25d0e0057b1d26125462
Author: Dianne Tennent <email address hidden>
Date: Fri Feb 18 16:23:58 2022 +1300

Bug 1960399: Embedly export format incorrect

(stdClass vs array)

Handle stdClass object type when rendering imported embed data

Change-Id: Iacddea1d1905692d2f8252dfef5c9e4b4422616b
(cherry picked from commit 4af232d954649562bb2ecd4c50ca3101bbdc04a3)

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

Reviewed: https://reviews.mahara.org/12495
Committed: https://git.mahara.org/mahara/mahara/commit/f6b79cba2d7a67b036f120fdc8b10e6763e7f887
Submitter: Robert Lyon (<email address hidden>)
Branch: 20.10_DEV

commit f6b79cba2d7a67b036f120fdc8b10e6763e7f887
Author: Dianne Tennent <email address hidden>
Date: Fri Feb 18 16:23:58 2022 +1300

Bug 1960399: Embedly export format incorrect

(stdClass vs array)

Handle stdClass object type when rendering imported embed data

Change-Id: Iacddea1d1905692d2f8252dfef5c9e4b4422616b
(cherry picked from commit 4af232d954649562bb2ecd4c50ca3101bbdc04a3)

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.