<?php

namespace wcf\data\article;

use wcf\data\tag\Tag;
use wcf\system\tagging\TagEngine;

/**
 * Represents a list of tagged articles.
 *
 * @author  Marcel Werk
 * @copyright   2001-2019 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\Data\Article
 * @since   3.0
 */
class TaggedArticleList extends AccessibleArticleList
{
    /**
     * Creates a new CategoryArticleList object.
     *
     * @param Tag|Tag[] $tags
     */
    public function __construct($tags)
    {
        parent::__construct();

        $this->sqlOrderBy = 'article.time ' . ARTICLE_SORT_ORDER;

        $tagIDs = TagEngine::getInstance()->getTagIDs($tags);
        $this->getConditionBuilder()->add("article.articleID IN (
            SELECT  articleID
            FROM    wcf" . WCF_N . "_article_content
            WHERE   articleContentID IN (
                SELECT      objectID
                FROM        wcf" . WCF_N . "_tag_to_object
                WHERE       objectTypeID = ?
                        AND tagID IN (?)
                GROUP BY    objectID
                HAVING      COUNT(objectID) = ?
            )
        )", [
            TagEngine::getInstance()->getObjectTypeID('com.woltlab.wcf.article'),
            $tagIDs,
            \count($tagIDs),
        ]);
    }
}

<?php

namespace wcf\data\article;

use wcf\data\tag\Tag;
use wcf\system\tagging\TagEngine;

/**
 * Represents a list of tagged articles.
 *
 * @author  Marcel Werk
 * @copyright   2001-2019 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\Data\Article
 * @since   3.0
 */
class TaggedArticleList extends AccessibleArticleList
{
    /**
     * Creates a new CategoryArticleList object.
     *
     * @param Tag|Tag[] $tags
     */
    public function __construct($tags)
    {
        parent::__construct();

        $this->sqlOrderBy = 'article.time ' . ARTICLE_SORT_ORDER;

        $subselect = TagEngine::getInstance()->getSubselectForObjectsByTags(
            'com.woltlab.wcf.article',
            $tags
        );
        $this->getConditionBuilder()->add("article.articleID IN (
            SELECT  articleID
            FROM    wcf" . WCF_N . "_article_content
            WHERE   articleContentID IN ({$subselect['sql']})
        )", $subselect['parameters']);
    }
}

Make use of TagEngine::getSubselectForObjectsByTags() in TaggedArticleList
Make use of TagEngine::getSubselectForObjectsByTags() in TaggedArticleList

Commit c9613f130106f74853fbe9a50f06c00208106b8c is fun.

It renamed the getSqlForObjectsByTags() method that was previously used in
TaggedArticleList to the current name getSubselectForObjectsByTags() and fixed
a bug in the method that prevented it from working correctly.

At the same time the commit edited TaggedArticleList to no longer use this
method and instead copied over the logic.

I'm not sure what exactly happened during the development of that commit, but
we simply should use this (fixed) method.
