<commit_before><?php
namespace wcf\system\database;
use wcf\system\database\editor\MySQLDatabaseEditor;
use wcf\system\database\exception\DatabaseException as GenericDatabaseException;

/**
 * This is the database implementation for MySQL 5.1 or higher using PDO.
 * 
 * @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.database
 * @category	Community Framework
 */
class MySQLDatabase extends Database {
	/**
	 * @inheritDoc
	 */
	protected $editorClassName = MySQLDatabaseEditor::class;
	
	/**
	 * @inheritDoc
	 */
	public function connect() {
		if (!$this->port) $this->port = 3306; // mysql default port
		
		try {
			$driverOptions = [
				\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
			];
			if (!$this->failsafeTest) {
				$driverOptions = [
					\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
				];
			}
			
			// disable prepared statement emulation since MySQL 5.1.17 is the minimum required version
			$driverOptions[\PDO::ATTR_EMULATE_PREPARES] = false;
			
			// throw PDOException instead of dumb false return values
			$driverOptions[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
			
			$this->pdo = new \PDO('mysql:host='.$this->host.';port='.$this->port.';dbname='.$this->database, $this->user, $this->password, $driverOptions);
			$this->setAttributes();
		}
		catch (\PDOException $e) {
			throw new GenericDatabaseException("Connecting to MySQL server '".$this->host."' failed", $e);
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public static function isSupported() {
		return (extension_loaded('PDO') && extension_loaded('pdo_mysql'));
	}
	
	/**
	 * @inheritDoc
	 */
	protected function setAttributes() {
		parent::setAttributes();
		$this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
	}
}
<commit_msg>Fixed MariaDB issue<commit_after><?php
namespace wcf\system\database;
use wcf\system\database\editor\MySQLDatabaseEditor;
use wcf\system\database\exception\DatabaseException as GenericDatabaseException;

/**
 * This is the database implementation for MySQL 5.1 or higher using PDO.
 * 
 * @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.database
 * @category	Community Framework
 */
class MySQLDatabase extends Database {
	/**
	 * @inheritDoc
	 */
	protected $editorClassName = MySQLDatabaseEditor::class;
	
	/**
	 * @inheritDoc
	 */
	public function connect() {
		if (!$this->port) $this->port = 3306; // mysql default port
		
		try {
			$driverOptions = [
				\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
			];
			if (!$this->failsafeTest) {
				$driverOptions = [
					\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
				];
			}
			
			// disable prepared statement emulation since MySQL 5.1.17 is the minimum required version
			$driverOptions[\PDO::ATTR_EMULATE_PREPARES] = false;
			
			// throw PDOException instead of dumb false return values
			$driverOptions[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
			
			$this->pdo = new \PDO('mysql:host='.$this->host.';port='.$this->port.';dbname='.$this->database, $this->user, $this->password, $driverOptions);
			$this->setAttributes();
		}
		catch (\PDOException $e) {
			throw new GenericDatabaseException("Connecting to MySQL server '".$this->host."' failed", $e);
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public static function isSupported() {
		return (extension_loaded('PDO') && extension_loaded('pdo_mysql'));
	}
	
	/**
	 * @inheritDoc
	 */
	protected function setAttributes() {
		parent::setAttributes();
		$this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
	}
	
	/**
	 * @inheritDoc
	 */
	public function getVersion() {
		try {
			$statement = $this->prepareStatement('SELECT VERSION()');
			$statement->execute();
			return $statement->fetchSingleColumn();
		}
		catch (\PDOException $e) {}
		
		return 'unknown';
	}
}

{'fraction_non_alphanumeric': 0.1477055449330784, 'fraction_numerical': 0.009560229445506692, 'mean_word_length': 4.060459492140266, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 40, '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': '6272449', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1346, 'n_words': 286}