Commit 129e2627 authored by Melissa Draper's avatar Melissa Draper
Browse files

Additional processing fixes for rss to avoid fatal errors (Bug #1081431)



Checking for the datatypes returned, and catching exception caused
by a previous exception object getting passed to the database,
which adodb doesn't know what to do with, surprisingly enough.
Making use of try to better handle failing record updates.

Change-Id: I884021aca8d3cb416acab575151ed97d7d64d3ed
Signed-off-by: default avatarMelissa Draper <melissa@catalyst.net.nz>
parent 724bb7f9
......@@ -64,8 +64,15 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
$data = $instance->get_data('feed', $configdata['feedid']);
$data->content = unserialize($data->content);
$data->image = unserialize($data->image);
if (isset($data) && is_string($data->content)) {
$data->content = unserialize($data->content);
}
if (isset($data) && (is_string($data->image) || is_array($data->image))) {
$data->image = @unserialize($data->image);
}
else {
$data->image = null;
}
// only keep the number of entries the user asked for
if (count($data->content)) {
......@@ -285,17 +292,30 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
}
try {
$data = self::parse_feed($feed->url, $feed->insecuresslmode, $feed->authuser, $feed->authpassword);
$data->id = $feed->id;
$data->lastupdate = db_format_timestamp(time());
$data->content = serialize($data->content);
$data->image = serialize($data->image);
update_record('blocktype_externalfeed_data', $data);
}
catch (XML_Feed_Parser_Exception $e) {
// The feed must have changed in such a way as to become
// invalid since it was added. We ignore this case in the hope
// the feed will become valid some time later
}
if (isset($data) && $data instanceof XML_Feed_Parser_Exception) {
continue;
}
else if (isset($data)) {
if (!isset($data->image)) {
$data->image = null;
}
try {
$data->content = $data->content ? serialize($data->content) : '' ;
$data->image = $data->image ? serialize($data->image) : '';
$data->id = $feed->id;
$data->lastupdate = db_format_timestamp(time());
update_record('blocktype_externalfeed_data', $data);
}
catch (XML_Feed_Parser_Exception $e) {
// We tried to add the newly parsed data
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment