Skip to main content
Topic: Small bug in search members with dropdown custom fields (Read 5369 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Small bug in search members with dropdown custom fields

At some point in Elkarte was addes the option to search user based on a  custom field wich can be a dropdown field. This is working great but I noticed a couple of errors in my log



In the image above I searched for members based on field "Provincia" which should be province in english. It works, but if I click on "Provincia" or "Regione" fields (see the 2 red arrows) I get a database error:



Not a big bug, bud would be better if solved. ;)
sorry for my bad english

Re: Small bug in search members with dropdown custom fields

Reply #1

Did you update Elkarte up to 1.0.6 correctly? I am not sure about the patch notes, but it says your database version is still 1.0.2 #_#
~ SimplePortal Support Team ~

Re: Small bug in search members with dropdown custom fields

Reply #2

I use the latest version:

sorry for my bad english

Re: Small bug in search members with dropdown custom fields

Reply #3

It's weird, it says your database version is 1.0.4 and it claims it's updated to the most recent one, however the error says you are still running 1.0.2 database. I think we need one of the big guys here.
~ SimplePortal Support Team ~

Re: Small bug in search members with dropdown custom fields

Reply #4

Yep, indeed something broken.
That's a... I'm not if calling it a fix is right, or maybe workaround sounds better, though it seems to work on few testings (I don't think it's particularly elegant though).

The file is sources/controllers/Memberlist.controller.php.
After:
Code: [Select]
$input_fields = isset($this->_req->query->fields) ? explode(',', $this->_req->query->fields) : $this->_req->post->fields;
add:
Code: [Select]
			if (isset($context['columns'][$sort]))
$input_fields[] = $sort;

before (or after, it doesn't matter):
Code: [Select]
$context['old_search_value'] = $search;
add:
Code: [Select]
			$input_fields = array_unique($input_fields);

and finally, replace:
Code: [Select]
					$customJoin[] = 'LEFT JOIN {db_prefix}custom_fields_data AS cfd' . $curField . ' ON (cfd' . $curField . '.variable = {string:cfd' . $curField . '} AND cfd' . $curField . '.id_member = mem.id_member)';
$query_parameters['cfd' . $curField] = $curField;
$fields += array($customCount++ => 'IFNULL(cfd' . $curField . '.value, {string:blank_string})');
with:
Code: [Select]
					$customJoin[] = 'LEFT JOIN {db_prefix}custom_fields_data AS cfd' . $field . ' ON (cfd' . $field . '.variable = {string:cfd' . $field . '} AND cfd' . $field . '.id_member = mem.id_member)';
$query_parameters['cfd' . $field] = $curField;
$fields += array($customCount++ => 'IFNULL(cfd' . $field . '.value, {string:blank_string})');

that should do.
Bugs creator.
Features destroyer.
Template killer.

Re: Small bug in search members with dropdown custom fields

Reply #5

What about that database version discrepancy? Can it be a problem? Is it known or just a false trigger or else? I remember something similar on smf, can't recall the details...
~ SimplePortal Support Team ~

Re: Small bug in search members with dropdown custom fields

Reply #6

Irrelevant. (Like in the other 99.9% of the times.)
Bugs creator.
Features destroyer.
Template killer.

Re: Small bug in search members with dropdown custom fields

Reply #7

Good to know, thanks :)
~ SimplePortal Support Team ~

Re: Small bug in search members with dropdown custom fields

Reply #8

Quote from: emanuele – The file is sources/controllers/Memberlist.controller.php.
After:
Code: [Select]
$input_fields = isset($this->_req->query->fields) ? explode(',', $this->_req->query->fields) : $this->_req->post->fields;
add:

Probably there is something wrong with my Memberlist.controller.php, but I have:
Code: [Select]
$input_fields = isset($_GET['fields']) ? explode(',', $_GET['fields']) : $_POST['fields'];

Re: Small bug in search members with dropdown custom fields

Reply #9

Ouch!!
Sorry, I was looking at the 1.1 files...
The line is the one you posted. All the others should be the same.
Bugs creator.
Features destroyer.
Template killer.

Re: Small bug in search members with dropdown custom fields

Reply #10

Well that worked for field province, but if I click on the other one "Region" I still get an error. I am wondering if a sort option has really sense in this case

Code: [Select]
Unknown column 'cfdcust_cust_region.value' in 'order clause'
File: /.../sources/subs/Memberlist.subs.php
Riga: 261

Nota: la versione del tuo database รจ 1.0.2.
sorry for my bad english

Re: Small bug in search members with dropdown custom fields

Reply #11

O_o

Is there any difference between the two fields? (Type mainly.)
Bugs creator.
Features destroyer.
Template killer.

Re: Small bug in search members with dropdown custom fields

Reply #12

they are both dropdown fields, what I wonder if a sorting option is really useful in this case
sorry for my bad english

Re: Small bug in search members with dropdown custom fields

Reply #13

I'd say yes.
Not in most of the possible custom fields but for some it would indeed be useful. Regioni e province to me is a good example of potentially useful sorting: that allows you to group them (yeah, okay, you could just search :P).
Bugs creator.
Features destroyer.
Template killer.

Re: Small bug in search members with dropdown custom fields

Reply #14

I keep forgetting that 1.1 is slightly different in many places...
Move this code:
Code: [Select]
			// Set defaults for how the results are sorted
if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
$_REQUEST['sort'] = 'real_name';
just after:
Code: [Select]
		// They're searching..
if (isset($_REQUEST['search']) && isset($_REQUEST['fields']))
{

move in the sense that the piece of code is present few lines below, remove it from there and move it up.
Bugs creator.
Features destroyer.
Template killer.