Fixed Wrong select if no watchUserId is provided

TickTackk

Well-known member
In Category model under prepareCategoryFetchOptions function
PHP:
if (isset($fetchOptions['watchUserId']))
        {
            if (!empty($fetchOptions['watchUserId']))
            {
                $selectFields .= ',
                    IF(category_watch.user_id IS NULL, 0, 1) AS category_is_watched';
                $joinTables .= '
                    LEFT JOIN xf_resource_category_watch AS category_watch
                        ON (category_watch.resource_category_id = resource_category.resource_category_id
                        AND category_watch.user_id = ' . $this->_getDb()->quote($fetchOptions['watchUserId']) . ')';
            }
            else
            {
                $selectFields .= ',
                    0 AS forum_is_watched';
            }
        }

should be
PHP:
if (isset($fetchOptions['watchUserId']))
        {
            if (!empty($fetchOptions['watchUserId']))
            {
                $selectFields .= ',
                    IF(category_watch.user_id IS NULL, 0, 1) AS category_is_watched';
                $joinTables .= '
                    LEFT JOIN xf_resource_category_watch AS category_watch
                        ON (category_watch.resource_category_id = resource_category.resource_category_id
                        AND category_watch.user_id = ' . $this->_getDb()->quote($fetchOptions['watchUserId']) . ')';
            }
            else
            {
                $selectFields .= ',
                    0 AS category_is_watched';
            }
        }
 
Back
Top Bottom