Commit 7471724c authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Check if rss feed is not empty and an array first (Bug #1191605)"

parents d1a1413a dccd7655
...@@ -75,13 +75,13 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype { ...@@ -75,13 +75,13 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
} }
// only keep the number of entries the user asked for // only keep the number of entries the user asked for
if (count($data->content)) { if (count($data->content) && !empty($data->content) && is_array($data->content)) {
$chunks = array_chunk($data->content, isset($configdata['count']) ? $configdata['count'] : 10); $chunks = array_chunk($data->content, isset($configdata['count']) ? $configdata['count'] : 10);
$data->content = $chunks[0]; $data->content = $chunks[0];
}
foreach ($data->content as $k => $c) { foreach ($data->content as $k => $c) {
$data->content[$k]->link = sanitize_url($c->link); $data->content[$k]->link = sanitize_url($c->link);
}
} }
// Attempt to fix relative URLs in the feeds // Attempt to fix relative URLs in the feeds
...@@ -91,12 +91,14 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype { ...@@ -91,12 +91,14 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
'src="' . $data->image['link'] . '$1"', 'src="' . $data->image['link'] . '$1"',
$data->description $data->description
); );
foreach ($data->content as &$entry) { if (!empty($data->content) && is_array($data->content)) {
$entry->description = preg_replace( foreach ($data->content as &$entry) {
'/src="(\/[^"]+)"/', $entry->description = preg_replace(
'src="' . $data->image['link'] . '$1"', '/src="(\/[^"]+)"/',
$entry->description 'src="' . $data->image['link'] . '$1"',
); $entry->description
);
}
} }
} }
......
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