Skip to:
Content

Opened 3 years ago

Last modified 33 hours ago

#4824 reopened defect (bug)

Autocomplete

Reported by: stefwilliams Owned by:
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.5.0
Component: Component - Messaging Keywords: has-patch 2nd-opinion
Cc:

Description

In Private Message > Compose screen.
'Send to' field does not get autofilled with:

Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method '[url]/wp-admin/admin-ajax.php'

Also means mail cannot be sent at all, even using username or @name.

Have tried it with twentytwelve and still get the issue...

(Using build 6784)

Cheers

Attachments (1)

4824.diff (1.4 KB) - added by boonebgorges 33 hours ago.

Download all attachments as: .zip

Change History (17)

#1 @r-a-y
3 years ago

  • Keywords reporter-feedback added

Are you using any other plugins?

A quick search on Google came up with a conflict with the Events Manager plugin:
https://wordpress.org/support/topic/auto-complete-not-working-in-messages

Are you using that?

#2 @stefwilliams
3 years ago

Ah,
Yes, that does seem to be the issue - deactivated EM and it works...
The thread above seems unsure whether it's a BP bug or EM...
Any ideas yourself?

PS - sorry, I did do a 'quick search on Google' myself :)

Last edited 3 years ago by stefwilliams (previous) (diff)

#3 @r-a-y
3 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Judging from that forum thread, it looks like EM introduced the bug in a new version of their plugin so I assume it's a problem on their part. But if it ends up being a BP problem, tell their devs to post a ticket here.

Closing as invalid for now.

#4 @defunctlife
3 years ago

If buddypress would enqueue the autcomplete scripts in the footer it would fix most issues.

e.g.

wp_enqueue_script( 'bp-jquery-autocomplete',    BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.autocomplete{$min}.js",   array( 'jquery' ), bp_get_version(), true );
		wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.autocompletefb{$min}.js", array(),           bp_get_version(), true );
		wp_enqueue_script( 'bp-jquery-bgiframe',        BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.bgiframe{$min}.js",       array(),           bp_get_version(), true );
		wp_enqueue_script( 'bp-jquery-dimensions',      BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.dimensions{$min}.js",     array(),           bp_get_version(), true );

#5 @pareshradadiya
3 weeks ago

  • Severity changed from major to normal
  • Version 1.7 deleted

well, I am getting same error if I do use wp_editor in Private Message > Compose screen.

PS: Event Manager plugin is not active/install on site.

#6 @pareshradadiya
3 weeks ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

#7 @pareshradadiya
3 weeks ago

this is not ideal but there is work-around at the moment.

<?php

       /**
         * Lets preclude the wp_editor from enqueue 'jquery-ui-autocomplete' script.
         *
         * Provisional fix for the wordpress core autocomplete
         * conflict wit buddypress autocomplete
         *
         * @todo Remove the 'tiny_mce_plugins' and 'quicktags_settings' filters once get fixed in the buddypress core
         */
        add_filter( 'tiny_mce_plugins', function ( $plugins ) {

            if ( ( $key = array_search( 'wplink', $plugins ) ) !== false ) {
                // Remove 'wplink' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors.
                // It can be added with 'mce_external_plugins'.
                unset( $plugins[$key] );
            }
            return $plugins;
        });

        add_filter( 'quicktags_settings', function ( $qtInit, $editor_id ) {
            // Remove 'link' from the quicktag button to prevent errors.
            if ( ( $key = array_search( 'link', $qtInit['buttons'] ) ) !== false ) {
                $qtInit['buttons'] = str_replace( 'link,', '', $qtInit['buttons'] );
            }
            return $qtInit;
        });

`

#8 @pareshradadiya
3 weeks ago

  • Version set to 2.5.0

#9 @mlwilkerson
9 days ago

Thank you @pareshradadiya. I applied this provisional fix and it worked for me. I just noticed today that autocomplete on message compose had stopped working.

#10 @mlwilkerson
9 days ago

It's throwing warnings, though, on the first and third lines of the code in the snippet below:

add_filter( 'quicktags_settings', function ( $qtInit, $editor_id ) {
	// Remove 'link' from the quicktag button to prevent errors.
	if ( ( $key = array_search( 'link', $qtInit['buttons'] ) ) !== false ) {

Warning: Missing argument 2 for {closure}() in /path/functions.php on line 678

Warning: array_search() expects parameter 2 to be array, string given in /path/functions.php on line 680

Last edited 9 days ago by mlwilkerson (previous) (diff)

#11 @boonebgorges
8 days ago

  • Keywords has-patch 2nd-opinion added
  • Milestone set to 2.6

@pareshradadiya @mlwilkerson Thanks for reviving this issue. The root problem is that we are loading our own library that registers itself as jQuery.fn.autocomplete, and it's different from the jQuery UI library loaded by wp_editor(). The only way I can think of to fix this problem is to change the name of our library. In 4824.diff, I've made it jQuery.fn.autocompletebp. It's ugly, but it resolves the conflict.

The only potential for breakage here is if someone was intentionally trying to do something custom using our autocomplete scripts on their page. I have a feeling this is very unlikely, and I would much rather fix the problem with wp_editor() than try to maintain this weird bit of backward compatibility. Does anyone disagree?

This would go away if we used something less insane for our autocomplete. See #4580.

#12 @mlwilkerson
8 days ago

Thanks for your attention to this @boonebgorges.

As for your suggested workaround, I don't know enough about would it would mean to "fix the problem with wp_editor()"—as in, what that fix would be, and maybe more importantly, what the side effects would be. So your autocompletebp solution, while it may seem ugly, does seem to resolve the conflict with less likelihood of creating new ones. However, again, I don't know enough about the internals to know what impact that fix would have either.

Either way, thank you.

#13 @DJPaul
8 days ago

You didn't attach the patch, but looking at the code, it's pretty clear that jquery.autocomplete.js is a third-party script, albeit an old one dating back to BuddyPress 1.0. If we went this way, we'd have to change messages_autocomplete_init_jsblock as that's the one place in core where we call this script. The root problem is a badly? named jQuery module, but I don't know if this script predates jQuery UI's or vice-versa (they must both date from around the same time).

I am generally against modifying third party scripts for this kind of reason, even scripts we're working towards deprecating (see: the at-mentions JS).

This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.


33 hours ago

@boonebgorges
33 hours ago

#15 @dcavins
33 hours ago

  • Milestone changed from 2.6 to Future Release

#16 @boonebgorges
33 hours ago

  • Milestone changed from Future Release to 2.6

Sorry, I initially forgot the attachment. 4824.diff

I am generally against modifying third party scripts for this kind of reason, even scripts we're working towards deprecating (see: the at-mentions JS).

It's not great, but it's also a pretty huge pain that we are incompatible with wp_editor(). Less of two evils. I don't think there are serious BC concerns here, and I am more sympathetic to making things that work-but-are-ugly than things that are beautiful-but-don't-work.

Note: See TracTickets for help on using tickets.