Skip to content

Loading…

Autosuggest showing 'undefined undefined' #2

Closed
BronsonQuick opened this Issue · 24 comments

5 participants

@BronsonQuick

I've enabled BP Labs as it has autosuggesting of names when an @ is used.

It's showing ''undefined undefined' at the moment. I am thinking that it's a plugin conflict and will need to turn off all plugins apart from BuddyPress and BP Labs to see if it works then. If it does then we'll need to flick them on 1 by 1 to find the conflicts

@Japh

I'm taking a look at this now too.

@Japh

From Googling, it looks like this is actually a bug in BP Labs, and Paul Gibbs says in this forum post http://buddypress.org/community/groups/bp-labs/forum/topic/auto-suggest-is-broken/ from a little over a week ago that he won't get a chance to look at it soon. BP Labs isn't a priority at the moment.

@BronsonQuick

Ahh good man. I vote we have a play and see if we can fix it for Paul!

Did you have a go at copying the files into our child theme? Might be worth a shot. I'll see if I can figure out what's triggering the error in the plugin.

@thenbrent

If we add it as submodule, we can patch in its own repo then push to our own fork and make a pull request. :D

@Japh

Feel free to add BP Labs as a submodule, @thenbrent :)

@BronsonQuick

@thenbrent Awesome plan of attack! I'm trying to debug it at the moment. The great thing about Paul is that you can bung in define ('WP_SCRIPTS', true); so you can get the dev.js

I'm console.logging a few things at the moment. Not making much progress yet though. Getting lots of '0' cause ajax is fun like that :)

@Japh

Yeah, you will. I think the problem might be that the AJAX action isn't being registered for some reason. Still working through it.

@Japh

Also, using define("SCRIPT_DEBUG", true); works for all WordPress core development, so it's cool that BuddyPress uses it too.

@BronsonQuick

I was gonna add this to .gitmodules:

[submodule "plugins/bp-labs"]
path = plugins/bp-labs
url = git@github.com:paulgibbs/BP-Labs.git

But I might be wrong. @thenbrent is that all I have to do? I should prolly read the readme again haha

@Japh

If we're adding submodules, @thenbrent, can you please also add a section to the repo's README.md on using them? Just for all us Git noobs ;)

@Japh

@BronsonQuick I'm pretty sure you'd do this from the command-line:
git submodule add git://github.com/paulgibbs/BP-Labs.git plugins/bp-labs

@BronsonQuick

@thenbrent Already did add that to the readme. Just trying it out now :)

@BronsonQuick

I suck. I deleted the bp-labs plugin then I tried git submodule add git@github.com:paulgibbs/BP-Labs.git plugins/bp-labs

and got fatal: Not a git repository: ../.git/modules/plugins/bp-labs #fail

@BronsonQuick

I'm gonna just comment on where I am at so we can all work on this one.

So we get to here: https://github.com/BronsonQuick/wpaustralia/blob/master/plugins/bp-labs/beakers/js/jquery.mentions.dev.js#L195 and that's where things are going wrong. My current theory is that jqXHR contains no data.

But there is a chance that maybe ajax with no privs needs to be added as an action

@BronsonQuick

My new theory is that mention_autosuggest might need a die(); in it perhaps?

Did I mention I had debugging ajax in WP? :)

@BronsonQuick

Okay so, it's definitely got to do with needing a die(); in there. We're getting a die('0'); from wp-admin/admin-ajax.php. If you change the die('0'); to in admin-ajax.php to die('grrrr'); and put a console.log(response); after https://github.com/BronsonQuick/wpaustralia/blob/master/plugins/bp-labs/beakers/js/jquery.mentions.dev.js#L169 you'll see grrr in the console.

I think I have stared at this too long and I'm missing something obvious here!

N.B. I only hack WordPress core when I am debugging :P

@BronsonQuick

Cheers for the tip @paulgibbs but unfortunately I suck at coding haha! ajaxurl was one of the first things I checked so it's good to know I started at the right place.

I tried adding some extra exit() in class-bplabs-autosuggest.php but didn't have any luck. I think I official give up for tonight. The good thing is that I am learning alot :)

@Japh

Last night I narrowed it down, and I don't think the BPLabs_Autosuggest->mention_autosuggest() function is even firing. If it's related to the ajax change @paulgibbs mentions, then I'd expect to be getting a 0 on the end of output, but I'm only seeing a 0 with no other output regardless of what I try.

@Japh

This is incredibly frustrating! I must be missing something very obvious, right in front of me, and I can't see it.

BPLabs_Autosuggest->register_actions() fires, so in theory BPLabs_Autosuggest->mention_autosuggest() should be the registered action to fire when an Ajax request is made.

When an Ajax request is made, it refers to the action activity_mention_autosuggest, as it should. But for some reason BPLabs_Autosuggest->mention_autosuggest() never fires.

Not sure if there's some issue with Line 66 of class-bplabs-autosuggest.php an the array passed to add_action?

@BronsonQuick

@Japh Yeah it is damn frustrating isn't it? :) It's so hard to debug Ajax stuff in WP. Once I've tidy up this BuddyPress Registration Honeypot plugin so it's good enough for you guys to review before I submit it to the repo then I'll jump back to this and checkout line 66 and see if I can help :)

@rmccue

Fixed this! @Japh, turns out register_actions() doesn't fire. The parent class checks is_admin(), which is true on admin-ajax.php, so it then returns without actioning anything. Patch incoming.

@rmccue

Pull request submitted upstream at paulgibbs/BP-Labs#1

@Japh

OH. EM. EFF. GEE. Thank you!

Though why I was able to get output inside register_actions, I still don't get. But luckily it no longer matters!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.