[SOLVED] Search breaks when sorted by custom field (date)

More
9 years 8 months ago - 9 years 8 months ago #62065 by ggppdk
Hello

in the new file there is no code like:
Code:
table AS fi

and no:
Code:
fi.

some of the files were not updated


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 9 years 8 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago - 9 years 8 months ago #62066 by ggppdk
Here is an example ordering by file field total downloads and then by a date field

notice the table alias
Code:
AS f2

also note that the ordering clause is created by other file:
component/com_flexicontent/classes/flexicontent.helper.php
Code:
SELECT SQL_CALC_FOUND_ROWS i.id FROM #__content AS i JOIN #__categories AS c ON c.id = i.catid JOIN #__flexicontent_items_ext AS ie ON ie.item_id = i.id JOIN #__flexicontent_types AS ty ON ie.type_id = ty.id LEFT JOIN (SELECT f.item_id, Sum(fdat.hits) AS file_hits FROM #__flexicontent_fields_item_relations AS f LEFT JOIN #__flexicontent_files AS fdat ON fdat.id = f.value WHERE f.field_id = 35 GROUP BY f.item_id) AS dl ON dl.item_id = i.id LEFT JOIN #__flexicontent_fields_item_relations AS f2 ON f2.item_id = i.id AND f2.field_id = 52 WHERE 1 AND i.state IN ( 1, -5, 2 ) AND c.published = 1 AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= UTC_TIMESTAMP() ) AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= UTC_TIMESTAMP() ) AND ty.access IN ( 0, 1, 1 ) AND c.access IN ( 0, 1, 1 ) AND i.access IN ( 0, 1, 1 ) AND ( ie.language LIKE 'el%' OR ie.language = "*" ) AND ie.type_id IN ( 1 ) AND i.id IN (SELECT id FROM fc_filter_iids_32) GROUP BY i.id ORDER BY file_hits DESC, Cast(f2.value AS date) ASC, i.title



-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 9 years 8 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #62069 by Ninjakitten
I appreciate your help, but I don't feel as though you understand what I'm saying, and that's really becoming frustrating. :/ I'm not sure how I can rephrase it, but I'll try.

Please look at line 444 and line 461 in flexiadvsearch.php, and notice the table alias:
Code:
LEFT JOIN #__flexicontent_fields_item_relations AS f
and likewise, line 639 in the same file:
Code:
JOIN #__flexicontent_fields as f
That is not something I did. That is the untouched distributed file, straight from the 15-dev zip.
Changing the alias for the #__flexicontent_fields table from f to something unused (fi) resolved the custom ordering 404 error.

#__flexicontent_fields_item_relations is aliased to f 4 times (lines 438, 444, 455, 461), and to f2 4 times (lines 473, 479, 490, 496).
#__flexicontent_fields is aliased only once, and it is aliased to f (line 639).

Resolving this resolves the error I originally posted about.
I'm not trying to do the second level ordering via PHP -- I just want it to work through the normal search configuration options.
Your image in the example below SHOWS the level 2 drop-down.
This matters because when the drop-down is SHOWN, level 2 ordering DOES WORK -- even without using the drop-down.
When the drop-down is NOT SHOWN, level 2 ordering DOES NOT work.
...and on changing to 15-dev, now only the first result on a page seems to have a categories array (and yes, I do have categories set as a field that search should render).
All the other results on the page have an empty array.
This result is the same whether I use my custom default_results.php or the unchanged one from the zip.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago - 9 years 8 months ago #62070 by ggppdk
Hello

i did not read 1 of your messages

you had posted 3 messages back to back , and i did not read the 1st of the 3

indeed the TABLE Alias that needs to be changed is:
> JOIN #__flexicontent_fields as f

- i will make a fix for this

[EDIT]
about 2nd level ordering being ignored (when selector is not visible) , i will check this too


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 9 years 8 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #62073 by Ninjakitten
Thank you!

After some poking around, it looks as if the new issue 15 caused (only having category info for the first result per search results page) comes from the rewriting of _getCategories in flexicontent.fields.php.

Changing line 1107 from
Code:
. ' WHERE c.itemid IN (' . $db->Quote(implode(',', $cids)) .')';
to
Code:
. " WHERE c.itemid IN ('" . implode("','", $cids) . "')";
and line 1121 from
Code:
. ' WHERE rel.itemid IN (' . $db->Quote(implode(',', $cids)) . ')'
to
Code:
. " WHERE rel.itemid IN ('" . implode("','", $cids) . "')"
seems to make it work properly again. It looks like maybe $db->quote doesn't work on lists of numbers? Joomla's secure coding guidelines page uses non-quoted implodes as above, but has JArrayHelper::toInteger($cids); on the line before the query in the 'Secure arrays of integers' section.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago - 9 years 8 months ago #62074 by ggppdk
Hello

The quotes were there before, and were working,
- Just we broke them recently, 1 day bug

because we replaced 1 query with 2 queries
- to make it faster for category view and use less memory

Furthermore indeed
1. These ids come from an integer DB column so they are never string, they are there for 3rd party code calling FC code,
2. you can just make sure that these are integers and then build the query without quotes

so will change them to be typecasted to integer and remove quotes completes

Thanks for report


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 9 years 8 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #62075 by ggppdk
Hello

i have commited fix:

- if you have uploaded new version

then you can use v3.0.x-stable branch:
github.com/FLEXIcontent/flexicontent-cck/tree/3.0.x-stable

click "Download ZIP " and upgrade


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago - 9 years 8 months ago #62076 by ggppdk
Hello

also fixed the 2nd level order will work now (regardless of if 2nd level order is displayed in frontend)

2nd level order was not working, because it was disabled, we have a flag to do this for views that do not implement it,

in this case , we added support but only enabled the flag when 2nd level order was shown

github.com/FLEXIcontent/flexicontent-cck/tree/3.0.x-stable


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 9 years 8 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #62079 by Ninjakitten
This new version definitely seems to have fixed the custom date field sorting issue and the categories. Thank you!

Unfortunately, it seems like the 2nd level ordering for search results is still only working when the drop-down is displayed. :/

Please Log in or Create an account to join the conversation.

More
9 years 8 months ago #62097 by ggppdk
Hello

aahh, i fixed it locally but i did not commit the change

commited, please retest


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save