Description:
I'm using Views Atom Module together with views to render the Atom Feed.
After the configuration of the view i got the following error:
Unsupported operand types in sites/all/modules/views/plugins/views_plugin_row_rss_fields.inc on line 120
if (function_exists('rdf_get_namespaces')) {
// Merge RDF namespaces in the XML namespaces in case they are used
// further in the RSS content.
$xml_rdf_namespaces = array();
foreach (rdf_get_namespaces() as $prefix => $uri) {
$xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
}
$this->view->style_plugin->namespaces += $xml_rdf_namespaces;
}
This error occurs because $this->view->style_plugin->namespaces is not set at that point when it runs through.
Solution:
Here is my suggestion:
if (function_exists('rdf_get_namespaces')) {
// Merge RDF namespaces in the XML namespaces in case they are used
// further in the RSS content.
$xml_rdf_namespaces = array();
foreach (rdf_get_namespaces() as $prefix => $uri) {
$xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
}
//check if namespace array is available
if (isset($this->view->style_plugin->namespaces) && is_array($this->view->style_plugin->namespaces)) {
$this->view->style_plugin->namespaces += $xml_rdf_namespaces;
}
else {
$this->view->style_plugin->namespaces = $xml_rdf_namespaces;
}
Does anyone have a better solution?
Comments
Comment #1
mahalo13 commentedComment #3
mahalo13 commentedapplied new patch
Comment #4
mahalo13 commentedComment #6
jmdeleon commentedI ran into the same error when using the Views Atom module.
The comment in the file views_plugin_row_rss_fields.inc suggests to merge the RDF and XML namespaces, yet the += operator (which is not type safe, hence the error) is used. My patch performs an array_merge rather than an += operator.
Patch submitted was tested on Views 7.x-3.13 release.
Comment #7
jmdeleon commentedComment #8
jmdeleon commentedComment #9
jmdeleon commentedComment #10
jmdeleon commentedAdditional change to my patch in #7 to handle cases where the namespaces property is not set.
Comment #11
jmdeleon commentedFixed typo in patch in #10.
Comment #12
jmdeleon commentedThis issue can be resolved by initializing the namespace array in the Views display plugin for Views Atom itself. A patch to do this is available here: #2766325: RSS Namespaces - Unsupported Operand Types when using fields
Marked as Closed (won't fix), as the fix won't be applied to Views.