Notice: Array to string conversion

More
12 years 8 months ago - 12 years 8 months ago #24365 by gruz
Notice: Array to string conversion in /site/modules/mod_flexicontent/helper.php on line 765
(line number may differ a little due to my experiments in the helper.php file)

The line is:
Code:
$types = is_array($types) ? implode(',', $types) : $types;

The problem is that $types is not an array of strings, but an array of arrays.

I replace it with
Code:
if (is_array($types)) { if (is_array($types[0])) { $types = implode(',', $types[0]); } else { $types = implode(',', $types); } }
to make it work. I'm not sure if it's a correct way, I don't understand the code deep enough, but it works.

[img


I cannot reproduce steps to get the error, too tired. My suggestion is to add a check to correctly transform the $types variable to string.


P.S.
In the current SVN the problem generates an SQL error:
[img


The fix above helps to remove it.

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)
Last edit: 12 years 8 months ago by gruz.

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #24563 by gruz
Please fix this bug!
[img

Code:
Notice: Array to string conversion in /var/www/oscar/data/www/test.oscargo.ru/modules/mod_flexicontent/helper.php on line 740
Code:
SELECT i.*, ie.type_id, ie.language, ty.name AS typename, value AS image, CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(':', i.id, i.alias) ELSE i.id END as slug, CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as categoryslug, GROUP_CONCAT(rel.catid SEPARATOR ",") as itemcats FROM #__content AS i LEFT JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id LEFT JOIN #__flexicontent_types AS ty on ie.type_id = ty.id LEFT JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id LEFT JOIN #__categories AS c ON c.id = rel.catid LEFT JOIN #__flexicontent_fields_item_relations AS firel ON ( i.id = firel.item_id AND firel.valueorder = 1 AND firel.field_id = 24 ) WHERE c.published = 1 AND i.state IN ( 1, -5 ) AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= '2012-04-23 21:23' ) AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= '2012-04-23 21:23' ) AND i.access <= 1 AND c.id IN (78) AND ie.type_id IN (Array) GROUP BY i.id Unknown column 'Array' in 'where clause' SQL=SELECT i.*, ie.type_id, ie.language, ty.name AS typename, value AS image, CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(':', i.id, i.alias) ELSE i.id END as slug, CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as categoryslug, GROUP_CONCAT(rel.catid SEPARATOR ",") as itemcats FROM vcjgz_content AS i LEFT JOIN vcjgz_flexicontent_items_ext AS ie on ie.item_id = i.id LEFT JOIN vcjgz_flexicontent_types AS ty on ie.type_id = ty.id LEFT JOIN vcjgz_flexicontent_cats_item_relations AS rel ON rel.itemid = i.id LEFT JOIN vcjgz_categories AS c ON c.id = rel.catid LEFT JOIN vcjgz_flexicontent_fields_item_relations AS firel ON ( i.id = firel.item_id AND firel.valueorder = 1 AND firel.field_id = 24 ) WHERE c.published = 1 AND i.state IN ( 1, -5 ) AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= '2012-04-23 21:23' ) AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= '2012-04-23 21:23' ) AND i.access <= 1 AND c.id IN (78) AND ie.type_id IN (Array) GROUP BY i.id LIMIT 0, 6

Fix the
/modules/mod_flexicontent/helper.php
That line
Code:
$types = is_array($types) ? implode(',', $types) : $types;

replace with:
Code:
if (is_array($types)) { if (is_array($types[0])) { $types = implode(',', $types[0]); } else { $types = implode(',', $types); } }

And please, also apply this code to the same file:
www.flexicontent.org/forum/index ... =viewtopic

Line about 547
Code:
$relitems_fields = (!is_array($relitems_fields)) ? array($relitems_fields) : $relitems_fields;
After it add
Code:
$relitems_fields_temp = array(); foreach ($relitems_fields as $k=>$v) { if (is_array($v)) { $relitems_fields_temp[] = $v[0]; } else { $relitems_fields_temp[]= $v; } } $relitems_fields = $relitems_fields_temp; unset($relitems_fields_temp);

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #24575 by ggppdk
Actually the helper file needs no changes, the problem is with outdated elements that creates the FORM fields of the module

The file:
administrator/components/com_flexicontent/elements/types.php contains the updated code for J2.5

in r1257, to avoid duplication of the source code i replaced all code of all form field elements fields to a require_once() statement that includes the respective element from the folder:
administrator/components/com_flexicontent/elements

I hope i missed nothing.

NOTE: You will need to reopen your modules and re-save them !!!

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #24585 by gruz
Thanks a lot! Seems to work now!

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 1.035 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline