Skip Navigation

[Resolved] Filtering Archive and Pagination issue

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 60 replies, has 5 voices.

Last updated by Beda 5 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1155682

Okay thanks, I have enough information now to report this to my 2nd tier support team for additional investigation. I'll let you know when I have some additional information to share about the problem. For now, it appears that "Show only available options for each input" should not be used for this archive.

#1157683

Thank you for reporting to 2nd tier. Please, keep up posted.

#1159603

We have created a stripped-down clone of the website and disabled WPML. That finally solved the issue!

Since for this project both multilingual support and the kind of filters' usage we have are essential, should we be expecting a solution on your side or should we be writing also to your colleagues in WPML?

#1159722

No need to start a separate ticket with WPML, our teams will collaborate if necessary.

#1160708

Hi, just wanted to let you know I am assigning this ticket directly to a 2nd tier supporter now. We've had difficulty getting your database to install successfully, and the issue cannot be replicated on a clean site installation. Beda will continue to follow up here. Thanks for your patience while we work this out.

#1160710

Thank you Christian.

@ Beda: we can give you full access to our clone website.

#1161414

Hello, I tried as Christian outlined, to replicate this issue both on clean and with the provided duplicates/database dumps

The closest I got is to restore the Database successfully (but we had to manipulate it) and from there, it cannot be connected to an Install, it tries to re-install WordPress from scratch even though, the Database is already providing all details and is existing, + connected to the core files install of WordPress.

During this process, and as well here in the ticket, I see several errors related purely to WPML and its queries to the database, complaining about inexisting tables and columns. Example, here: https://toolset.com/forums/topic/filtering-archive-and-pagination-issue/page/2/#post-1155376

It all points towards an issue within WPML but since we are the sister company of WPML I will not ask you to report that there again, instead I could internally work with WPML people to fix it.

But to do so I need (at least) a working package where the issue is shown, and that was not possible to achieve yet.

Yes, access to a staging site might help a lot.

Let's do it (if possible) like this:
- deploy your current site to a staging site
- remove all software, custom code and themes that you do not need to replicate the issue.
- make sure, WordPress files are genuine (re-install it in Dashboard > Updates > Reinstall)
- make sure all plugins are fresh (re-download them manually from the respective download sections of WPML and Toolset)
- make sure no custom code (theme) is used

Then, the issue should be replicated on a kind of "minimal install".
At this point, please enable the debug details as Christian already did show you in past and inform me.
With this, please if possible provide:
- Fresh Admin User Access to the WP Install (staging)
- URL or problem, and one example step to follow, in case it's different than already reported
- PHPMyAdmin User Access (you can install PHP ARI Adminer, it's a plugin that will let us look into the database without using cPanel; https://wordpress.org/plugins/ari-adminer/)
- Full SFTP access in case I need to alter PHP files, or remove errors, read the error log, etc. (cPanel works here usually, or any other method of SSH/SFTP)

I will then login to that site and look at this issue, try to narrow it down and likely, involve a WPML Specialist.

Thanks a lot for your patience and cooperation.

#1164723

OK, but can we update the system first?

If I am allowed to do any change I consider adequate on that site, and you would not lose anything if I do, I could do this directly myself, I am however not sure if you left them outdated for some reason?

Before I will proceed with the error replication and debug, I will update the versions - but I would need to confirm that is fine for you.
I will also remove the theme and other non-Toolset Plugins not needed for this issue since it is a test site.

Please confirm I can do as needed.

#1164726

Do as you like, it's a website for you!

#1164757

On it, then, please expect my news in less than 24hrs.
Not saying I will have the solution, but hopefully at least the reason and a bug report.

#1165446

I see the issue both on English and Italian, and I see the DDBB error as Christian mentioned:

WordPress database error: [Unknown column 'wpml_translations.language_code' in 'where clause']
SELECT s.id, st.status, s.domain_name_context_md5 AS ctx , st.value AS translated, st.mo_string AS mo_string, s.value AS original, s.gettext_context FROM studiogiochi_com_icl_strings s LEFT JOIN studiogiochi_com_icl_string_translations st ON s.id=st.string_id AND st.language='en' AND s.language!='en' WHERE s.context = 'default' LIMIT 1000 OFFSET 6000

I also see that it works if you change the filter to not update the values and hence show them all at all times.

I then updated the system, and removed Software piece by piece, starting with the non-OTGS Software.

1. After updating WPML the issue went worse and the SQL error bigger.

Errore sul database di WordPress: [Unknown column 'wpml_translations.language_code' in 'where clause']
SELECT studiogiochi_com_posts.ID FROM studiogiochi_com_posts INNER JOIN studiogiochi_com_postmeta ON ( studiogiochi_com_posts.ID = studiogiochi_com_postmeta.post_id ) LEFT JOIN studiogiochi_com_posts AS p2 ON (studiogiochi_com_posts.post_parent = p2.ID) WHERE 1=1 AND ( ( studiogiochi_com_postmeta.meta_key = 'wpcf-pubblicazioni-anno' AND studiogiochi_com_postmeta.meta_value = '2012' ) ) AND studiogiochi_com_posts.post_type IN ('post', 'page', 'attachment', 'autore', 'editore', 'pubblicazioni', 'le-nostre-pagine') AND (((studiogiochi_com_posts.post_status = 'publish' OR studiogiochi_com_posts.post_status = 'private') OR (studiogiochi_com_posts.post_status = 'inherit' AND (p2.post_status = 'publish' OR p2.post_status = 'private')))) AND ( ( ( wpml_translations.language_code = 'it' OR ( wpml_translations.language_code = 'it' AND studiogiochi_com_posts.post_type IN ( 'post','page','autore','editore','pubblicazioni','edizione','le-nostre-pagine' ) AND ( ( ( SELECT COUNT(element_id) FROM studiogiochi_com_icl_translations WHERE trid = wpml_translations.trid AND language_code = 'it' ) = 0 ) OR ( ( SELECT COUNT(element_id) FROM studiogiochi_com_icl_translations t2 JOIN studiogiochi_com_posts p ON p.id = t2.element_id WHERE t2.trid = wpml_translations.trid AND t2.language_code = 'it' AND ( p.post_status = 'publish' OR p.post_type='attachment' AND p.post_status = 'inherit' ) ) = 0 ) ) ) ) AND studiogiochi_com_posts.post_type IN ('post','page','attachment','autore','editore','pubblicazioni','edizione','le-nostre-pagine' ) ) OR studiogiochi_com_posts.post_type NOT IN ('post','page','attachment','autore','editore','pubblicazioni','edizione','le-nostre-pagine' ) ) GROUP BY studiogiochi_com_posts.ID ORDER BY studiogiochi_com_posts.post_date DESC

2. Your archive does not feature the closing "[/wpv-filter-controls]", it's missing. I added it, but this did not fix the issue, however, the error at least now is again like before (short)

Errore sul database di WordPress: [Unknown column 'wpml_translations.language_code' in 'where clause']
SELECT s.id, st.status, s.domain_name_context_md5 AS ctx , st.value AS translated, st.mo_string AS mo_string, s.value AS original, s.gettext_context FROM studiogiochi_com_icl_strings s LEFT JOIN studiogiochi_com_icl_string_translations st ON s.id=st.string_id AND st.language='it' AND s.language!='it' WHERE s.context = 'default' LIMIT 1000 OFFSET 6000

3. There is a View on that archive, but it's not inserted in the archive, instead somehow else. How do I remove that view?
(hidden link)

4. I created a new view and there I see all available dates.
The query finds 216 items.
hidden link
As soon you add pagination, then you will "find" only the amount of items per page with wpv-items-count, instead, wpv-found-count returns the full amount of posts.
The options in the DropDown search will be all there if you do not paginate, they will only show the ones on the very current page if you paginate.
This, is not replicable locally. Locally, you will always see all options unless of course, some other filter removes them, but pagination does not influence that filter.

But then, I saw that this is NOT a Post Types archive, instead, it is a TAXONOMY archive, and there, look at that, I can replicate the issue clean and clear on a local install, no big deals needed.

The thing is, it requires always a lot of testing to find the steps for the precise issue, but they are always there (lucky us)

Now, on local, the issue works like this:

1. Create a Custom Taxonomy and assign ONE term to ONE Post. Create ANOTHER Term and assign it to ANOTHER post
2. Both those posts should also have a Custom Field with any value you want (this is what we will use in the search later, and will "break")
3. Create an archive for that taxonomy and in it, a custom search for the field, select mode
4. Choose to always hide non-valid options and paginate by one
5. Complete the loop and observe/use the Archive on the front end

It will show only ONE value in the search select for the custom field.
If you paginate, it will show a new value matching the ONE post displayed on the page.
If you remove pagination, then all items will show in the search
If you add a SECOND Post to the exact same term, then that posts custom field value as well appears in the search

This is exactly what happens on your site, and I am not sure if this is expected!
See, when you load a taxonomy archive the query IS already restricted to ONE term, so only posts of that term are displayed and so only Custom Search options of those posts appear.
What is not expected, is that pagination has an influence on this, it should not by what I know, and that is why I report this as an error.

The current workaround to this is to not paginate, or not limit the search input.
It workes well on post archives.

Note, I above wrote my entire process done on your site, until I had the problem localized
You might ask yourself why I do not just say "I replicated the issue please wait for the fix". I do this for 3 reasons:
- you can learn to troubleshoot and know where to look for next time
- our supporters can see what I did
- other users can see what we do and how we solve issues or narrow down steps and will understand better why this is so important and (sometimes) takes time.

I hope you are fine with my more elaborated style of support and will update you here once I have news from the developers, .about this problem.
Eventually, an erratum will be published which I then also would share here.

Related to the Error (SQL Error), I would suggest opening another thread for this in WPML Forum as it is not related to this issue or Toolset in general. This should instead be an issue that is fixable with WPML's troubleshooting steps and seems not to affect our issue here now.

Beda.

#1165510

Just wanted to ask, please do not delete that test site, as the issue I replicated, is actually expected, so I am back at square one, but can tell:
- String Translation is the culprit
- if you use Checkboxes in the search instead of Select it works
- If you add any second filter and do NOT fix the query as Views will offer (ANd / OR) then it works as well
- After you run a manual search then it works as well (so if you manually add 2012 to the URL, query it, then it works)

This was all confirmed on your site and I am sure there are steps to replicate this, however it seems I missed an expected technical issue before and did not replicate it properly.
I am however on it so to be sure to have found the exact bug.

#1166224

Long story short, there is something wrong here with the Translations.

Toolset works fine, also with properly translated content.
On your site, there are issues with the translations, namely, the fields (marked as not translatable, but translated) and the taxonomies, which are translated, but somehow wrongly (not matching the slugs and language information)

I forwarded this to my WPML Colleagues because it is all solved as soon ST is disabled (String Translation) and I am not that familiar with WPML to properly debug this.

I will, of course, continue to update you here.

==> Note, the issue I replicated earlier was actually expected, so not a bug, I fooled myself in the process.

#1167568

Thank you Beda for your in-depth analysis.

We have verified that some taxonomies (in the WPML Settings) were marked as having "English" as their source language, where it should have been Italian.

Though, we can't understand what you mean by fields "marked as not translatable, but translated". While we wait for your colleagues from WPML, can you give us a specific example to check?

Thanks again

#1167743

Since we spent the morning doing some heavy cleaning (useless custom fields, wrong WPML language settings) on the online website, would it be OK if we copied our actual database to test.studiogiochi.com, so that if you have some more testing to do, then you'll have a cleaner environment?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.