Explorar el Código

Support custom MySQL ports

https://github.com/FreshRSS/FreshRSS/issues/1241
Alexandre Alapetite hace 9 años
padre
commit
0564f5e1c4
Se han modificado 2 ficheros con 6 adiciones y 2 borrados
  1. 1 1
      app/install.php
  2. 5 1
      lib/Minz/ModelPdo.php

+ 1 - 1
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>
 

+ 5 - 1
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') {