Skip to content

Commit ff5fe5d

Browse files
author
Till Brehm
committed
Fixed PHP 7.4 compatibility problem with limit query in mysql database lib.
1 parent 85f9d1d commit ff5fe5d

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

install/lib/mysql.lib.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,15 @@ public function query($sQuery = '') {
286286
public function queryOneRecord($sQuery = '') {
287287

288288
$aArgs = func_get_args();
289-
290-
if(!preg_match('/limit \d+\s*,\s*\d+$/i', $sQuery)) $sQuery .= ' LIMIT 0,1';
291-
292-
$oResult = call_user_func_array(array(&$this, 'query'), $aArgs);
289+
if(!empty($aArgs)) {
290+
$sQuery = array_shift($aArgs);
291+
if($sQuery && !preg_match('/limit \d+(\s*,\s*\d+)?$/i', $sQuery)) {
292+
$sQuery .= ' LIMIT 0,1';
293+
}
294+
array_unshift($aArgs, $sQuery);
295+
}
296+
297+
$oResult = call_user_func_array([&$this, 'query'], $aArgs);
293298
if(!$oResult) return null;
294299

295300
$aReturn = $oResult->get();

interface/lib/classes/db_mysql.inc.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,15 @@ public function query($sQuery = '') {
356356
public function queryOneRecord($sQuery = '') {
357357

358358
$aArgs = func_get_args();
359-
360-
if(!preg_match('/limit \d+\s*(,\s*\d+)?$/i', $sQuery)) $sQuery .= ' LIMIT 0,1';
361-
362-
$oResult = call_user_func_array(array(&$this, 'query'), $aArgs);
359+
if(!empty($aArgs)) {
360+
$sQuery = array_shift($aArgs);
361+
if($sQuery && !preg_match('/limit \d+(\s*,\s*\d+)?$/i', $sQuery)) {
362+
$sQuery .= ' LIMIT 0,1';
363+
}
364+
array_unshift($aArgs, $sQuery);
365+
}
366+
367+
$oResult = call_user_func_array([&$this, 'query'], $aArgs);
363368
if(!$oResult) return null;
364369

365370
$aReturn = $oResult->get();

interface/lib/classes/getconf.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function get_security_config($section = '') {
6565
} else {
6666
$app->uses('ini_parser');
6767
$security_config_path = '/usr/local/ispconfig/security/security_settings.ini';
68-
if(!is_file($security_config_path)) $security_config_path = realpath(ISPC_ROOT_PATH.'/../security/security_settings.ini');
68+
if(!is_readable($security_config_path)) $security_config_path = realpath(ISPC_ROOT_PATH.'/../security/security_settings.ini');
6969
$this->security_config = $app->ini_parser->parse_ini_string(file_get_contents($security_config_path));
7070

7171
return ($section == '') ? $this->security_config : $this->security_config[$section];

server/lib/classes/db_mysql.inc.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,17 @@ public function query($sQuery = '') {
354354
* @return array result row or NULL if none found
355355
*/
356356
public function queryOneRecord($sQuery = '') {
357-
357+
358358
$aArgs = func_get_args();
359-
if(!preg_match('/limit \d+\s*(,\s*\d+)?$/i', $sQuery)) $sQuery .= ' LIMIT 0,1';
360-
361-
$oResult = call_user_func_array(array(&$this, 'query'), $aArgs);
359+
if(!empty($aArgs)) {
360+
$sQuery = array_shift($aArgs);
361+
if($sQuery && !preg_match('/limit \d+(\s*,\s*\d+)?$/i', $sQuery)) {
362+
$sQuery .= ' LIMIT 0,1';
363+
}
364+
array_unshift($aArgs, $sQuery);
365+
}
366+
367+
$oResult = call_user_func_array([&$this, 'query'], $aArgs);
362368
if(!$oResult) return null;
363369

364370
$aReturn = $oResult->get();

0 commit comments

Comments
 (0)