Merge branch 'feature-db'

This commit is contained in:
Dmitry Khomutov 2017-01-29 18:55:19 +07:00
commit 46d3428e14
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
45 changed files with 268 additions and 224 deletions

View file

@ -73,7 +73,7 @@ Installing
----------
You will need PHP 5.6+ (with OpenSSL support and enabled functions: `exec()`, `shell_exec()` and `proc_open()`)
with web-server (Nginx or Apache2), MySQL (or MariaDB) database and Composer.
with web-server (Nginx or Apache2), DB (MySQL/MariaDB or PostgreSQL) database and Composer.
* Go to the directory in which you want to install PHP Censor, for example: `/var/www`;
@ -83,7 +83,7 @@ with web-server (Nginx or Apache2), MySQL (or MariaDB) database and Composer.
* Install dependencies using Composer: `composer install`;
* Create empty MySQL database for application;
* Create empty database for application;
* Install Beanstalkd queue (`aptitude install beanstalkd`);
@ -135,7 +135,7 @@ cd /path/to/php-censor
For Phar plugin tests set 'phar.readonly' setting to Off (0) in `php.ini` config. Otherwise tests will be skipped.
For database B8Framework tests create empty 'b8_test' MySQL database on 'localhost' with user/password: `root/root`.
For database B8Framework tests create empty 'b8_test' database on 'localhost' with user/password: `root/root`.
Otherwise database tests will be skipped.
Documentation

View file

@ -1,9 +1,13 @@
b8:
database:
servers:
read: localhost
write: localhost
port: 3306
read:
- host: localhost
port: 3306
write:
- host: localhost
port: 3306
type: mysql
name: php-censor-db
username: php-censor-user
password: php-censor-password

View file

@ -39,7 +39,6 @@
"require": {
"php": ">=5.6.0",
"ext-pdo": "*",
"ext-pdo_mysql": "*",
"swiftmailer/swiftmailer": "5.4.*",
"symfony/yaml": "2.8.*",

View file

@ -53,7 +53,7 @@ As mentioned earlier, PHP Censor is powered by plugins, there are several phases
* `setup` - This phase is designed to initialise the build procedure.
* `test` - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build.
* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any mysql stuff here, you will need to add the mysql credentials to this section as well, as it runs in a separate instance.
* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any DB stuff here, you will need to add the DB credentials to this section as well, as it runs in a separate instance.
* `success` - Called upon success of the `test` phase.
* `failure` - Called upon failure of the `test` phase.
* `fixed` - Called upon success of the `test` phase if the previous build of the branch was a success.

View file

@ -16,5 +16,5 @@ php-censor:
default_user_id: 1
```
where you can get the `default_user_id by` logging into the mysql database and selecting your user ID from the `users` table in
where you can get the `default_user_id` by logging into the database and selecting your user ID from the `users` table in
the PHP Censor database.

View file

@ -8,7 +8,7 @@ What you'll need
* A web server (Nginx or Apache)
* [Composer](https://getcomposer.org/download/)
* [Git](http://git-scm.com/downloads)
* A MySQL server to connect to.
* A DB server to connect to (MySQL/MariaDB or PostgreSQL).
* The following functions need to be enabled: `exec()`, `shell_exec()` and `proc_open()` in php.ini.
* PHP must have OpenSSL support enabled.

View file

@ -6,7 +6,7 @@ Unless already running a build, the worker will pick up and start running new bu
creation.
The worker is the recommended way to run PHP Censor builds. You can run several workers all watching one queue,
allowing jobs to be run simultaneously without the overhead of polling your MySQL database.
allowing jobs to be run simultaneously without the overhead of polling your database.
If you can't run Beanstalkd on your server, or would prefer to run builds on a regular schedule, you should consider
using the [running builds via Cron](workers/cron.md).

View file

@ -17,9 +17,11 @@ class Database extends \PDO
self::$servers['read'] = $settings['servers']['read'];
self::$servers['write'] = $settings['servers']['write'];
self::$details['type'] = $settings['type'];
self::$details['db'] = $settings['name'];
self::$details['user'] = $settings['username'];
self::$details['pass'] = $settings['password'];
self::$initialised = true;
}
@ -42,14 +44,9 @@ class Database extends \PDO
}
if (is_null(self::$connections[$type])) {
if (is_array(self::$servers[$type])) {
// Shuffle, so we pick a random server:
$servers = self::$servers[$type];
shuffle($servers);
} else {
// Only one server was specified
$servers = [self::$servers[$type]];
}
// Shuffle, so we pick a random server:
$servers = self::$servers[$type];
shuffle($servers);
$connection = null;
@ -58,14 +55,16 @@ class Database extends \PDO
// Pull the next server:
$server = array_shift($servers);
if (stristr($server, ':')) {
list($host, $port) = explode(':', $server);
$server = $host . ';port=' . $port;
$dns = self::$details['type'] . ':host=' . $server['host'];
if (isset($server['port'])) {
$dns .= ';port=' . $server['port'];
}
$dns .= ';dbname=' . self::$details['db'];
// Try to connect:
try {
$connection = new self('mysql:host=' . $server . ';dbname=' . self::$details['db'],
$connection = new self(
$dns,
self::$details['user'],
self::$details['pass'],
[
@ -73,7 +72,8 @@ class Database extends \PDO
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_TIMEOUT => 2,
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
]);
]
);
} catch (\PDOException $ex) {
$connection = false;
}
@ -107,4 +107,18 @@ class Database extends \PDO
self::$lastUsed = ['read' => null, 'write' => null];
self::$initialised = false;
}
public function prepareCommon($statement, array $driver_options = [])
{
$quote = '';
if ('mysql' === self::$details['type']) {
$quote = '`';
} elseif ('pgsql' === self::$details['type']) {
$quote = '"';
}
$statement = preg_replace('/{{(.*?)}}/', ($quote . '\1' . $quote), $statement);
return parent::prepare($statement, $driver_options);
}
}

View file

@ -27,8 +27,8 @@ abstract class Store
$manualWheres = [],
$whereType = 'AND'
) {
$query = 'SELECT ' . $this->tableName . '.* FROM ' . $this->tableName;
$countQuery = 'SELECT COUNT(*) AS cnt FROM ' . $this->tableName;
$query = 'SELECT * FROM {{' . $this->tableName . '}}';
$countQuery = 'SELECT COUNT(*) AS {{count}} FROM {{' . $this->tableName . '}}';
$wheres = [];
$params = [];
@ -70,7 +70,7 @@ abstract class Store
}
} else {
$params[] = $item;
$ors[] = $this->fieldCheck($key) . ' ' . $value['operator'] . ' ?';
$ors[] = $key . ' ' . $value['operator'] . ' ?';
}
}
$wheres[] = '(' . implode(' OR ', $ors) . ')';
@ -98,16 +98,15 @@ abstract class Store
}
}
} else {
$wheres[] = $key . ' IN (' . implode(', ',
array_map([Database::getConnection('read'), 'quote'], $value)) . ')';
$wheres[] = $key . ' IN (' . implode(', ', array_map([Database::getConnection('read'), 'quote'], $value)) . ')';
}
}
}
if (count($joins)) {
foreach ($joins as $table => $join) {
$query .= ' LEFT JOIN ' . $table . ' ' . $join['alias'] . ' ON ' . $join['on'] . ' ';
$countQuery .= ' LEFT JOIN ' . $table . ' ' . $join['alias'] . ' ON ' . $join['on'] . ' ';
$query .= ' LEFT JOIN {{' . $table . '}} AS ' . $join['alias'] . ' ON ' . $join['on'] . ' ';
$countQuery .= ' LEFT JOIN {{' . $table . '}} AS ' . $join['alias'] . ' ON ' . $join['on'] . ' ';
}
}
@ -173,16 +172,16 @@ abstract class Store
}
try {
$stmt = Database::getConnection('read')->prepare($countQuery);
$stmt = Database::getConnection('read')->prepareCommon($countQuery);
$stmt->execute($params);
$res = $stmt->fetch(\PDO::FETCH_ASSOC);
$count = (int)$res['cnt'];
$count = (int)$res['count'];
} catch (\PDOException $ex) {
$count = 0;
}
try {
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->execute($params);
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$rtn = [];
@ -232,8 +231,8 @@ abstract class Store
}
if (count($updates)) {
$qs = 'UPDATE ' . $this->tableName . ' SET ' . implode(', ', $updates) . ' WHERE ' . $this->primaryKey . ' = :primaryKey';
$q = Database::getConnection('write')->prepare($qs);
$qs = 'UPDATE {{' . $this->tableName . '}} SET ' . implode(', ', $updates) . ' WHERE {{' . $this->primaryKey . '}} = :primaryKey';
$q = Database::getConnection('write')->prepareCommon($qs);
foreach ($update_params as $update_param) {
$q->bindValue(':' . $update_param[0], $update_param[1]);
@ -266,9 +265,9 @@ abstract class Store
}
if (count($cols)) {
$qs = 'INSERT INTO ' . $this->tableName . ' (' . implode(', ', $cols) . ') VALUES (' . implode(', ',
$qs = 'INSERT INTO {{' . $this->tableName . '}} (' . implode(', ', $cols) . ') VALUES (' . implode(', ',
$values) . ')';
$q = Database::getConnection('write')->prepare($qs);
$q = Database::getConnection('write')->prepareCommon($qs);
if ($q->execute($qParams)) {
$id = !empty($data[$this->primaryKey]) ? $data[$this->primaryKey] : Database::getConnection('write')->lastInsertId();
@ -291,16 +290,13 @@ abstract class Store
$data = $obj->getDataArray();
$q = Database::getConnection('write')->prepare('DELETE FROM ' . $this->tableName . ' WHERE ' . $this->primaryKey . ' = :primaryKey');
$q = Database::getConnection('write')->prepareCommon('DELETE FROM {{' . $this->tableName . '}} WHERE {{' . $this->primaryKey . '}} = :primaryKey');
$q->bindValue(':primaryKey', $data[$this->primaryKey]);
$q->execute();
return true;
}
/**
*
*/
protected function fieldCheck($field)
{
if (empty($field)) {

View file

@ -15,6 +15,7 @@ use PDO;
use b8\Config;
use b8\Store\Factory;
use PHPCensor\Helper\Lang;
use PHPCensor\Model\ProjectGroup;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@ -43,6 +44,7 @@ class InstallCommand extends Command
$this
->setName('php-censor:install')
->addOption('url', null, InputOption::VALUE_OPTIONAL, Lang::get('installation_url'))
->addOption('db-type', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host'))
->addOption('db-host', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host'))
->addOption('db-port', null, InputOption::VALUE_OPTIONAL, Lang::get('db_port'))
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, Lang::get('db_name'))
@ -82,7 +84,7 @@ class InstallCommand extends Command
$output->writeln('');
// ----
// Get MySQL connection information and verify that it works:
// Get DB connection information and verify that it works:
// ----
$connectionVerified = false;
@ -104,8 +106,11 @@ class InstallCommand extends Command
$this->writeConfigFile($conf);
$this->setupDatabase($output);
$admin = $this->getAdminInformation($input, $output);
$this->createAdminUser($admin, $output);
$this->createDefaultGroup($output);
}
/**
@ -127,7 +132,7 @@ class InstallCommand extends Command
}
// Check required extensions are present:
$requiredExtensions = ['PDO', 'pdo_mysql'];
$requiredExtensions = ['PDO'];
foreach ($requiredExtensions as $extension) {
if (!extension_loaded($extension)) {
@ -300,6 +305,11 @@ class InstallCommand extends Command
/** @var $helper QuestionHelper */
$helper = $this->getHelperSet()->get('question');
if (!$dbType = $input->getOption('db-type')) {
$questionType = new Question(Lang::get('enter_db_type'), 'mysql');
$dbType = $helper->ask($input, $output, $questionType);
}
if (!$dbHost = $input->getOption('db-host')) {
$questionHost = new Question(Lang::get('enter_db_host'), 'localhost');
$dbHost = $helper->ask($input, $output, $questionHost);
@ -327,18 +337,24 @@ class InstallCommand extends Command
$dbPass = $helper->ask($input, $output, $questionPass);
}
$db['servers']['read'] = $dbHost;
$db['servers']['write'] = $dbHost;
$db['port'] = $dbPort;
$db['name'] = $dbName;
$db['username'] = $dbUser;
$db['password'] = $dbPass;
$db['servers']['read'] = [[
'host' => $dbHost,
'port' => $dbPort,
]];
$db['servers']['write'] = [[
'host' => $dbHost,
'port' => $dbPort,
]];
$db['type'] = $dbType;
$db['name'] = $dbName;
$db['username'] = $dbUser;
$db['password'] = $dbPass;
return $db;
}
/**
* Try and connect to MySQL using the details provided.
* Try and connect to DB using the details provided.
* @param array $db
* @param OutputInterface $output
* @return bool
@ -347,7 +363,7 @@ class InstallCommand extends Command
{
try {
$pdo = new PDO(
'mysql:host='.$db['servers']['write'].';port='.$db['port'].'dbname='.$db['name'],
$db['type'] . ':host=' . $db['servers']['write'][0]['host'] . ';port=' . $db['servers']['write'][0]['host'] . 'dbname=' . $db['name'],
$db['username'],
$db['password'],
[
@ -413,6 +429,24 @@ class InstallCommand extends Command
}
}
/**
* @param OutputInterface $output
*/
protected function createDefaultGroup($output)
{
try {
$group = new ProjectGroup();
$group->setTitle('Projects');
Factory::getStore('ProjectGroup')->save($group);
$output->writeln('<info>'.Lang::get('default_group_created').'</info>');
} catch (\Exception $ex) {
$output->writeln('<error>'.Lang::get('default_group_failed_to_create').'</error>');
$output->writeln('<error>' . $ex->getMessage() . '</error>');
}
}
protected function reloadConfig()
{
$config = Config::getInstance();

View file

@ -33,14 +33,18 @@ class Application extends BaseApplication
'default_migration_table' => 'migration',
'default_database' => 'php-censor',
'php-censor' => [
'adapter' => 'mysql',
'host' => $databaseSettings['servers']['write'],
'adapter' => $databaseSettings['type'],
'host' => $databaseSettings['servers']['write'][0]['host'],
'name' => $databaseSettings['name'],
'user' => $databaseSettings['username'],
'pass' => $databaseSettings['password'],
],
],
];
if (!empty($databaseSettings['port'])) {
$phinxSettings['environments']['php-censor']['port'] = (integer)$databaseSettings['port'];
}
$phinxConfig = new PhinxConfig($phinxSettings);

View file

@ -309,11 +309,11 @@ Kontrollér venligst nedenstående fejl før du fortsætter.',
'enter_password' => 'Administrator-adgangskode: ',
'enter_app_url' => 'Din PHP Censor URL (eksempelvis "http://php-censor.local"): ',
'enter_db_host' => 'Indtast dit MySQL-hostnavn [localhost]: ',
'enter_db_name' => 'Indtast dit MySQL database-navn [php-censor-db]: ',
'enter_db_user' => 'Indtast dit MySQL-brugernavn [php-censor-user]: ',
'enter_db_pass' => 'Indtast dit MySQL-password: ',
'could_not_connect' => 'PHP Censor kunne ikke forbinde til MySQL med de angivning oplysninger. Forsøg igen.',
'enter_db_host' => 'Indtast dit DB-hostnavn [localhost]: ',
'enter_db_name' => 'Indtast dit DB database-navn [php-censor-db]: ',
'enter_db_user' => 'Indtast dit DB-brugernavn [php-censor-user]: ',
'enter_db_pass' => 'Indtast dit DB-password: ',
'could_not_connect' => 'PHP Censor kunne ikke forbinde til DB med de angivning oplysninger. Forsøg igen.',
'setting_up_db' => 'Indlæser database...',
'user_created' => 'Brugerkonto oprettet!',
'failed_to_create' => 'PHP Censor kunne ikke oprette din administrator-konto.',

View file

@ -332,11 +332,11 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'enter_password' => 'Passwort des Administrators: ',
'enter_app_url' => 'Ihre PHP Censor-URL (z.B. "http://php-censor.local"): ',
'enter_db_host' => 'Bitte geben Sie Ihren MySQL-Host ein [localhost]: ',
'enter_db_name' => 'Bitte geben Sie Ihren MySQL-Namen ein [php-censor-db]: ',
'enter_db_user' => 'Bitte geben Sie Ihren MySQL-Benutzernamen ein [php-censor-user]: ',
'enter_db_pass' => 'Bitte geben Sie Ihr MySQL-Passwort ein: ',
'could_not_connect' => 'PHP Censor konnte wegen folgender Details nicht mit MySQL verbinden. Bitte versuchen Sie es erneut.',
'enter_db_host' => 'Bitte geben Sie Ihren DB-Host ein [localhost]: ',
'enter_db_name' => 'Bitte geben Sie Ihren DB-Namen ein [php-censor-db]: ',
'enter_db_user' => 'Bitte geben Sie Ihren DB-Benutzernamen ein [php-censor-user]: ',
'enter_db_pass' => 'Bitte geben Sie Ihr DB-Passwort ein: ',
'could_not_connect' => 'PHP Censor konnte wegen folgender Details nicht mit DB verbinden. Bitte versuchen Sie es erneut.',
'setting_up_db' => 'Ihre Datenbank wird aufgesetzt... ',
'user_created' => 'Benutzerkonto wurde erstellt!',
'failed_to_create' => 'PHP Censor konnte Ihr Administratorenkonto nicht erstellen.',

View file

@ -311,11 +311,11 @@ Services</a> του Bitbucket αποθετηρίου σας.',
'enter_password' => 'Κωδικός πρόσβασης διαχειριστή: ',
'enter_app_url' => 'Ο URL σύνδεσμος σας για το PHP Censor ("http://php-censor.local" για παράδειγμα): ',
'enter_db_host' => 'Παρακαλώ εισάγετε τον MySQL οικοδεσπότη σας [localhost]: ',
'enter_db_name' => 'Παρακαλώ εισάγετε το όνομα της MySQL βάσης δεδομένων σας [php-censor-db]: ',
'enter_db_user' => 'Παρακαλώ εισάγετε το όνομα χρήστη της MySQL σας [php-censor-user]: ',
'enter_db_pass' => 'Παρακαλώ εισάγετε τον κωδικό χρήστη της MySQL σας: ',
'could_not_connect' => 'Το PHP Censor δεν μπόρεσε να συνδεθεί με την MySQL με τα στοχεία που δώσατε. Παρακαλώ δοκιμάστε ξανά.',
'enter_db_host' => 'Παρακαλώ εισάγετε τον DB οικοδεσπότη σας [localhost]: ',
'enter_db_name' => 'Παρακαλώ εισάγετε το όνομα της DB βάσης δεδομένων σας [php-censor-db]: ',
'enter_db_user' => 'Παρακαλώ εισάγετε το όνομα χρήστη της DB σας [php-censor-user]: ',
'enter_db_pass' => 'Παρακαλώ εισάγετε τον κωδικό χρήστη της DB σας: ',
'could_not_connect' => 'Το PHP Censor δεν μπόρεσε να συνδεθεί με την DB με τα στοχεία που δώσατε. Παρακαλώ δοκιμάστε ξανά.',
'setting_up_db' => 'Γίνεται ρύθμιση της βάσης δεδομένων σας ...',
'user_created' => 'Λογαριασμός χρήστη δημιουργήθηκε!',
'failed_to_create' => 'Το PHP Censor απέτυχε να δημιουργήσει το λογαριασμό διαχειριστή σας.',

View file

@ -362,12 +362,12 @@ PHP Censor',
'enter_password' => 'Admin Password: ',
'enter_app_url' => 'Your PHP Censor URL ("http://php-censor.local" for example): ',
'enter_db_host' => 'Please enter your MySQL host [localhost]: ',
'enter_db_port' => 'Please enter your MySQL port [3306]: ',
'enter_db_name' => 'Please enter your MySQL database name [php-censor-db]: ',
'enter_db_user' => 'Please enter your MySQL username [php-censor-user]: ',
'enter_db_pass' => 'Please enter your MySQL password: ',
'could_not_connect' => 'PHP Censor could not connect to MySQL with the details provided. Please try again.',
'enter_db_host' => 'Please enter your DB host [localhost]: ',
'enter_db_port' => 'Please enter your DB port [3306]: ',
'enter_db_name' => 'Please enter your DB database name [php-censor-db]: ',
'enter_db_user' => 'Please enter your DB username [php-censor-user]: ',
'enter_db_pass' => 'Please enter your DB password: ',
'could_not_connect' => 'PHP Censor could not connect to DB with the details provided. Please try again.',
'setting_up_db' => 'Setting up your database... ',
'user_created' => 'User account created!',
'failed_to_create' => 'PHP Censor failed to create your admin account.',

View file

@ -306,11 +306,11 @@ PHP Censor',
'enter_password' => 'Contraseña de Admin:',
'enter_app_url' => 'La URL de PHP Censor ("Por ejemplo: http://php-censor.local"): ',
'enter_db_host' => 'Por favor, ingresa el servidor MySQL [localhost]: ',
'enter_db_name' => 'Por favor, ingresa el nombre de la base de datos MySQL [php-censor-db]: ',
'enter_db_user' => 'Por favor, ingresa el usuario MySQL [php-censor-user]: ',
'enter_db_pass' => 'Por favor, ingresa la contraseña MySQL: ',
'could_not_connect' => 'PHP Censor no pudo conectarse a MySQL con los datos dados. Por favor, intenta nuevamente.',
'enter_db_host' => 'Por favor, ingresa el servidor DB [localhost]: ',
'enter_db_name' => 'Por favor, ingresa el nombre de la base de datos DB [php-censor-db]: ',
'enter_db_user' => 'Por favor, ingresa el usuario DB [php-censor-user]: ',
'enter_db_pass' => 'Por favor, ingresa la contraseña DB: ',
'could_not_connect' => 'PHP Censor no pudo conectarse a DB con los datos dados. Por favor, intenta nuevamente.',
'setting_up_db' => 'Configurando base de datos... ',
'user_created' => '¡Cuenta de usuario creada!',
'failed_to_create' => 'PHP Censor no pudo crear la cuenta de admin.',

View file

@ -326,11 +326,11 @@ PHP Censor',
'enter_password' => 'Mot de passe de l\'admin: ',
'enter_app_url' => 'Votre URL vers PHP Censor (par exemple "http://php-censor.local"): ',
'enter_db_host' => 'Merci d\'entrer le nom d\'hôte MySQL [localhost]: ',
'enter_db_name' => 'Merci d\'entrer le nom de la base MySQL [php-censor-db]: ',
'enter_db_user' => 'Merci d\'entrer le nom d\'utilisateur MySQL [php-censor-user]: ',
'enter_db_pass' => 'Merci d\'entrer le mot de passe MySQL: ',
'could_not_connect' => 'PHP Censor ne peut pas se connecter à MySQL à partir des informations fournies. Veuillez réessayer..',
'enter_db_host' => 'Merci d\'entrer le nom d\'hôte DB [localhost]: ',
'enter_db_name' => 'Merci d\'entrer le nom de la base DB [php-censor-db]: ',
'enter_db_user' => 'Merci d\'entrer le nom d\'utilisateur DB [php-censor-user]: ',
'enter_db_pass' => 'Merci d\'entrer le mot de passe DB: ',
'could_not_connect' => 'PHP Censor ne peut pas se connecter à DB à partir des informations fournies. Veuillez réessayer..',
'setting_up_db' => 'Paramétrage de la base de données... ',
'user_created' => 'Le compte utilisateur a été créé !',
'failed_to_create' => 'PHP Censor n\'a pas réussi à créer votre compte admin.',

View file

@ -312,11 +312,11 @@ PHP Censor',
'enter_password' => 'Password dell\'amministratore: ',
'enter_app_url' => 'L\'URL di PHP Censor ("http://php-censor.locale" ad esempio): ',
'enter_db_host' => 'Per favore inserisci l\'host MySQL [localhost]: ',
'enter_db_name' => 'Per favore inserisci il nome MySQL [php-censor-db]: ',
'enter_db_user' => 'Per favore inserisci l\'username MySQL [php-censor-user]: ',
'enter_db_pass' => 'Per favore inserisci la password MySQL: ',
'could_not_connect' => 'PHP Censor non può connettersi a MySQL con le informazioni fornite. Per favore prova ancora.',
'enter_db_host' => 'Per favore inserisci l\'host DB [localhost]: ',
'enter_db_name' => 'Per favore inserisci il nome DB [php-censor-db]: ',
'enter_db_user' => 'Per favore inserisci l\'username DB [php-censor-user]: ',
'enter_db_pass' => 'Per favore inserisci la password DB: ',
'could_not_connect' => 'PHP Censor non può connettersi a DB con le informazioni fornite. Per favore prova ancora.',
'setting_up_db' => 'Configurzione del tuo database... ',
'user_created' => 'Account utente creato!',
'failed_to_create' => 'PHP Censor non è riuscito a creare il tuo account amministrativo.',

View file

@ -311,11 +311,11 @@ Gelieve de fouten na te kijken vooraleer verder te gaan.',
'enter_password' => 'Administrator wachtwoord: ',
'enter_app_url' => 'Je PHP Censor URL (bijvoorbeeld "http://php-censor.local"): ',
'enter_db_host' => 'Vul je MySQL host in [localhost]: ',
'enter_db_name' => 'Vul je MySQL databasenaam in [php-censor-db]: ',
'enter_db_user' => 'Vul je MySQL gebruikersnaam in [php-censor-user]: ',
'enter_db_pass' => 'Vul je MySQL watchtwoord in: ',
'could_not_connect' => 'PHP Censor kon met deze gegevens geen verbinding maken met MySQL. Gelieve opnieuw te proberen.',
'enter_db_host' => 'Vul je DB host in [localhost]: ',
'enter_db_name' => 'Vul je DB databasenaam in [php-censor-db]: ',
'enter_db_user' => 'Vul je DB gebruikersnaam in [php-censor-user]: ',
'enter_db_pass' => 'Vul je DB watchtwoord in: ',
'could_not_connect' => 'PHP Censor kon met deze gegevens geen verbinding maken met DB. Gelieve opnieuw te proberen.',
'setting_up_db' => 'Database wordt aangemaakt...',
'user_created' => 'Gebruikersprofiel aangemaakt!',
'failed_to_create' => 'PHP Censor kon je administratorprofiel niet aanmaken.',

View file

@ -312,11 +312,11 @@ Przejrzyj powyższą listę błędów przed kontynuowaniem.',
'enter_password' => 'Hasło Admina: ',
'enter_app_url' => 'URL PHP Censor (na przykład "http://php-censor.local"): ',
'enter_db_host' => 'Wpisz hosta MySQL [host lokalny]: ',
'enter_db_name' => 'Wpisz nazwę bazy danych MySQL [php-censor-db]: ',
'enter_db_user' => 'Wpisz nazwę użytkownika MySQL [php-censor-user]: ',
'enter_db_pass' => 'Wpisz hasło MySQL: ',
'could_not_connect' => 'Z podanymi ustawieniami PHP Censor nie udało się połączyć z MySQL. Spróbuj ponownie.',
'enter_db_host' => 'Wpisz hosta DB [host lokalny]: ',
'enter_db_name' => 'Wpisz nazwę bazy danych DB [php-censor-db]: ',
'enter_db_user' => 'Wpisz nazwę użytkownika DB [php-censor-user]: ',
'enter_db_pass' => 'Wpisz hasło DB: ',
'could_not_connect' => 'Z podanymi ustawieniami PHP Censor nie udało się połączyć z DB. Spróbuj ponownie.',
'setting_up_db' => 'Ustawianie Twojej bazy danych...',
'user_created' => 'Utworzono konto użytkownika!',
'failed_to_create' => 'PHP Censor nie udało się założyc Twojego konta administratora.',

View file

@ -333,11 +333,11 @@ PHP Censor',
'enter_password' => 'Admin Password: ',
'enter_app_url' => 'Your PHP Censor URL ("http://php-censor.local" for example): ',
'enter_db_host' => 'Please enter your MySQL host [localhost]: ',
'enter_db_name' => 'Please enter your MySQL database name [php-censor-db]: ',
'enter_db_user' => 'Please enter your MySQL username [php-censor-user]: ',
'enter_db_pass' => 'Please enter your MySQL password: ',
'could_not_connect' => 'PHP Censor could not connect to MySQL with the details provided. Please try again.',
'enter_db_host' => 'Please enter your DB host [localhost]: ',
'enter_db_name' => 'Please enter your DB database name [php-censor-db]: ',
'enter_db_user' => 'Please enter your DB username [php-censor-user]: ',
'enter_db_pass' => 'Please enter your DB password: ',
'could_not_connect' => 'PHP Censor could not connect to DB with the details provided. Please try again.',
'setting_up_db' => 'Setting up your database... ',
'user_created' => 'User account created!',
'failed_to_create' => 'PHP Censor failed to create your admin account.',

View file

@ -351,12 +351,12 @@ PHP Censor',
'enter_password' => 'Пароль администратора: ',
'enter_app_url' => 'URL-адрес вашего PHP Censor (например: "http://php-censor.local"): ',
'enter_db_host' => 'Пожалуйста, введите хост MySQL [localhost]: ',
'enter_db_port' => 'Пожалуйста, введите порт MySQL [3306]: ',
'enter_db_name' => 'Пожалуйста, введите имя базы данных MySQL [php-censor-db]: ',
'enter_db_user' => 'Пожалуйста, введите пользователя MySQL [php-censor-user]: ',
'enter_db_pass' => 'Пожалуйста, введите пароль MySQL: ',
'could_not_connect' => 'PHP Censor не может подключится к MySQL с переданными параметрами. Пожалуйста, попробуйте еще раз.',
'enter_db_host' => 'Пожалуйста, введите хост DB [localhost]: ',
'enter_db_port' => 'Пожалуйста, введите порт DB [3306]: ',
'enter_db_name' => 'Пожалуйста, введите имя базы данных DB [php-censor-db]: ',
'enter_db_user' => 'Пожалуйста, введите пользователя DB [php-censor-user]: ',
'enter_db_pass' => 'Пожалуйста, введите пароль DB: ',
'could_not_connect' => 'PHP Censor не может подключится к DB с переданными параметрами. Пожалуйста, попробуйте еще раз.',
'setting_up_db' => 'Установка базы данных... ',
'user_created' => 'Аккаунт пользователя создан!',
'failed_to_create' => 'PHP Censor не удалось создать аккаунт администратора.',

View file

@ -311,11 +311,11 @@ PHP Censor',
'enter_password' => 'Пароль адміністратора: ',
'enter_app_url' => 'URL адреса вашого PHP Censor (наприклад, "http://php-censor.local"): ',
'enter_db_host' => 'Будь ласка, введіть хост MySQL [localhost]: ',
'enter_db_name' => 'Будь ласка, введить ім’я бази даних MySQL [php-censor-db]: ',
'enter_db_user' => 'Будь ласка, введить ім’я користувача MySQL [php-censor-user]: ',
'enter_db_pass' => 'Будь ласка, введить ваш пароль MySQL: ',
'could_not_connect' => 'PHP Censor не може підключитися до MySQL із наданими параметрами. Будь ласка, спробуйте ще раз.',
'enter_db_host' => 'Будь ласка, введіть хост DB [localhost]: ',
'enter_db_name' => 'Будь ласка, введить ім’я бази даних DB [php-censor-db]: ',
'enter_db_user' => 'Будь ласка, введить ім’я користувача DB [php-censor-user]: ',
'enter_db_pass' => 'Будь ласка, введить ваш пароль DB: ',
'could_not_connect' => 'PHP Censor не може підключитися до DB із наданими параметрами. Будь ласка, спробуйте ще раз.',
'setting_up_db' => 'Налаштування вашої бази даних...',
'user_created' => 'Аккаунт користувача створено!',
'failed_to_create' => 'PHP Censor не вдалося створити ваш аккаунт адміністратора.',

View file

@ -326,11 +326,11 @@ PHP Censor',
'enter_password' => 'Admin Password: ',
'enter_app_url' => 'Your PHP Censor URL ("http://php-censor.local" for example): ',
'enter_db_host' => 'Please enter your MySQL host [localhost]: ',
'enter_db_name' => 'Please enter your MySQL database name [php-censor-db]: ',
'enter_db_user' => 'Please enter your MySQL username [php-censor-user]: ',
'enter_db_pass' => 'Please enter your MySQL password: ',
'could_not_connect' => 'PHP Censor could not connect to MySQL with the details provided. Please try again.',
'enter_db_host' => 'Please enter your DB host [localhost]: ',
'enter_db_name' => 'Please enter your DB database name [php-censor-db]: ',
'enter_db_user' => 'Please enter your DB username [php-censor-user]: ',
'enter_db_pass' => 'Please enter your DB password: ',
'could_not_connect' => 'PHP Censor could not connect to DB with the details provided. Please try again.',
'setting_up_db' => 'Setting up your database... ',
'user_created' => 'User account created!',
'failed_to_create' => 'PHP Censor failed to create your admin account.',

View file

@ -6,13 +6,6 @@ class FixDatabaseColumns extends AbstractMigration
{
public function up()
{
$dbAdapter = $this->getAdapter();
if ($dbAdapter instanceof \Phinx\Db\Adapter\PdoAdapter) {
$pdo = $dbAdapter->getConnection();
$pdo->exec('SET foreign_key_checks = 0');
}
$build = $this->table('build');
$build->changeColumn('project_id', 'integer', ['null' => false]);
@ -53,11 +46,6 @@ class FixDatabaseColumns extends AbstractMigration
$user->changeColumn('hash', 'string', ['limit' => 250, 'null' => false]);
$user->changeColumn('is_admin', 'integer', ['null' => false, 'default' => 0]);
$user->changeColumn('name', 'string', ['limit' => 250, 'null' => false]);
if ($dbAdapter instanceof \Phinx\Db\Adapter\PdoAdapter) {
$pdo = $dbAdapter->getConnection();
$pdo->exec('SET foreign_key_checks = 1');
}
}
public function down()

View file

@ -9,7 +9,7 @@ class ArchiveProject extends AbstractMigration
$project = $this->table('project');
if (!$project->hasColumn('archived')) {
$project->addColumn('archived', 'boolean', ['default' => 0])->save();
$project->addColumn('archived', 'boolean', ['default' => false])->save();
}
}

View file

@ -1,7 +1,6 @@
<?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class FixColumnTypes extends AbstractMigration
{
@ -9,11 +8,11 @@ class FixColumnTypes extends AbstractMigration
{
$build = $this->table('build');
$build->changeColumn('log', 'text', ['null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM]);
$build->changeColumn('log', 'text', ['null' => true]);
$buildMeta = $this->table('build_meta');
$buildMeta->changeColumn('meta_value', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM]);
$buildMeta->changeColumn('meta_value', 'text', ['null' => false]);
}
public function down()

View file

@ -1,6 +1,5 @@
<?php
use Phinx\Db\Adapter\MysqlAdapter;
use Phinx\Migration\AbstractMigration;
class AddUserProviders extends AbstractMigration
@ -16,12 +15,12 @@ class AddUserProviders extends AbstractMigration
// The provider name
->addColumn('provider_key', 'string', [
'default' => 'internal',
'limit' => MysqlAdapter::TEXT_SMALL
'limit' => 255
])
// A data used by the provider
->addColumn('provider_data', 'string', [
'null' => true,
'limit' => MysqlAdapter::TEXT_SMALL
'limit' => 255
])
->save();
}

View file

@ -13,12 +13,14 @@ class AddProjectGroups extends AbstractMigration
}
if (!$table->hasColumn('title')) {
$table->addColumn('title', 'string', ['limit' => 100, 'null' => false])->save();
$table
->addColumn('title', 'string', ['limit' => 100, 'null' => false])
->save();
$group = new \PHPCensor\Model\ProjectGroup();
/* $group = new \PHPCensor\Model\ProjectGroup();
$group->setTitle('Projects');
\b8\Store\Factory::getStore('ProjectGroup')->save($group);
\b8\Store\Factory::getStore('ProjectGroup')->save($group);*/
}
$table = $this->table('project');

View file

@ -9,11 +9,11 @@ class RemoveUniqueNameIndex extends AbstractMigration
$user = $this->table('user');
if ($user->hasIndex('name', ['unique' => true])) {
$user->removeIndex('name', ['unique' => true])->save();
$user->removeIndex(['name'], ['unique' => true])->save();
}
if (!$user->hasIndex('name', ['unique' => true])) {
$user->addIndex('name', ['unique' => false])->save();
$user->addIndex(['name'], ['unique' => false])->save();
}
}
}

View file

@ -1,7 +1,6 @@
<?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class ErrorsTable extends AbstractMigration
{
@ -34,7 +33,7 @@ class ErrorsTable extends AbstractMigration
}
if (!$table->hasColumn('severity')) {
$table->addColumn('severity', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY])->save();
$table->addColumn('severity', 'integer', ['signed' => false, 'limit' => 255])->save();
}
if (!$table->hasColumn('message')) {

View file

@ -1,17 +1,13 @@
<?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class ProjectTableDefaults extends AbstractMigration
{
public function change()
{
$this->table('project')
->changeColumn('build_config', MysqlAdapter::PHINX_TYPE_TEXT, ['null' => true])
->changeColumn('archived', MysqlAdapter::PHINX_TYPE_INTEGER, [
'length' => MysqlAdapter::INT_TINY,
'default' => 0,
])->save();
->changeColumn('build_config', 'text', ['null' => true])
->save();
}
}

View file

@ -16,7 +16,6 @@ use PHPCensor\Plugin\Util\TestResultParsers\Codeception as Parser;
use PHPCensor\Plugin;
use Symfony\Component\Yaml\Parser as YamlParser;
use PHPCensor\ZeroConfigPluginInterface;
use Psr\Log\LogLevel;
/**
* Codeception Plugin - Enables full acceptance, unit, and functional testing.

View file

@ -38,8 +38,8 @@ class BuildErrorStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `build_error` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build_error}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -62,8 +62,8 @@ class BuildErrorStoreBase extends Store
}
$query = 'SELECT * FROM `build_error` WHERE `build_id` = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build_error}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

View file

@ -38,8 +38,8 @@ class BuildMetaStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `build_meta` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build_meta}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -62,8 +62,8 @@ class BuildMetaStoreBase extends Store
}
$query = 'SELECT * FROM `build_meta` WHERE `project_id` = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build_meta}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
@ -94,8 +94,8 @@ class BuildMetaStoreBase extends Store
}
$query = 'SELECT * FROM `build_meta` WHERE `build_id` = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build_meta}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

View file

@ -38,8 +38,8 @@ class BuildStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `build` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -62,8 +62,8 @@ class BuildStoreBase extends Store
}
$query = 'SELECT * FROM `build` WHERE `project_id` = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
@ -94,8 +94,8 @@ class BuildStoreBase extends Store
}
$query = 'SELECT * FROM `build` WHERE `status` = :status LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{build}} WHERE {{status}} = :status LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':status', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

View file

@ -38,8 +38,8 @@ class ProjectGroupStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `project_group` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{project_group}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {

View file

@ -38,8 +38,8 @@ class ProjectStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `project` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{project}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -62,8 +62,8 @@ class ProjectStoreBase extends Store
}
$query = 'SELECT * FROM `project` WHERE `title` = :title LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{project}} WHERE {{title}} = :title LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':title', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
@ -94,8 +94,8 @@ class ProjectStoreBase extends Store
}
$query = 'SELECT * FROM `project` WHERE `group_id` = :group_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{project}} WHERE {{group_id}} = :group_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':group_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

View file

@ -38,8 +38,8 @@ class UserStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `user` WHERE `id` = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{user}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
@ -67,8 +67,8 @@ class UserStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `user` WHERE `email` = :email LIMIT 1';
$stmt = Database::getConnection()->prepare($query);
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :email LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':email', $value);
if ($stmt->execute()) {
@ -96,8 +96,8 @@ class UserStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `user` WHERE `email` = :value OR `name` = :value LIMIT 1';
$stmt = Database::getConnection()->prepare($query);
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :value OR {{name}} = :value LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':value', $value);
if ($stmt->execute()) {
@ -119,9 +119,8 @@ class UserStoreBase extends Store
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM `user` WHERE `name` = :name LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{user}} WHERE {{name}} = :name LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':name', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

View file

@ -24,8 +24,7 @@ class BuildErrorStore extends BuildErrorStoreBase
*/
public function getErrorsForBuild($buildId, $since = null)
{
$query = 'SELECT * FROM build_error
WHERE build_id = :build';
$query = 'SELECT * FROM {{build_error}} WHERE {{build_id}} = :build';
if (!is_null($since)) {
$query .= ' AND created_date > :since';
@ -33,7 +32,7 @@ class BuildErrorStore extends BuildErrorStoreBase
$query .= ' LIMIT 15000';
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':build', $buildId, \PDO::PARAM_INT);
@ -63,10 +62,10 @@ class BuildErrorStore extends BuildErrorStoreBase
*/
public function getErrorTotalForBuild($buildId)
{
$query = 'SELECT COUNT(*) AS total FROM build_error
WHERE build_id = :build';
$query = 'SELECT COUNT(*) AS {{total}} FROM {{build_error}}
WHERE {{build_id}} = :build';
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':build', $buildId, \PDO::PARAM_INT);

View file

@ -28,11 +28,11 @@ class BuildMetaStore extends BuildMetaStoreBase
*/
public function getErrorsForUpgrade($limit)
{
$query = 'SELECT * FROM build_meta
WHERE meta_key IN (\'phpmd-data\', \'phpcs-data\', \'phpdoccheck-data\', \'technical_debt - data\')
ORDER BY id ASC LIMIT :limit';
$query = 'SELECT * FROM {{build_meta}}
WHERE {{meta_key}} IN (\'phpmd-data\', \'phpcs-data\', \'phpdoccheck-data\', \'technical_debt - data\')
ORDER BY {{id}} ASC LIMIT :limit';
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':limit', $limit, \PDO::PARAM_INT);

View file

@ -30,12 +30,12 @@ class BuildStore extends BuildStoreBase
public function getLatestBuilds($projectId = null, $limit = 5)
{
if (!is_null($projectId)) {
$query = 'SELECT * FROM build WHERE `project_id` = :pid ORDER BY id DESC LIMIT :limit';
$query = 'SELECT * FROM {{build}} WHERE {{project_id}} = :pid ORDER BY {{id}} DESC LIMIT :limit';
} else {
$query = 'SELECT * FROM build ORDER BY id DESC LIMIT :limit';
$query = 'SELECT * FROM {{build}} ORDER BY {{id}} DESC LIMIT :limit';
}
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
if (!is_null($projectId)) {
$stmt->bindValue(':pid', $projectId);
@ -65,8 +65,8 @@ class BuildStore extends BuildStoreBase
*/
public function getLastBuildByStatus($projectId = null, $status = Build::STATUS_SUCCESS)
{
$query = 'SELECT * FROM build WHERE project_id = :pid AND status = :status ORDER BY id DESC LIMIT 1';
$stmt = Database::getConnection('read')->prepare($query);
$query = 'SELECT * FROM {{build}} WHERE {{project_id}} = :pid AND {{status}} = :status ORDER BY {{id}} DESC LIMIT 1';
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':pid', $projectId);
$stmt->bindValue(':status', $status);
@ -87,8 +87,8 @@ class BuildStore extends BuildStoreBase
*/
public function getByProjectAndCommit($projectId, $commitId)
{
$query = 'SELECT * FROM `build` WHERE `project_id` = :project_id AND `commit_id` = :commit_id';
$stmt = Database::getConnection('read')->prepare($query);
$query = 'SELECT * FROM {{build}} WHERE {{project_id}} = :project_id AND {{commit_id}} = :commit_id';
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':project_id', $projectId);
$stmt->bindValue(':commit_id', $commitId);
@ -116,8 +116,8 @@ class BuildStore extends BuildStoreBase
*/
public function getBuildBranches($projectId)
{
$query = 'SELECT DISTINCT `branch` FROM `build` WHERE `project_id` = :project_id';
$stmt = Database::getConnection('read')->prepare($query);
$query = 'SELECT DISTINCT {{branch}} FROM {{build}} WHERE {{project_id}} = :project_id';
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':project_id', $projectId);
if ($stmt->execute()) {
@ -140,8 +140,8 @@ class BuildStore extends BuildStoreBase
public function getMeta($key, $projectId, $buildId = null, $branch = null, $numResults = 1)
{
$query = 'SELECT bm.build_id, bm.meta_key, bm.meta_value
FROM build_meta AS bm
LEFT JOIN build b ON b.id = bm.build_id
FROM {{build_meta}} AS {{bm}}
LEFT JOIN {{build}} AS {{b}} ON b.id = bm.build_id
WHERE bm.meta_key = :key
AND bm.project_id = :projectId';
@ -160,7 +160,7 @@ class BuildStore extends BuildStoreBase
$query .= ' ORDER BY bm.id DESC LIMIT :numResults';
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':key', $key, \PDO::PARAM_STR);
$stmt->bindValue(':projectId', (int)$projectId, \PDO::PARAM_INT);
$stmt->bindValue(':buildId', (int)$buildId, \PDO::PARAM_INT);
@ -199,10 +199,10 @@ class BuildStore extends BuildStoreBase
*/
public function setMeta($projectId, $buildId, $key, $value)
{
$cols = '`project_id`, `build_id`, `meta_key`, `meta_value`';
$query = 'REPLACE INTO build_meta ('.$cols.') VALUES (:projectId, :buildId, :key, :value)';
$cols = '{{project_id}}, {{build_id}}, {{meta_key}}, {{meta_value}}';
$query = 'INSERT INTO {{build_meta}} ('.$cols.') VALUES (:projectId, :buildId, :key, :value)';
$stmt = Database::getConnection('read')->prepare($query);
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':key', $key, \PDO::PARAM_STR);
$stmt->bindValue(':projectId', (int)$projectId, \PDO::PARAM_INT);
$stmt->bindValue(':buildId', (int)$buildId, \PDO::PARAM_INT);

View file

@ -28,8 +28,8 @@ class ProjectStore extends ProjectStoreBase
*/
public function getKnownBranches($projectId)
{
$query = 'SELECT DISTINCT branch from build WHERE project_id = :pid';
$stmt = Database::getConnection('read')->prepare($query);
$query = 'SELECT DISTINCT {{branch}} from {{build}} WHERE {{project_id}} = :pid';
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':pid', $projectId);
if ($stmt->execute()) {
@ -57,8 +57,8 @@ class ProjectStore extends ProjectStoreBase
{
$archived = (integer)$archived;
$query = 'SELECT * FROM `project` WHERE `archived` = :archived ORDER BY `title` ASC';
$stmt = Database::getConnection('read')->prepare($query);
$query = 'SELECT * FROM {{project}} WHERE {{archived}} = :archived ORDER BY {{title}} ASC';
$stmt = Database::getConnection('read')->prepareCommon($query);
$stmt->bindValue(':archived', $archived);
@ -98,8 +98,8 @@ class ProjectStore extends ProjectStoreBase
}
$archived = (integer)$archived;
$query = 'SELECT * FROM `project` WHERE `group_id` = :group_id AND `archived` = :archived ORDER BY title LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepare($query);
$query = 'SELECT * FROM {{project}} WHERE {{group_id}} = :group_id AND {{archived}} = :archived ORDER BY {{title}} LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':group_id', $value);
$stmt->bindValue(':archived', $archived);

View file

@ -13,9 +13,14 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
'b8' => [
'database' => [
'servers' => [
'read' => 'localhost',
'write' => 'localhost',
'read' => [
['host' => 'localhost'],
],
'write' => [
['host' => 'localhost'],
],
],
'type' => 'mysql',
'name' => 'b8_test',
'username' => 'root',
'password' => 'root',
@ -69,9 +74,14 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
'b8' => [
'database' => [
'servers' => [
'read' => 'localhost',
'write' => 'localhost',
'read' => [
['host' => 'localhost'],
],
'write' => [
['host' => 'localhost'],
],
],
'type' => 'mysql',
'name' => 'b8_test_2',
'username' => '',
'password' => '',

View file

@ -58,6 +58,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase
'verifyDatabaseDetails',
'setupDatabase',
'createAdminUser',
'createDefaultGroup',
'writeConfigFile',
'checkRequirements',
])->getMock();
@ -78,6 +79,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase
})
);
$command->expects($this->once())->method('checkRequirements');
$command->expects($this->once())->method('createDefaultGroup');
return $command;
}
@ -100,6 +102,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase
'--db-name' => 'php-censor-db',
'--db-user' => 'php-censor-user',
'--db-pass' => 'php-censor-password',
'--db-type' => 'mysql',
'--admin-mail' => 'admin@php-censor.local',
'--admin-name' => 'admin',
'--admin-pass' => 'admin-password',
@ -144,8 +147,8 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase
$this->executeWithoutParam('--db-host', $dialog);
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['read']);
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['write']);
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['read'][0]['host']);
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['write'][0]['host']);
}
public function testDatabaseNameConfig()