magefan / module-blog

Magento 2 Blog Extension is a solution that helps you to create a blog on Magento and manage posts,categories, tags, authors, and comments.
https://magefan.com/magento2-blog-extension
Other
263 stars 135 forks source link

Comment collection store filter causing error in 2.3.2 #269

Closed Kivike closed 5 years ago

Kivike commented 5 years ago

\Magefan\Blog\Model\ResourceModel\Comment has method addStoreFilter, which is now called because of this change: https://devdocs.magento.com/guides/v2.3/release-notes/ReleaseNotes2.3.2Commerce.html#admingws

However, the collection doesn't join any table that would match 'store_table.store_id', causing SQL error: Unknown column 'store_table.store_id' in 'where clause'

This causes admin login to not work at all for users with limited access.

One possible fix is to add this method to the collection class:


   /**
     * Join store relation table if there is store filter
     *
     * @return void
     */
    protected function _renderFiltersBefore()
    {
        if ($this->getFilter('store') && !$this->getFlag('store_filtered')) {
            $this->getSelect()->join(
                ['store_table' => $this->getTable('magefan_blog_post_store')],
                'main_table.post_id = store_table.post_id',
                []
            )->group(
                'main_table.comment_id'
            );
            $this->setFlag('store_filtered', true);
        }
        parent::_renderFiltersBefore();
    }
magefan commented 5 years ago

Hello @Kivike, thank you for your report and for the suggestion, we have added changes to the master branch https://github.com/magefan/module-blog/commit/1d3a6b5af806af3c54305b9357cee1279650dbf8 . This modification will be present in the next release of Magento 2 Blog extension.