Administrative user search form not working

theborg - January 15, 2008 - 11:58
Project:Drupal
Version:6.x-dev
Component:user system
Category:bug report
Priority:critical
Assigned:theborg
Status:closed
Description

There is a typo error in user search form that renders the same content without doing the search.

Patch provided.

AttachmentSize
user_search_a.patch819 bytes

#1

catch - January 15, 2008 - 12:05
Status:needs review» reviewed & tested by the community

trivial patch, tested, works, RTBC.

#2

theborg - January 15, 2008 - 12:11

Related to this form also: http://drupal.org/node/208790

#3

Gábor Hojtsy - January 15, 2008 - 12:42
Status:reviewed & tested by the community» needs work

Hm, we use NULL not null. Also what does search_data() do there? There is not even a parameter at that position AFAIS:

in the patch:
drupal_get_form('search_form', url('admin/user/search'), $keys, 'user', null, search_data($keys, 'user'));

function signature:
function search_form(&$form_state, $action = '', $keys = '', $type = NULL, $prompt = NULL) {

#4

theborg - January 15, 2008 - 13:25

Corrected NULL typo.

As per form_api:
drupal_get_form can take optional additional arguments, which will be simply passed on to the $form builder function.

AttachmentSize
user_search_b.patch 819 bytes

#5

Gábor Hojtsy - January 15, 2008 - 13:40

Yes, that doc refers to the arguments of the form builder I quoted above. How does search_data($keys, 'user') get there.

#6

chx - January 15, 2008 - 14:17

What Gabor says is that you are passing NULL for $prompt and then something else which has no matching parameter in the function signature.

#7

theborg - January 15, 2008 - 14:45

Yes, I'm aware of that, sorry, I missunderstood documentation.

The keys end as a callback parameter to drupal_retrieve_form and search_form function

  // If $callback was returned by a hook_forms() implementation, call it.
  // Otherwise, call the function named after the form id.
  $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);

Sure there is a correct way of solving this bug.

#8

chx - January 15, 2008 - 18:41

SIGH! You are passing five (5) arguments to search_form which takes four (4) arguments aside from the form_state that's automatically added. The fifth argument is not going to be used. Got it?

#9

theborg - January 15, 2008 - 21:07
Status:needs work» needs review

Ok, got it, sorry for that mess.

This patch sets the action to null, so it will go to 'search/user'.

AttachmentSize
user_search_c.patch 859 bytes

#10

dvessel - January 16, 2008 - 00:06
Title:User search form not working» Administrative user search form not working

Only affects the admin end.

The patch works but I don't think you need to check for keys. search_data will handle it just fine but I'm not sure if the returning nothing and appending to the string would cause a notice.

#11

chx - January 16, 2008 - 00:45
Status:needs review» needs work

If you pass in NULL then the action

<?php
 
if (!$action) {
   
$action = url('search/'. $type);
  }
?>
wil be search/user. This is not what you want. I agree with dvessel that passing in a NULL for search_data will work the function returns NULL very fast which PHP nicely casts to the empty string.

#12

chx - January 16, 2008 - 01:07

Why in the first place do we have this page? What does it do that search/user does not?

#13

chx - January 16, 2008 - 01:16
Status:needs work» needs review

catch said we nuked admin/content/search for it did nothing that search/node did not. Same for this page. Fixing the search form does not hurt, however.

AttachmentSize
search.patch 1.14 KB

#14

catch - January 16, 2008 - 01:17
Status:needs review» needs work

Nothing.

fwiw, admin/content/search was removed a couple of months ago for similar reasons.

#15

chx - January 16, 2008 - 01:46
Status:needs work» needs review

I guess catch crossposted my patch.

#16

dvessel - January 16, 2008 - 02:22
Status:needs review» needs work

Works just fine. The menu link still exists though. Thought it was cached in the menu system.. got it cleared and it's still there.

#17

theborg - January 16, 2008 - 08:40
Status:needs work» needs review

Tested and works ok.

Removed the search link from the admin users menu.

AttachmentSize
search_b.patch 2.36 KB

#18

theborg - January 16, 2008 - 08:51
Status:needs review» needs work

Edit: $form['#redirect'] = FALSE; causes /search path to not work.

AttachmentSize
search_c.patch 1.68 KB

#19

theborg - January 16, 2008 - 08:51
Status:needs work» needs review

#20

chx - January 16, 2008 - 13:19
Status:needs review» reviewed & tested by the community

OK.

#21

Gábor Hojtsy - January 16, 2008 - 22:55
Status:reviewed & tested by the community» fixed

Hm, all right. The argument sounds right that we removed the content search on the same grounds. Well, committed.

#22

Anonymous (not verified) - January 30, 2008 - 23:04
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.