Hi.

The new 4.7 version runs quite well on my setup now, and with finally seeing results, I can say thank you for such a wonderful module, I have been looking for something like this a long time.

But there's also one remaining issue:
Profile-Values are (mostly ?) stored serialized in the database in 4.7. This of course stays that way when your module gets those values into its own table. But unfortunately your module currently doesn't include an unserialize() - function... As far as I can tell it should be somewhere around row 600, but my PHP-knowledge and available time aren't up to this problem...

Comments

pukku’s picture

Assigned: Unassigned » pukku

Hi! What kind of profile.module fields are you referring to? Strictly speaking, this module right now will only work with profile.module fields, not arbitrary profile fields created by any other module. This is in part because MySQL doesn't have very good support for sub-selects, so in order to search, I need to have either a table or a view. Thus, everything that I can make accessible needs to be selectable with a SQL query, not processed through PHP.

That being said, someone privately sent me code that does grab and unserialize the 'data' field from the users table, but I'm not interested at this point in incorporating that code (this may change).

Ricky

oneoftwo’s picture

Hi.

I'm just talking about simple text value fields created by the 4.7.6 profile.module. At least in my profile_values table every value is stored serialized...

pukku’s picture

OK, that's weird. When I do a SELECT * FROM profile_values, the data in the value column is not serialized, but just data. What kind of profile fields are these? Are they single-line textfields? Or multi-line textfields? Or something else?

oneoftwo’s picture

Yes, it's a single-line text-field. But I just checked some code, and apparently the modified profile.module I am using is causing the serialization of all data... I didn't know that it also changed this aspect of data storage... And since I used it that way from the start of my site on, I can't really easily change it...

Update: Okay, I found a solution... After some trial-and-error coding, I found a solution that should work with every kind of value, be it serialized or not... (I don't know how to do "real" patch files, so here goes)

Row ~ 580

$use_themeing = variable_get('site_user_list_theme_cells', 0);
while($contact = db_fetch_array($result)) {
+
+ //catch serialized values
+ foreach ($contact as $pfkey => $pfvalue) {
+ $pfvalue_un = unserialize($pfvalue);
+ if ($pfvalue_un) {
+ $contact[$pfkey] = $pfvalue_un;
+ }
+ }
+
// allow items to be themed; see http://drupal.org/node/135189
if ($use_themeing) {

Now I know this is not completely nice since this apparently makes an unnecessary copy of the array, but the alternative while(list()=each()) solution just didn't work...

You might consider adding this to the code to the module any way, since date-fields appear to be serialized even with an original profile.module...

pukku’s picture

Hi! First, why do you have a "modified" profile.module — is this something that is common? Is this a change you made, or did you get it from somewhere else?

Second, I'll look at this. My one concern is that calling unserialize() for every value in the entire table, especially as you start to increase your number of users, might cause a big speed decrease. Perhaps I'll make it optional (like the use of theme functions).

Ricky

oneoftwo’s picture

Hi,

I use the profile.module provided by jaxxed ( http://drupal.org/node/29901 ) which allows for multiple choice profile fields, with some further small modifications by myself (mainly incorporating Drupal version updates). I don't think it's a common profile-module-version, though (which I personally find hard to understand...).

And yeah, I guess it's probably not the most resource-saving way of handling data... But optionality is of course always a way, and even if you decide not to include it, then at least a possible solution can now be found here for those people that might need it ;)

Well, thanks again anyway for your support and of course your module.

oneoftwo’s picture

Follow up for those who might want to use my solution for serialized values:

I noticed that sorting fails with serialized values... A solution would be to replace

$sql .= tablesort_sql($display_header);

with this:

  $tablesort = tablesort_init($display_header);
  if ($tablesort['sql']) { 
    $tablesort_sql = db_escape_string($tablesort['sql']); 
    $tablesort_sort = drupal_strtoupper(db_escape_string($tablesort['sort']));
    $tsstring = ' ORDER BY SUBSTRING_INDEX(' . $tablesort_sql . ", ':', -1) " . $tablesort_sor;
  }
  $sql .= $tsstring;
oneoftwo’s picture

sorry (typo), the new block should of course be:

  $tablesort = tablesort_init($display_header);
  if ($tablesort['sql']) { 
    $tablesort_sql = db_escape_string($tablesort['sql']); 
    $tablesort_sort = drupal_strtoupper(db_escape_string($tablesort['sort']));
    $tsstring = " ORDER BY SUBSTRING_INDEX(" . $tablesort_sql . ", ':', -1) " . $tablesort_sort;
  }
  $sql .= $tsstring;
pukku’s picture

Hi! I just uploaded a completely new version of site_user_list to cvs. This new version makes it possible, in theory, to handle things like this more easily. The right way to do this is to use hook_user to grab any changes to profile information, and store a "viewable" version in a shadow table. Then, the internal_sql query would grab from that table for columns that are serialized. I will be working on this at some point (I have to implement hook_user for a few other things anyway).

Also, the new version allows sorting to occur on different columns than display, which will solve the sorting issue you mentioned.

nancydru’s picture

I am seeing this problem too. In my case, it's on a date field. The profile field definition specifies this is a date field, so it should be handled that way.

Also, check boxes are displaying as 0 or 1, rather than as a check mark, which would be preferable.

nancydru’s picture

Oh, I almost forgot to say, I'm seeing it on the 5.x version.

pukku’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)