• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

"Most Recent" doesn't work suddently

Status
Not open for further replies.

domaincamp

Chevereto Member
Hi

Just found a weird issue. Today when I upload images, the newly uploaded images should show as the 1st image on the page, but they are not. The newly uploaded images are listed behind old images.

Please check the screenshot, the 3 images in the red circle are the latest 3 images got uploaded.

Actually I uploaded 4 images, can't find one of them, but the direct link to that image works.

Thanks in advance

recent.jpg
 

Hi, Rodolfo

I did searched about this issue in advance but didn't see related topics.

I just created a new user and uploaded three images (the latest 3 images)
Please check this user's profile link

When choosing the "Most Recent" images, these three images are not on first 3 position.
Two of them are in the 4th rows, and I can't find another image.

And the "Most Viewed" "Most Liked" all doesn't show the correct order.
This image is the most viewed and liked, but it's not on position 1st.


The following is my system info, please help, thanks!


  • Chevereto version 3.8.3 – G\ Library 1.0.29
  • PHP version 5.6.15
  • Server host.*********.com Linux/apache2handler
  • MySQL version 5.6.31
  • MySQL server info Uptime: 79772 Threads: 4 Questions: 25915 Slow queries: 0 Opens: 360 Flush tables: 1 Open tables: 135 Queries per second avg: 0.324
  • GD Library Version bundled (2.1.0 compatible) JPEG:1 GIF:1/1 PNG:1 WBMP:1 XBM:1
  • File uploads Enabled
  • Max. upload size 80 MB
  • Max. post size 80 MB
  • Max. execution time 120 seconds
  • Memory limit 64 MB
 
Last edited:
Works fine for me I don't know where you got that is not working as expected.

upload_2016-8-30_12-23-7.png
 
What I found is that the this query:

Code:
SELECT * FROM (SELECT * FROM chv_images
LEFT JOIN chv_albums ON chv_images.image_album_id = chv_albums.album_id
WHERE chv_images.image_nsfw = 0 AND (chv_albums.album_privacy NOT IN ('private','private_but_link','password','custom') OR chv_albums.album_privacy IS NULL OR chv_albums.album_user_id IS NULL)
ORDER BY chv_images.image_id DESC
LIMIT 0,25) chv_images
LEFT JOIN chv_storages ON chv_images.image_storage_id = chv_storages.storage_id
LEFT JOIN chv_users ON chv_images.image_user_id = chv_users.user_id
LEFT JOIN chv_categories ON chv_images.image_category_id = chv_categories.category_id

In your server is not working as expected because in your server the engine is re-sorting the resulset, which is something that it shouldn't. Basically the sub-query select the matching images with order, then it adds (join) the other tables (storages, users, categories, etc.) but in your server it does the sub-query then re-sort the resultset (not always).

So at script side the patch is quite simple is just add this line to the bottom of the query:
Code:
ORDER BY chv_images.image_id DESC
I've added a patch that will work for now in your server (PHP) but is not an official patch because I'm still investigating this.

I think that the trouble could be in your optimizer_switch which has this value:
Code:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on,use_index_extensions=on

As a reference, this is my optimizer_switch for the demo:
Code:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on

And this one is for my dev server:
Code:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on

You should try changing your optimizer_switch and debug the thing to see if you get a re-ordered resulset via PHPMyAdmin or any DB script/software you use. There could be other variables causing this, not sure about it to be honest. I searched around, I asked around, no one knows this bug or whatever it is.

I'm pretty sure that the problem is your MySQL configuration, I dumped your database in my local server and the query worked fine so is not DB structure, indexes, etc.

The MySQL user that I used (taken from settings.php) didn't have SUPER privileges so I wasn't able to test those variables, I assume that everybody uses *standard* setups and I can't spend all day debugging the 500 variables of a custom MySQL server but all those with "sort" must be related to this.

I noticed that you are on a VPS so it won't be that hard to change those values. Let me know if you do it or if you grant me SUPER. I need to fix this and the patch only applies to your installation, I'm not adding that patch to the official releases yet.
 
Last edited:
WOW! Rodolf, thank you very much!

As I can see the issue is fully solved now and it has taken you a few hours of precious time to help me find the solutions. Even this is my server-side issue.
I can see there are two new files being created on the root directory, are they the patches and should I keep them there?
And in which file did you add this code to the bottom?
ORDER BY chv_images.image_id DESC
 
Those files are for debugging, adminer.php is a well known one-file PHPMyAdmin alternative and the other one is an HTTP tunnel that I setup to connect your database with my database manager software (Navicat). You can get rid of those, I use them only for test purposes.

The file with the patch is app/classes/class.listing.php:
PHP:
$query .= $order_by;

I think that I will add this patch to the official release but I never like when I fix something knowing that something else is triggering it. But I can't figure it out yet, and the patch shouldn't cause any issues to be honest, just some bytes to re-order.
 
Status
Not open for further replies.
Back
Top