Skip to content

Commit e51e43f

Browse files
committed
Prepare JSONDB for merge
1 parent c5d55f5 commit e51e43f

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/JSONDB/JSONDB.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ public function createServer($path, $username, $password, $connect = FALSE)
302302
}
303303
fclose($htaccess);
304304

305-
$htpasswd = fopen(realpath(dirname(__DIR__) . '/config/.htpasswd'), 'a+');
306-
fwrite($htpasswd, $username . ':' . crypt($password, NULL) . "\n");
307-
fclose($htpasswd);
308305

309306
$this->config->addUser(realpath($path), $username, $password);
310307

@@ -382,7 +379,6 @@ public function connect($server, $username, $password, $database = NULL)
382379
throw new Exception("JSONDB Error: User's authentication failed for user \"{$username}\" on server \"{$server}\". Access denied.");
383380
}
384381

385-
$this->server = $server;
386382
$this->database = $database;
387383
$this->username = $username;
388384
$this->password = $password;
@@ -1009,7 +1005,7 @@ protected function _replace($data)
10091005
}
10101006

10111007
$i = 0;
1012-
foreach ($current_data as &$array_data) {
1008+
foreach ((array)$current_data as &$array_data) {
10131009
$array_data = array_key_exists($i, $insert) ? array_replace($array_data, $insert[$i]) : $array_data;
10141010
$i++;
10151011
}
@@ -1019,13 +1015,12 @@ protected function _replace($data)
10191015
$pk_error = FALSE;
10201016
$non_pk = array_flip(array_diff($data['prototype'], $data['properties']['primary_keys']));
10211017
$i = 0;
1022-
foreach ($insert as $array_data) {
1023-
$array_data = array_diff_key($array_data, $non_pk);
1018+
foreach ((array)$insert as $array) {
1019+
$array = array_diff_key($array, $non_pk);
10241020
foreach (array_slice($insert, $i + 1) as $value) {
10251021
$value = array_diff_key($value, $non_pk);
1026-
$pk_error = $pk_error || ($value === $array_data);
1022+
$pk_error = $pk_error || ($value === $array);
10271023
if ($pk_error) {
1028-
exit;
10291024
$values = implode(', ', $value);
10301025
$keys = implode(', ', $data['properties']['primary_keys']);
10311026
throw new Exception("JSONDB Error: Can't replace value. Duplicate values \"{$values}\" for primary keys \"{$keys}\".");
@@ -1037,11 +1032,11 @@ protected function _replace($data)
10371032
$uk_error = FALSE;
10381033
$i = 0;
10391034
foreach ((array)$data['properties']['unique_keys'] as $uk) {
1040-
foreach ($insert as $array_data) {
1041-
$array_data = array_intersect_key($array_data, array($uk => $uk));
1035+
foreach ((array)$insert as $array) {
1036+
$array = array_intersect_key($array, array($uk => $uk));
10421037
foreach (array_slice($insert, $i + 1) as $value) {
10431038
$value = array_intersect_key($value, array($uk => $uk));
1044-
$uk_error = $uk_error || (!empty($item[$uk]) && ($value === $array_data));
1039+
$uk_error = $uk_error || (!empty($item[$uk]) && ($value === $array));
10451040
if ($uk_error) {
10461041
throw new Exception("JSONDB Error: Can't replace value. Duplicate values \"{$value[$uk]}\" for unique key \"{$uk}\".");
10471042
}

0 commit comments

Comments
 (0)