Skip to content

Commit 0887a1d

Browse files
committed
Remove personalisation from write on readonly db DBA error message
1 parent c8ba00f commit 0887a1d

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

ext/dba/dba.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ static zend_string* php_dba_make_key(HashTable *key)
139139

140140
/* check whether the user has write access */
141141
#define DBA_WRITE_CHECK(info) \
142-
if((info)->mode != DBA_WRITER && (info)->mode != DBA_TRUNC && (info)->mode != DBA_CREAT) { \
143-
php_error_docref(NULL, E_WARNING, "You cannot perform a modification to a database without proper access"); \
142+
if ((info)->mode != DBA_WRITER && (info)->mode != DBA_TRUNC && (info)->mode != DBA_CREAT) { \
143+
php_error_docref(NULL, E_WARNING, "Cannot perform a modification on a readonly database"); \
144144
RETURN_FALSE; \
145145
}
146146

ext/dba/tests/dba_cdb_001.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Warning: dba_open(): Driver initialization failed for handler: cdb: Update opera
8282
Failed to open DB
8383
Test 2
8484

85-
Warning: dba_insert(): You cannot perform a modification to a database without proper access in %sdba_cdb_001.php on line %d
85+
Warning: dba_insert(): Cannot perform a modification on a readonly database in %sdba_cdb_001.php on line %d
8686
Test 3
8787

8888
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d

ext/dba/tests/dba_lmdb_readonly.phpt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
DBA LMDB handler readonly test
3+
--EXTENSIONS--
4+
dba
5+
--SKIPIF--
6+
<?php
7+
$handler = 'lmdb';
8+
require_once __DIR__ .'/skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
$handler = 'lmdb';
13+
$db_filename = __DIR__ . "/lmdb-readonly.dbm";
14+
15+
// Create DB
16+
$db_file = dba_open($db_filename, "c", $handler);
17+
assert($db_file !== false);
18+
// Close handler
19+
dba_close($db_file);
20+
21+
// Open in read only mode
22+
$db_file = dba_open($db_filename, "r", $handler);
23+
assert($db_file !== false);
24+
25+
// Try inserting
26+
dba_insert("key1", "This is a test insert", $db_file);
27+
dba_close($db_file);
28+
?>
29+
--CLEAN--
30+
<?php
31+
$db_filename = __DIR__ . "/lmdb-readonly.dbm";
32+
@unlink($db_filename);
33+
@unlink($db_filename.'.lck');
34+
@unlink($db_filename.'-lock');
35+
?>
36+
--EXPECTF--
37+
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d

0 commit comments

Comments
 (0)