Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ff8aa195b | ||
|
|
f176d12a1e | ||
|
|
f974b15f78 | ||
|
|
91fad09367 | ||
|
|
e8fe1feda5 | ||
|
|
23fd78e5c8 | ||
|
|
6cdede2997 | ||
|
|
ace02b14d8 | ||
|
|
58e916d314 | ||
|
|
4f6d85f4da | ||
|
|
cd45590a72 | ||
|
|
4d42da201c |
@@ -25,7 +25,7 @@
|
||||
"phpstan/phpdoc-parser": "^2.0",
|
||||
"phpstan/phpstan-deprecation-rules": "^2.0",
|
||||
"phan/phan": "^5.4",
|
||||
"egrajp/smarty-extended": "^4.3",
|
||||
"egrajp/smarty-extended": "^5.4",
|
||||
"gullevek/dotenv": "dev-master",
|
||||
"phpunit/phpunit": "^9"
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
9.26.3
|
||||
9.26.7
|
||||
|
||||
@@ -1532,7 +1532,7 @@ class Login
|
||||
$this->acl['page'] = $_SESSION['LOGIN_PAGES_ACL_LEVEL'][$this->page_name];
|
||||
}
|
||||
|
||||
$this->acl['unit_id'] = null;
|
||||
$this->acl['unit_cuid'] = null;
|
||||
$this->acl['unit_name'] = null;
|
||||
$this->acl['unit_uid'] = null;
|
||||
$this->acl['unit'] = [];
|
||||
@@ -3217,7 +3217,7 @@ HTML;
|
||||
* @return int|null same edit access id if ok
|
||||
* or the default edit access id
|
||||
* if given one is not valid
|
||||
* @deprecated Please switch to using edit access cuid check with ->loginCheckEditAccessValidCuid()
|
||||
* @#deprecated Please switch to using edit access cuid check with ->loginCheckEditAccessValidCuid()
|
||||
*/
|
||||
public function loginCheckEditAccessId(?int $edit_access_id): ?int
|
||||
{
|
||||
@@ -3290,10 +3290,24 @@ HTML;
|
||||
*/
|
||||
public function loginGetEditAccessCuidFromId(int $id): string|false
|
||||
{
|
||||
if (!isset($_SESSION['LOGIN_UNIT_ACL_LEVEL'][$id])) {
|
||||
if (!isset($_SESSION['LOGIN_UNIT_LEGACY'][$id])) {
|
||||
return false;
|
||||
}
|
||||
return (string)$_SESSION['LOGIN_UNIT_ACL_LEVEL'][$id]['cuid'];
|
||||
return (string)$_SESSION['LOGIN_UNIT_LEGACY'][$id]['cuid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a Legacy lookup from the edit access id to cuid for further lookups in the normal list
|
||||
*
|
||||
* @param string $cuid edit access cuid
|
||||
* @return int|false false on not found or edit access id PK
|
||||
*/
|
||||
public function loginGetEditAccessIdFromCuid(string $cuid): int|false
|
||||
{
|
||||
if (!isset($_SESSION['LOGIN_UNIT'][$cuid])) {
|
||||
return false;
|
||||
}
|
||||
return $_SESSION['LOGIN_UNIT'][$cuid]['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3141,6 +3141,7 @@ class IO
|
||||
'pk_name' => '',
|
||||
'count' => 0,
|
||||
'query' => '',
|
||||
'query_raw' => $query,
|
||||
'result' => null,
|
||||
'returning_id' => false,
|
||||
'placeholder_converted' => [],
|
||||
@@ -3237,11 +3238,12 @@ class IO
|
||||
}
|
||||
} else {
|
||||
// if we try to use the same statement name for a differnt query, error abort
|
||||
if ($this->prepare_cursor[$stm_name]['query'] != $query) {
|
||||
if ($this->prepare_cursor[$stm_name]['query_raw'] != $query) {
|
||||
// thrown error
|
||||
$this->__dbError(26, false, context: [
|
||||
'statement_name' => $stm_name,
|
||||
'prepared_query' => $this->prepare_cursor[$stm_name]['query'],
|
||||
'prepared_query_raw' => $this->prepare_cursor[$stm_name]['query_raw'],
|
||||
'query' => $query,
|
||||
'pk_name' => $pk_name,
|
||||
]);
|
||||
@@ -4364,6 +4366,37 @@ class IO
|
||||
return $this->prepare_cursor[$stm_name][$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a prepared query eixsts
|
||||
*
|
||||
* @param string $stm_name Statement to check
|
||||
* @param string $query [default=''] If set then query must also match
|
||||
* @return false|int<0,2> False on missing stm_name
|
||||
* 0: ok, 1: stm_name matchin, 2: stm_name and query matching
|
||||
*/
|
||||
public function dbPreparedCursorStatus(string $stm_name, string $query = ''): false|int
|
||||
{
|
||||
if (empty($stm_name)) {
|
||||
$this->__dbError(
|
||||
101,
|
||||
false,
|
||||
'No statement name given'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// does not exist
|
||||
$return_value = 0;
|
||||
if (!empty($this->prepare_cursor[$stm_name]['query_raw'])) {
|
||||
// statement name eixts
|
||||
$return_value = 1;
|
||||
if ($this->prepare_cursor[$stm_name]['query_raw'] == $query) {
|
||||
// query also matches
|
||||
$return_value = 2;
|
||||
}
|
||||
}
|
||||
return $return_value;
|
||||
}
|
||||
|
||||
// ***************************
|
||||
// ERROR AND WARNING DATA
|
||||
// ***************************
|
||||
|
||||
@@ -3692,7 +3692,7 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function preparedProviderValue(): array
|
||||
public function providerDbGetPrepareCursorValue(): array
|
||||
{
|
||||
// 1: query (can be empty for do not set)
|
||||
// 2: stm name
|
||||
@@ -3736,7 +3736,7 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
* test return prepare cursor errors
|
||||
*
|
||||
* @covers ::dbGetPrepareCursorValue
|
||||
* @dataProvider preparedProviderValue
|
||||
* @dataProvider providerDbGetPrepareCursorValue
|
||||
* @testdox prepared query $stm_name with $key expect error id $error_id [$_dataName]
|
||||
*
|
||||
* @param string $query
|
||||
@@ -3769,6 +3769,94 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providerDbPreparedCursorStatus(): array
|
||||
{
|
||||
return [
|
||||
'empty statement pararm' => [
|
||||
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||
'stm_name' => 'test_stm_a',
|
||||
'check_stm_name' => '',
|
||||
'check_query' => '',
|
||||
'expected' => false
|
||||
],
|
||||
'different stm_name' => [
|
||||
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||
'stm_name' => 'test_stm_b',
|
||||
'check_stm_name' => 'other_name',
|
||||
'check_query' => '',
|
||||
'expected' => 0
|
||||
],
|
||||
'same stm_name' => [
|
||||
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||
'stm_name' => 'test_stm_c',
|
||||
'check_stm_name' => 'test_stm_c',
|
||||
'check_query' => '',
|
||||
'expected' => 1
|
||||
],
|
||||
'same stm_name and query' => [
|
||||
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||
'stm_name' => 'test_stm_d',
|
||||
'check_stm_name' => 'test_stm_d',
|
||||
'check_query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||
'expected' => 2
|
||||
],
|
||||
'same stm_name and different query' => [
|
||||
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||
'stm_name' => 'test_stm_e',
|
||||
'check_stm_name' => 'test_stm_e',
|
||||
'check_query' => 'SELECT row_int, uid, row_int FROM table_with_primary_key',
|
||||
'expected' => 1
|
||||
],
|
||||
'insert query test' => [
|
||||
'query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES ($1, $2)',
|
||||
'stm_name' => 'test_stm_f',
|
||||
'check_stm_name' => 'test_stm_f',
|
||||
'check_query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES ($1, $2)',
|
||||
'expected' => 2
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test cursor status for prepared statement
|
||||
*
|
||||
* @covers ::dbPreparedCursorStatus
|
||||
* @dataProvider providerDbPreparedCursorStatus
|
||||
* @testdox Check prepared $stm_name ($check_stm_name) status is $expected [$_dataName]
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $stm_name
|
||||
* @param string $check_stm_name
|
||||
* @param string $check_query
|
||||
* @param bool|int $expected
|
||||
* @return void
|
||||
*/
|
||||
public function testDbPreparedCursorStatus(
|
||||
string $query,
|
||||
string $stm_name,
|
||||
string $check_stm_name,
|
||||
string $check_query,
|
||||
bool|int $expected
|
||||
): void {
|
||||
$db = new \CoreLibs\DB\IO(
|
||||
self::$db_config['valid'],
|
||||
self::$log
|
||||
);
|
||||
$db->dbPrepare($stm_name, $query);
|
||||
// $db->dbExecute($stm_name);
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$db->dbPreparedCursorStatus($check_stm_name, $check_query),
|
||||
'check prepared stement cursor status'
|
||||
);
|
||||
unset($db);
|
||||
}
|
||||
|
||||
// - schema set/get tests
|
||||
// dbGetSchema, dbSetSchema
|
||||
|
||||
|
||||
Reference in New Issue
Block a user