mirror of
https://github.com/php/web-pecl.git
synced 2026-03-23 23:02:08 +01:00
Partially refactor database configuration
This patch refactors database handling in certain development scripts
This commit is contained in:
14
.env.dist
14
.env.dist
@@ -2,7 +2,7 @@
|
||||
# the settings in the config directory files.
|
||||
|
||||
# Application environment
|
||||
PECL_ENV=dev
|
||||
PECL_ENV="dev"
|
||||
|
||||
# http or https
|
||||
PECL_SCHEME="http"
|
||||
@@ -10,5 +10,17 @@ PECL_SCHEME="http"
|
||||
# PECL channel host (domain name)
|
||||
PECL_HOST="pecl.localhost"
|
||||
|
||||
# Database username
|
||||
PECL_DB_USERNAME="nobody"
|
||||
|
||||
# Database password
|
||||
PECL_DB_PASSWORD="password"
|
||||
|
||||
# Database host
|
||||
PECL_DB_HOST="localhost"
|
||||
|
||||
# Database name
|
||||
PECL_DB_NAME="pecl"
|
||||
|
||||
# Path where new PECL account requests are sent when requesting a SVN account
|
||||
PECL_MASTER_API_URL="http://pecl.localhost"
|
||||
|
||||
@@ -27,12 +27,17 @@ require_once __DIR__.'/../include/bootstrap.php';
|
||||
|
||||
$svnusers = '/home/pierre/project/pecl/migration/svnusers';
|
||||
$svn_accounts = file($svnusers);
|
||||
function nonl(&$var) {$var = str_replace(["\n","\r", "\r\n"], '', $var);}
|
||||
|
||||
function nonl(&$var) {
|
||||
$var = str_replace(["\n","\r", "\r\n"], '', $var);
|
||||
}
|
||||
|
||||
array_walk($svn_accounts, 'nonl');
|
||||
|
||||
$sql = 'select handle from users where handle NOT IN (select handle from maintains)';
|
||||
|
||||
$dh = new \PDO(PECL_DB_DSN, PECL_DB_USER, PECL_DB_PASSWORD);
|
||||
$dsn = 'mysql:host='.$config->get('db_host').';dbname='.$config->get('db_name');
|
||||
$dh = new \PDO($dsn, $config->get('db_username'), $config->get('db_password'));
|
||||
|
||||
$res = $dh->query($sql);
|
||||
$sql_del = 'DELETE FROM users WHERE handle=';
|
||||
|
||||
@@ -31,5 +31,6 @@ DROP TABLE IF EXISTS
|
||||
elections, election_votes_single, election_votes_multiple, election_votes_abstain, election_results, election_handle_votes, election_choices, election_account_request, zendinfo, trackbacks, apidoc_queue, tagnames, tag_package_link, `comments`, manual_notes
|
||||
';
|
||||
|
||||
$dh = new \PDO(PECL_DB_DSN, PECL_DB_USER, PECL_DB_PASSWORD);
|
||||
$dsn = 'mysql:host='.$config->get('db_host').';dbname='.$config->get('db_name');
|
||||
$dh = new \PDO($dsn, $config->get('db_username'), $config->get('db_password'));
|
||||
$res = $dh->query($sql);
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
require_once __DIR__.'/../include/bootstrap.php';
|
||||
|
||||
$dh = new \PDO(PECL_DB_DSN, PECL_DB_USER, PECL_DB_PASSWORD);
|
||||
$dsn = 'mysql:host='.$config->get('db_host').';dbname='.$config->get('db_name');
|
||||
$dh = new \PDO($dsn, $config->get('db_username'), $config->get('db_password'));
|
||||
|
||||
$sql = "update karma set level='developer' where level='pear.dev' or level='pecl.dev';";
|
||||
$res = $dh->query($sql);
|
||||
|
||||
@@ -44,7 +44,8 @@ IF (cvs_link REGEXP('cvs.php.net\/cvs.php(.*)'),
|
||||
where package_type='pecl' and cvs_link like '%cvs.php.net%';
|
||||
";
|
||||
|
||||
$dh = new \PDO(PECL_DB_DSN, PECL_DB_USER, PECL_DB_PASSWORD);
|
||||
$dsn = 'mysql:host='.$config->get('db_host').';dbname='.$config->get('db_name');
|
||||
$dh = new \PDO($dsn, $config->get('db_username'), $config->get('db_password'));
|
||||
|
||||
$res = $dh->query($sql_movetosvn);
|
||||
if (!$res) {
|
||||
|
||||
@@ -34,6 +34,21 @@ return [
|
||||
// PECL channel URL host (domain name)
|
||||
'host' => isset($_SERVER['PECL_HOST']) ? $_SERVER['PECL_HOST'] : 'pecl.php.net',
|
||||
|
||||
// Database username
|
||||
'db_username' => isset($_SERVER['PECL_DB_USERNAME']) ? $_SERVER['PECL_DB_USERNAME'] : 'nobody',
|
||||
|
||||
// Database password
|
||||
'db_password' => isset($_SERVER['PECL_DB_PASSWORD']) ? $_SERVER['PECL_DB_PASSWORD'] : 'password',
|
||||
|
||||
// Database name
|
||||
'db_name' => isset($_SERVER['PECL_DB_NAME']) ? $_SERVER['PECL_DB_NAME'] : 'pecl',
|
||||
|
||||
// Database host
|
||||
'db_host' => isset($_SERVER['PECL_DB_HOST']) ? $_SERVER['PECL_DB_HOST'] : 'localhost',
|
||||
|
||||
// Database driver
|
||||
'db_driver' => (function_exists('mysql_connect') ? 'mysql' : (function_exists('mysqli_connect') ? 'mysqli' : '')),
|
||||
|
||||
// REST static files directory
|
||||
'rest_dir' => isset($_SERVER['PECL_REST_DIR']) ? $_SERVER['PECL_REST_DIR'] : __DIR__.'/../public_html/rest',
|
||||
|
||||
|
||||
@@ -25,6 +25,18 @@
|
||||
*/
|
||||
|
||||
return [
|
||||
// Database username
|
||||
'db_username' => isset($_SERVER['PECL_DB_USERNAME']) ? $_SERVER['PECL_DB_USERNAME'] : 'pear',
|
||||
|
||||
// Database password
|
||||
'db_password' => isset($_SERVER['PECL_DB_PASSWORD']) ? $_SERVER['PECL_DB_PASSWORD'] : 'pear',
|
||||
|
||||
// Database name
|
||||
'db_name' => isset($_SERVER['PECL_DB_NAME']) ? $_SERVER['PECL_DB_NAME'] : 'pear',
|
||||
|
||||
// Database host
|
||||
'db_host' => isset($_SERVER['PECL_DB_HOST']) ? $_SERVER['PECL_DB_HOST'] : 'localhost',
|
||||
|
||||
// REST static files directory
|
||||
'rest_dir' => isset($_SERVER['PECL_REST_DIR']) ? $_SERVER['PECL_REST_DIR'] : '/var/lib/peclweb/rest',
|
||||
|
||||
|
||||
@@ -38,5 +38,4 @@ if (isset($_SERVER['PEAR_DATABASE_DSN'])) {
|
||||
$driver = 'mysqli';
|
||||
}
|
||||
define('PEAR_DATABASE_DSN', $driver . '://' . PECL_DB_USER . ':' . PECL_DB_PASSWORD. '@' . PECL_DB_HOST. '/' . PECL_DB_NAME);
|
||||
define('PECL_DB_DSN', 'mysql:host=' . PECL_DB_HOST . ';dbname=' . PECL_DB_NAME);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user