<commit_before><?php
namespace wcf\system\search;
use wcf\data\article\category\ArticleCategory;
use wcf\data\article\content\SearchResultArticleContent;
use wcf\data\article\content\SearchResultArticleContentList;
use wcf\data\category\CategoryNodeTree;
use wcf\form\IForm;
use wcf\form\SearchForm;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\page\PageLocationManager;
use wcf\system\WCF;
use wcf\util\ArrayUtil;

/**
 * An implementation of ISearchableObjectType for searching in articles.
 *
 * @author      <NAME>
 * @copyright	2001-2016 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.search
 * @category	Community Framework
 * @since       2.2
 */
class ArticleSearch extends AbstractSearchableObjectType {
	/**
	 * ids of the selected categories
	 * @var	integer[]
	 */
	public $articleCategoryIDs = [];
	
	/**
	 * message data cache
	 * @var	SearchResultArticleContent[]
	 */
	public $messageCache = [];
	
	/**
	 * @inheritDoc
	 */
	public function cacheObjects(array $objectIDs, array $additionalData = null) {
		$list = new SearchResultArticleContentList();
		$list->setObjectIDs($objectIDs);
		$list->readObjects();
		foreach ($list->getObjects() as $content) {
			$this->messageCache[$content->articleContentID] = $content;
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public function getObject($objectID) {
		if (isset($this->messageCache[$objectID])) return $this->messageCache[$objectID];
		return null;
	}
	
	/**
	 * @inheritDoc
	 */
	public function getTableName() {
		return 'wcf'.WCF_N.'_article_content';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getIDFieldName() {
		return $this->getTableName().'.articleContentID';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getSubjectFieldName() {
		return $this->getTableName().'.title';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getUsernameFieldName() {
		return 'wcf'.WCF_N.'_article.username';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getTimeFieldName() {
		return 'wcf'.WCF_N.'_article.time';
	}
	
	/** @noinspection PhpMissingParentCallCommonInspection */
	/**
	 * @inheritDoc
	 */
	public function getConditions(IForm $form = null) {
		// accessible category ids
		if (isset($_POST['articleCategoryIDs'])) $this->articleCategoryIDs = ArrayUtil::toIntegerArray($_POST['articleCategoryIDs']);
		$accessibleCategoryIDs = ArticleCategory::getAccessibleCategoryIDs();
		if (!empty($this->articleCategoryIDs)) {
			$this->articleCategoryIDs = array_intersect($accessibleCategoryIDs, $this->articleCategoryIDs);
		}
		else {
			$this->articleCategoryIDs = $accessibleCategoryIDs;
		}
		if (empty($this->articleCategoryIDs)) {
			throw new PermissionDeniedException();
		}
		
		$conditionBuilder = new PreparedStatementConditionBuilder();
		$conditionBuilder->add('wcf'.WCF_N.'_article.categoryID IN (?) AND wcf'.WCF_N.'_article.publicationStatus = ?', [$this->articleCategoryIDs, 1]);
		
		return $conditionBuilder;
	}
	
	/** @noinspection PhpMissingParentCallCommonInspection */
	/**
	 * @inheritDoc
	 */
	public function getJoins() {
		return 'JOIN wcf'.WCF_N.'_article ON (wcf'.WCF_N.'_article.articleID = '.$this->getTableName().'.articleID)';
	}<commit_msg>Changed type of join in article search implementation<commit_after><?php
namespace wcf\system\search;
use wcf\data\article\category\ArticleCategory;
use wcf\data\article\content\SearchResultArticleContent;
use wcf\data\article\content\SearchResultArticleContentList;
use wcf\data\category\CategoryNodeTree;
use wcf\form\IForm;
use wcf\form\SearchForm;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\page\PageLocationManager;
use wcf\system\WCF;
use wcf\util\ArrayUtil;

/**
 * An implementation of ISearchableObjectType for searching in articles.
 *
 * @author      <NAME>
 * @copyright	2001-2016 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.search
 * @category	Community Framework
 * @since       2.2
 */
class ArticleSearch extends AbstractSearchableObjectType {
	/**
	 * ids of the selected categories
	 * @var	integer[]
	 */
	public $articleCategoryIDs = [];
	
	/**
	 * message data cache
	 * @var	SearchResultArticleContent[]
	 */
	public $messageCache = [];
	
	/**
	 * @inheritDoc
	 */
	public function cacheObjects(array $objectIDs, array $additionalData = null) {
		$list = new SearchResultArticleContentList();
		$list->setObjectIDs($objectIDs);
		$list->readObjects();
		foreach ($list->getObjects() as $content) {
			$this->messageCache[$content->articleContentID] = $content;
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public function getObject($objectID) {
		if (isset($this->messageCache[$objectID])) return $this->messageCache[$objectID];
		return null;
	}
	
	/**
	 * @inheritDoc
	 */
	public function getTableName() {
		return 'wcf'.WCF_N.'_article_content';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getIDFieldName() {
		return $this->getTableName().'.articleContentID';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getSubjectFieldName() {
		return $this->getTableName().'.title';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getUsernameFieldName() {
		return 'wcf'.WCF_N.'_article.username';
	}
	
	/**
	 * @inheritDoc
	 */
	public function getTimeFieldName() {
		return 'wcf'.WCF_N.'_article.time';
	}
	
	/** @noinspection PhpMissingParentCallCommonInspection */
	/**
	 * @inheritDoc
	 */
	public function getConditions(IForm $form = null) {
		// accessible category ids
		if (isset($_POST['articleCategoryIDs'])) $this->articleCategoryIDs = ArrayUtil::toIntegerArray($_POST['articleCategoryIDs']);
		$accessibleCategoryIDs = ArticleCategory::getAccessibleCategoryIDs();
		if (!empty($this->articleCategoryIDs)) {
			$this->articleCategoryIDs = array_intersect($accessibleCategoryIDs, $this->articleCategoryIDs);
		}
		else {
			$this->articleCategoryIDs = $accessibleCategoryIDs;
		}
		if (empty($this->articleCategoryIDs)) {
			throw new PermissionDeniedException();
		}
		
		$conditionBuilder = new PreparedStatementConditionBuilder();
		$conditionBuilder->add('wcf'.WCF_N.'_article.categoryID IN (?) AND wcf'.WCF_N.'_article.publicationStatus = ?', [$this->articleCategoryIDs, 1]);
		
		return $conditionBuilder;
	}
	
	/** @noinspection PhpMissingParentCallCommonInspection */
	/**
	 * @inheritDoc
	 */
	public function getJoins() {
		return 'INNER JOIN wcf'.WCF_N.'_article ON (wcf'.WCF_N.'_article.articleID = '.$this->getTableName().'.articleID)';
	}
{'fraction_non_alphanumeric': 0.14187779433681072, 'fraction_numerical': 0.003278688524590164, 'mean_word_length': 4.606516290726817, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2276064', 'n_tokens_mistral': 2270, 'n_tokens_neox': 2055, 'n_words': 382}