fix issue in PhpHelper::trimArray() returning an empty array, fixes #751
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -374,7 +374,7 @@ class PhpHelper
|
||||
$returnval = array();
|
||||
if (is_array($source)) {
|
||||
$source = array_map('trim', $source);
|
||||
$source = array_filter($source, function ($value) {
|
||||
$returnval = array_filter($source, function ($value) {
|
||||
return $value !== '';
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -242,8 +242,8 @@ class Store
|
||||
$mysql_access_host_array = array_map('trim', explode(',', Settings::Get('system.mysql_access_host')));
|
||||
$mysql_access_host_array[] = $newfieldvalue;
|
||||
$mysql_access_host_array = array_unique(\Froxlor\PhpHelper::arrayTrim($mysql_access_host_array));
|
||||
$mysql_access_host = implode(',', $mysql_access_host_array);
|
||||
\Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array);
|
||||
$mysql_access_host = implode(',', $mysql_access_host_array);
|
||||
Settings::Set('system.mysql_access_host', $mysql_access_host);
|
||||
}
|
||||
|
||||
@@ -293,9 +293,11 @@ class Store
|
||||
'cleanMySQLAccessHost'
|
||||
), $mysql_access_host_array);
|
||||
|
||||
$mysql_access_host_array = array_unique($mysql_access_host_array);
|
||||
$mysql_access_host_array = array_unique(\Froxlor\PhpHelper::arrayTrim($mysql_access_host_array));
|
||||
$newfieldvalue = implode(',', $mysql_access_host_array);
|
||||
\Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array);
|
||||
$mysql_access_host = implode(',', $mysql_access_host_array);
|
||||
Settings::Set('system.mysql_access_host', $mysql_access_host);
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\Admins;
|
||||
use Froxlor\Api\Commands\Customers;
|
||||
use Froxlor\Api\Commands\Mysqls;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings\Store;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,6 +17,7 @@ use Froxlor\Database\Database;
|
||||
* @covers \Froxlor\Api\Commands\Admins
|
||||
* @covers \Froxlor\Database\DbManager
|
||||
* @covers \Froxlor\Database\Manager\DbManagerMySQL
|
||||
* @covers \Froxlor\Settings\Store
|
||||
*/
|
||||
class MysqlsTest extends TestCase
|
||||
{
|
||||
@@ -183,6 +186,24 @@ class MysqlsTest extends TestCase
|
||||
*
|
||||
* @depends testCustomerMysqlsAdd
|
||||
*/
|
||||
public function testStoreSettingIpAddress()
|
||||
{
|
||||
// this settings test is here because it directly changes mysql users / privileges
|
||||
$fielddata = array(
|
||||
'label' => 'serversettings.ipaddress',
|
||||
'settinggroup' => 'system',
|
||||
'varname' => 'ipaddress'
|
||||
);
|
||||
Store::storeSettingIpAddress('system_system_ipaddress', $fielddata, '82.149.225.47');
|
||||
|
||||
$mysql_access_hosts = Settings::Get('system.mysql_access_host');
|
||||
$this->assertTrue(strpos($mysql_access_hosts, '82.149.225.47') !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testStoreSettingIpAddress
|
||||
*/
|
||||
public function testGetAllSqlUsers()
|
||||
{
|
||||
\Froxlor\Database\Database::needRoot(true);
|
||||
|
||||
Reference in New Issue
Block a user