[TRN] Discussion Preview [Deleted]

I'm displaying 20 threads, each displaying 6 attachments.
Addon disabled (forum_view):
Screen Shot 2016-05-24 at 3.40.20 PM.webp
Addon enabled (forum_view):
Screen Shot 2016-05-24 at 3.41.10 PM.webp
qJou.png
I guess the problem is the attachments [...] :oops: but this is the only reason I've purchased the addon, I need to display the attachments, but 147 DB queries is too much :r
 
For each discussion i have to make a single query for images. For each image found that shall be displayed I run the code:
Code:
$image = $this->getModelFromCache('XenForo_Model_Attachment')->prepareAttachment($image);
$image['canView'] = $this->getModelFromCache('XenForo_Model_Attachment')->canViewAttachment($image);
}
That generates several queries per image and it comes to a price of course. If the impact is to high, try reduce the number of previewed images per page.
Reduce the images per page is not an option to me. I need those 6 images.
Maybe there are some way to optimize those queries in the code instead? because that would be great.
 
Maybe removing that permission check $image['canView']? can reduce the queries? because my attachments are open to everyone. I don't need that.
 
Maybe removing that permission check $image['canView']? can reduce the queries? because my attachments are open to everyone. I don't need that.

I've checked that and that permission check generates several queries per each image.

In /library/fgX/DiscussionPreview/ImagePuller.php

Change the line

Code:
$image['canView'] = $this->getModelFromCache('XenForo_Model_Attachment')->canViewAttachment($image);

to

Code:
$image['canView'] = 1;//$this->getModelFromCache('XenForo_Model_Attachment')->canViewAttachment($image);

Let me know if it helps. Then I might make that an option. I guess most people won't need a permission check on each image.
 
31 :) Thank you!
Screen Shot 2016-05-24 at 4.43.33 PM.webp
I really would like to get rid all those permissions checks (if there are more) . I don't need that, because my threads are open to everyone. the overload in the server checking permissions is not fun :cautious:
 
farang updated [fgX] Discussion Preview with a new update entry:

Version 3.6.0 released

New features in version 3.6.0
  • New option "Perform Attachments Permission Checks" (Disabled by default)
Properly checking the users view permissions on each image that shall be previewed will cause several additional database queries for each image. What is actually checked is the permissions to see the full size attachment, not the thumbnail. Thumbnails don't have any permission checks on them. If a user doesn't have permissions to view a certain attachment and the...

Read the rest of this update entry...
 
Probably this has been mentioned before, but just noticed after buy: Needs at least PHP 5.4
Debian 7 with PHP 5.3 using this addon stops Xenforo fully (blank pages). Of course I will update, late, but for the moment I can't use it...
 
Probably this has been mentioned before, but just noticed after buy: Needs at least PHP 5.4
Debian 7 with PHP 5.3 using this addon stops Xenforo fully (blank pages). Of course I will update, late, but for the moment I can't use it...

Hi @PyroM

That was news for me. My add-ons shall work with the same PHP version as XenForo requires (currently PHP 5.2.11+). I've made a small change in the code to address the problem which is related to PHP syntax for dereferencing function results. I've been testing it in PHP 5.2.17 (which is the lowest that I can go). I release the fix within a moment.
 
There are more permission checks edited on this version? 147 to 31 is a big difference, but still 31 is a high number of queries. by default forum_list only have 8 - 10

No I haven't changed anything else regarding to decrease the number of queries. I'm bound to try using the built in XF functions. When preparing an image for display, there are queries involved. I wish I could but I can't really do anything about that. If You need to make it run faster than 0,0650 seconds and it keeps overloading the server, you should consider to decrease the number of images displayed on a single page.
 
Hi @farang, is it possible to include the preview in latest thread widget generated by [bd] Widget Framework?
Hi @sami simo

It is possible but it might not be so easy. I actually had that working before when I used the [bd] Widget Framework.

To achive that, 2 things must be done.
  1. I need to alter the code so that preview data is fetched when using [bd] Widget Framework. I might find the code for that in an old backup.
  2. You need to manually alter the [bd] Widget Framework templates so that the preview data is displayed.
If You like to give it a try, I can look for that backup .... Please let me know. ;)
 
Back
Top Bottom