[wp-trac] [WordPress Trac] #39576: Admin - Tag autocomplete not work - WP >= 4.7

WordPress Trac noreply at wordpress.org
Fri Jan 13 14:56:32 UTC 2017


#39576: Admin - Tag autocomplete not work - WP >= 4.7
--------------------------+-----------------------------
 Reporter:  mgermani      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.7.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 For WP 4.7 >= tags suggest not work properly. Ajax search return text
 delimited by "\n" but split parser fails:

 File: wp-admin/js/tags-suggest.js
 Line: 66 to 82

 {{{#!js
                                         if ( data ) {
                                                 data = data.split( '\n' );

                                                 for ( tagName in data ) {
                                                         var id = ++tempID;

                                                         tags.push({
                                                                 id: id,
                                                                 name:
 data[tagName]
                                                         });
                                                 }

                                                 cache = tags;
                                                 response( tags );
                                         } else {
                                                 response( tags );
                                         }  response( tags );
                     }
 }}}

 The method data = data.split( '\n' ); generate an Array() but "for in"
 construct set tagName with name method besides the int index.
 I have fixed this issue checking if tagName is only a number:

 {{{#!js
                     if ( data ) {
                         data = data.split( '\n' );

                         for ( tagName in data ) {
                             var id = ++tempID;

                             if (!isNaN(tagName)) {
                                 tags.push({
                                     id: id,
                                     name: data[tagName]
                                 });
                             }
                         }

                         cache = tags;
                         response( tags );
                     } else {
                         response( tags );
                     }
 }}}

 I hope this help!
 Best regards.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39576>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list