Possible bug

  • Bojan Atanasijevic
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 6 months ago - 13 years 6 months ago #1 by Bojan Atanasijevic
Possible bug was created by Bojan Atanasijevic
Joomdle R0.82

While analyzing code to see why Joomla 1.6+ custom user profile mapping to Moodle not works,
( www.joomdle.com/en/forum/r08-support/911...not-synced-in-moodle )
I think that I found a possible bug which is not in correlation with my primary issue.

File: administrator/components/com_joomdle/helpers/mappings.php
Function: set_field_value_joomla16 ($field, $value, $user_id)

Line 1980:

instead of: ' INSERT INTO #__community_fields_values' .

should be: ' INSERT INTO #__user_profile' .



If we have new user it will be inserted into wrong table, and probably unexisting table ...

Code:
function set_field_value_joomla16 ($field, $value, $user_id) { $db =& JFactory::getDBO(); $query = ' SELECT count(*) from #__user_profiles' . " WHERE profile_key = " . $db->Quote($field) . " AND user_id = " . $db->Quote($user_id); $db->setQuery($query); $exists = $db->loadResult(); if ($exists) $query = ' UPDATE #__user_profiles' . ' SET profile_value='. $db->Quote($value) . " WHERE profile_key = " . $db->Quote($field) . " AND user_id = " . $db->Quote($user_id); else $query = ' INSERT INTO #__community_fields_values' . ' (profile_key, user_id, profile_value) VALUES ('. $db->Quote($field) . ','. $db->Quote($user_id) . ',' . $db->Quote($value) . ')'; $db->setQuery($query); $db->query(); return true; }
Last edit: 13 years 6 months ago by Bojan Atanasijevic.

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

More
13 years 6 months ago #2 by Ron Wells
Replied by Ron Wells on topic Possible bug
Could this be related to a PHP error I am getting in the error_log file located in my public_html folder?

PHP Warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in /home/public_html/administrator/components/com_joomdle/helpers/mappings.php on line 1302


Thanks,
Ron

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

  • Bojan Atanasijevic
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 6 months ago #3 by Bojan Atanasijevic
Replied by Bojan Atanasijevic on topic Possible bug
Hi Ron,

No, this bug is not related to warning issues you found in log, though this is a bug, but not critical.

The problem is with array-merge which expects all parameters to be array.
I did not have time to do deep investigation on depended code, but you will get rid of this warnings if you cast second parameter into array.

In file administrator/components/com_joomdle/helpers/mappings.php line 1302 which is:
Code:
return array_merge ($user_info, $more_info);

should be
Code:
return array_merge ($user_info, (array)$more_info);

Someone more skillded in joomdle code shoud verify if this is correct way to fix this.

Regards,

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

More
13 years 6 months ago #4 by Antonio Durán
Replied by Antonio Durán on topic Possible bug
Thanks for the bug report, Bojan. I will fix it for next release.

Ron, I will also take a look at the best way to fix your log errros. Thanks for sharing.

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