aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-09-11 11:43:43 +0200
committerGravatar GitHub <noreply@github.com> 2016-09-11 11:43:43 +0200
commitc3589cac2d41501af1bd916c4689cf1ea4b58038 (patch)
treeee04434c9668d25c98ae7351994e35c568c0d3c3
parent12d21c4fe8087f8536a1679cad275025a4400d45 (diff)
parent63b567b2c306f584652b3ba500a5ea4e74512aa4 (diff)
Merge pull request #1244 from Alkarex/MySQL-port
Support custom MySQL ports
-rw-r--r--CHANGELOG.md2
-rw-r--r--app/install.php2
-rw-r--r--lib/Minz/ModelPdo.php6
3 files changed, 8 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fca908ff0..b3c46bdb6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## 2016-XX-XX FreshRSS 1.6.0-dev
+* Features
+ * Support custom ports `localhost:3306` for database servers [#1241](https://github.com/FreshRSS/FreshRSS/issues/1241)
* Security
* Prevent `<a target="_blank">` attacks with `window.opener` [#1245](https://github.com/FreshRSS/FreshRSS/issues/1245)
* UI
diff --git a/app/install.php b/app/install.php
index 62695ceb6..dad3535dc 100644
--- a/app/install.php
+++ b/app/install.php
@@ -716,7 +716,7 @@ function printStep3() {
<div class="form-group">
<label class="group-name" for="host"><?php echo _t('install.bdd.host'); ?></label>
<div class="group-controls">
- <input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" />
+ <input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}(:[0-9]{2,5})?" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" />
</div>
</div>
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index 845aecaae..f82045df9 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -53,13 +53,17 @@ class Minz_ModelPdo {
self::$sharedCurrentUser = $currentUser;
$driver_options = isset($conf->db['pdo_options']) && is_array($conf->db['pdo_options']) ? $conf->db['pdo_options'] : array();
+ $dbServer = parse_url('db://' . $db['host']);
try {
$type = $db['type'];
if ($type === 'mysql') {
- $string = 'mysql:host=' . $db['host']
+ $string = 'mysql:host=' . $dbServer['host']
. ';dbname=' . $db['base']
. ';charset=utf8mb4';
+ if (!empty($dbServer['port'])) {
+ $string .= ';port=' . $dbServer['port'];
+ }
$driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8mb4';
$this->prefix = $db['prefix'] . $currentUser . '_';
} elseif ($type === 'sqlite') {