Hi!
When using this module with Views following error occurs when using Drupal for Facebook Friend filter: "Defaults: Configure filter Broken/missing handler". Note that this happens with any FB Views handler provided by fb_views module

Comments

amir_c’s picture

Status: Active » Needs review
StatusFileSize
new596 bytes

Here is the patch for this error. Tested myself and it seems fine i.e. the error "Defaults: Configure filter Broken/missing handler" is not shown anymore.
However, there are some other issues with fb_views module that I will report soon.

amir_c’s picture

after applying the patch above, I tried again to use FB Friend filter and when choosing True on Views filter question "Is friend of the current user ", I get following pop-up error window "An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /smk/admin/structure/views/ajax/preview/fb_test
StatusText: Service unavailable (with message)
ResponseText: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fb_user.fbuINs' in 'where clause': SELECT COUNT(*) AS expression
FROM
(SELECT 1 AS expression
FROM
{node} node
LEFT JOIN {fb_user} fb_user ON node.uid = fb_user.uid
WHERE (( (fb_user.fbuINs = :db_condition_placeholder_0) ))) subquery; Array
(
[:db_condition_placeholder_0] => 0
)
in views_plugin_pager->execute_count_query() (line 141 of C:\xampplite\htdocs\smk\sites\all\modules\views\plugins\views_plugin_pager.inc)."

Anybody who knows what this could be? My guess is that line 24 in fb_views_handler_filter_friends.inc i.e. $this->query->add_where(0, $this->table_alias . '.fbu IN (%s)', implode(',', $friends)); is wrong

banana.boy’s picture

Same problem here after applying the patch:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_node__fb_user.fbuINs' in 'where clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node} node LEFT JOIN {users} users_node ON node.uid = users_node.uid LEFT JOIN {fb_user} users_node__fb_user ON users_node.uid = users_node__fb_user.uid LEFT JOIN {field_data_field_price} field_data_field_price ON node.nid = field_data_field_price.entity_id AND (field_data_field_price.entity_type = :views_join_condition_0 AND field_data_field_price.deleted = :views_join_condition_1) WHERE (( (node.type IN (:db_condition_placeholder_0)) AND (users_node__fb_user.fbuINs = :db_condition_placeholder_1) ))) subquery; Array ( [:db_condition_placeholder_0] => book_ad [:db_condition_placeholder_1] => 0 [:views_join_condition_0] => node [:views_join_condition_1] => 0 ) in views_plugin_pager->execute_count_query() (line 140 of /home/banana/web/drupal/sites/all/modules/views/plugins/views_plugin_pager.inc).

Any news?

banana.boy’s picture

I fixed the query() method:

  function query() {
    // We can't learn friends if user is not logged in.
    $fbu = fb_facebook_user();
    if ($fbu) {
      $friends = fb_get_friends($fbu);
      // if the user has friends
      if(count($friends) > 0) {
        $friends_formatted = "('" . implode("', '",$friends) . "')";
        $this->ensure_my_table();
        $this->query->add_where_expression($this->options['group'], $this->table_alias . '.fbu IN ' . $friends_formatted);
      }
    }
  }

It works fine, but gives the same result for "true" and "false" parameters, which I don't know how to fix.

amir_c’s picture

I used views_handler_filter_in_operator as class extender in another views filter that I've been building on and it worked fine.

amir_c’s picture

banana.boy, I tested your query() function and it works great!

I don't know why you're interested in results for "false" parameters but here is the code for that:

if(count($friends) > 0) {
        $friends_formatted .= "('" . implode("', '",$friends) . "')";
        $this->ensure_my_table();
		if ($this->value == TRUE){
			$this->query->add_where_expression($this->options['group'], $this->table_alias . '.fbu IN ' . $friends_formatted);
		} else {
			// do what ever you want to do when FALSE
		}
      }
banana.boy’s picture

Thanks !
I came back here to post the same thing as you !

But the hard thing is: how do you restrict the query to people who are NOT friends of the user?
Because, if you just use "NOT IN", it will only show Facebook users that are not friends, but won't show the users that are not on Facebook (not in the fb_user table) !

amir_c’s picture

Status: Needs review » Reviewed & tested by the community

Please include this patch in next release of fb_views since it was tested OK. note that there are 2 patches here: one for the actual port to D7 and the one for the fb_views_handler_filter_friends.inc - see #4. thanks and keep up the good work!

luksak’s picture

Status: Reviewed & tested by the community » Needs work

If you want code to go into a module, you should create a patch. Inline code posted in comments will not.

luksak’s picture

Status: Needs work » Needs review
StatusFileSize
new4.17 KB

I created a patch for this. I only tested the profile picture feature and added all available options for the fbml tag (except facebook-logo):

https://developers.facebook.com/docs/reference/fbml/profile-pic/

joknjokn’s picture

Lukas von Blarer's patch just worked for me, using 7.x-3.3-beta6. (I did it manually.)

tunic’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

The patch from #10 works fine.

Remember that if you are patching the module donwloaded form durpal.org the automatically metadata added by drupal.org avoids patching the .info file. The patch applies ok to the respository version.