Error message when combining Phoca Open Graph with DPCalendar
Posted: 09 Jun 2019, 18:49
I see the following error from Phoca Open Graph plugin when viewing DPCalendar events:
Some debugging has shown that the problem is that the event item passed to onContentAfterDisplay has an $item->images of type object.
As I understand the interface, plugins are supposed to check if the passed item is an article and only if so treat it as string.
For the moment I have hacked in the following patch:
Would it be possible to apply this fix in the next version of the Open Graph plugin?
Josh
Code: Select all
[06-Jun-2019 17:47:47 UTC] PHP Warning: json_decode() expects parameter 1 to be string, object given in /home/nydi/public_html/plugins/content/phocaopengraph/phocaopengraph.php on line 97As I understand the interface, plugins are supposed to check if the passed item is an article and only if so treat it as string.
For the moment I have hacked in the following patch:
Code: Select all
--- plugins/content/phocaopengraph/phocaopengraph.php.orig 2019-06-06 13:54:44.873000000 -0400
+++ plugins/content/phocaopengraph/phocaopengraph.php 2019-06-08 11:49:13.195000000 -0400
@@ -94,7 +94,8 @@
plgContentPhocaOpenGraphHelper::renderTag('og:type', $this->params->get('type'.$suffix, 'article'), $type);
// Image
- $pictures = json_decode($row->images);
+ // JMD: Need to check if this is a string before decoding json!
+ $pictures = (is_string($row->images) ? json_decode($row->images) : $row->images);
if ($this->params->get('image'.$suffix, '') != '') {
plgContentPhocaOpenGraphHelper::renderTag('og:image', JURI::base(false).$this->params->get('image'.$suffix, ''), $type); Josh