What Do You Need In The Xf2 Xengallery Version? Vote for your choices here: http://www.sonnb.com/threads/what-do-you-need-in-the-xf2-xengallery-version.1539/

Fixed Import Pictures From Thread To Gallery Not Working

Discussion in 'Bug Reports' started by RobinHood, Oct 18, 2016.

  1. RobinHood

    RobinHood Authorized Member Authorized

    I've tried importing pics from a thread to the gallery, and it says it's doing it, but the album is empty.

    Is there any kind of delay on it?
     
  2. sonnb

    sonnb Administrator Staff Member

    Yes, it is. It uses the defer system to do the work then it could a bit delay but not much. Does it show now?
     
  3. RobinHood

    RobinHood Authorized Member Authorized

    Nope, still empty

    One thing to note, it wasn't every image in the thread that I selected, I did deselect a few. I wonder if that made a difference.
     
  4. RobinHood

    RobinHood Authorized Member Authorized

    That's weird, I tried it again, but selecting all the images, and immediately the single image in the 3rd post was included, but not the rest.
     
  5. RobinHood

    RobinHood Authorized Member Authorized

    Something to note, they are event threads, associated with XenAtendo events.

    I just tested another normal thread and it did the same thing, only imported the first image in the thread immediately, nothing else yet.
     
  6. sonnb

    sonnb Administrator Staff Member

    OK. I will try and let you know.
     
    RobinHood likes this.
  7. bt012ss

    bt012ss Authorized Member Authorized

  8. sonnb

    sonnb Administrator Staff Member

  9. bt012ss

    bt012ss Authorized Member Authorized

    No, i don´t use XenAtendo.
     
  10. RobinHood

    RobinHood Authorized Member Authorized

    I don't think it's related to that add on, it's not working on normal threads either.
     
  11. bt012ss

    bt012ss Authorized Member Authorized

    Yes, so it is.
     
  12. radu

    radu Authorized Member Authorized

  13. sonnb

    sonnb Administrator Staff Member

    I found the issue. In the query that fetch the selected attachments, it has following condition:
    Code:
    AND (post.position >= X AND post.position < Y) 
    For the first 5 attachments (It get 5 attachments at a time), X will be 0 and Y will be 5. Therefore if the attachments are not from post 1 -> 5, no attachments returned -> return -> nothing imported.

    The above condition must be removed.
     
    RobinHood likes this.
  14. RobinHood

    RobinHood Authorized Member Authorized

  15. bt012ss

    bt012ss Authorized Member Authorized

    Hi, where can i find this code to remove it?
     
  16. sonnb

    sonnb Administrator Staff Member

    Here is how to fix the issue:

    Open the file: library/sonnb/XenGallery/Model/Attachment

    Replace the current getAttachmentsForXenGalleryByAttachmentIds method code with the following one:
    PHP:
    public function getAttachmentsForXenGalleryByAttachmentIds($attachmentIds, array $fetchOptions = array())
        {
            
    $limitOptions $this->prepareLimitFetchOptions($fetchOptions);

            return 
    $this->fetchAllKeyed($this->limitQueryResults("
                    SELECT attachment.*, attachment_data.*, post.username, post.user_id
                    FROM xf_attachment AS attachment
                        LEFT JOIN xf_attachment_data AS attachment_data
                            ON (attachment.data_id = attachment_data.data_id)
                        LEFT JOIN xf_post AS post
                            ON (attachment.content_id = post.post_id)
                    WHERE attachment.attachment_id IN ("
    $this->_getDb()->quote($attachmentIds) .")
                        AND attachment.content_type = 'post'
                        AND post.message_state = 'visible'
                    ORDER BY attachment.attachment_id ASC"
    $limitOptions['limit'], $limitOptions['offset']), 'attachment_id');
        }
     
  17. bt012ss

    bt012ss Authorized Member Authorized

    Well done, it works for me. Thank you :D
     

Share This Page