RSS block: "Invalid array key 'url'" messages when using an atom feed

Bug #1409545 reported by Aaron Wells on 2015-01-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Low
Unassigned
1.10
Low
Unassigned
1.8
Low
Unassigned
1.9
Low
Unassigned
15.04
Low
Unassigned

Bug Description

A client reported that when using the external feed block to display the Atom feeds of Mahara's own blogs, you'd see this warning message:

[WAR] f9 (blocktype/externalfeed/lib.php:464) Illegal string offset 'url'
Call stack (most recent first):

    log_message("Illegal string offset 'url'", 8, true, true, "/home/aaronw/www/mahara/htdocs/blocktype/externalf...", 464) at /home/aaronw/www/mahara/htdocs/lib/errors.php:439
    error(2, "Illegal string offset 'url'", "/home/aaronw/www/mahara/htdocs/blocktype/externalf...", 464, array(size 2)) at /home/aaronw/www/mahara/htdocs/blocktype/externalfeed/lib.php:464
    PluginBlocktypeExternalfeed::make_feed_image_tag("http://trinity-mahara.testing.elearning.catalyst.n...") at /home/aaronw/www/mahara/htdocs/blocktype/externalfeed/lib.php:98
    PluginBlocktypeExternalfeed::render_instance(object(BlockInstance)) at Unknown:0
    call_user_func_array(array(size 2), array(size 1)) at /home/aaronw/www/mahara/htdocs/lib/mahara.php:1578
    call_static_method("PluginBlocktypeExternalfeed", "render_instance", object(BlockInstance)) at /home/aaronw/www/mahara/htdocs/blocktype/lib.php:782
    BlockInstance->render_viewing() at /home/aaronw/www/mahara/htdocs/lib/view.php:2049
    View->build_column(1, 1, false) at /home/aaronw/www/mahara/htdocs/lib/view.php:2006
    View->build_columns(1, false) at /home/aaronw/www/mahara/htdocs/lib/view.php:1991
    View->build_rows() at /home/aaronw/www/mahara/htdocs/view/view.php:257

On looking at the code, it looks like the problem is that the PluginBlocktypeExternalfeed::make_feed_image_tag() function is in dire need of a cleanup. It is built to handle an array if the feed is an RSS feed, and a URL string if the feed is an Atom feed. But it just checks for array keys directly, rather than checking whether it's an array or if the array key exists, and although that works, it throws a warning message.

Aaron Wells (u-aaronw) wrote :

The function also is written in a confusing order, and sometimes it cleans up URLs and sometimes it doesn't. The whole thing could use some cleanup and maybe refactoring.

Aaron Wells (u-aaronw) wrote :

I uploaded into gerrit the quick fix patch I wrote for our client, but I gave it a -2 to indicate the further issues we should also tackle. https://reviews.mahara.org/#/c/4137/

The code that causes this problem is quite old (probably from Mahara 1.6), so it probably affects 1.8 and 1.9 as well, but since it only throws a warning message and doesn't cause any other problems, it's probably not worth backporting further than 1.10.

Changed in mahara:
status: Confirmed → In Progress
tags: added: bite-sized

Reviewed: https://reviews.mahara.org/4137
Committed: http://gitorious.org/mahara/mahara/commit/64356c94e25d28ca234ff162e46d39d9ffd55c08
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 64356c94e25d28ca234ff162e46d39d9ffd55c08
Author: Aaron Wells <email address hidden>
Date: Mon Jan 12 11:16:06 2015 +1300

Fix "Invalid array key 'url'" warnings

Bug 1409545: Also cleaning up this old & messy function

Change-Id: I9c338aa35208148811bdfe77aee4938f23d8313f

Reviewed: https://reviews.mahara.org/4288
Committed: http://gitorious.org/mahara/mahara/commit/dd3a64579d871b09456ab935cdea035961e80671
Submitter: Aaron Wells (<email address hidden>)
Branch: 1.10_STABLE

commit dd3a64579d871b09456ab935cdea035961e80671
Author: Aaron Wells <email address hidden>
Date: Mon Jan 12 11:16:06 2015 +1300

Fix "Invalid array key 'url'" warnings

Bug 1409545: Also cleaning up this old & messy function

Change-Id: I9c338aa35208148811bdfe77aee4938f23d8313f

Robert Lyon (robertl-9) on 2015-04-17
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers