File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed
Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ Warning: dba_open(): Driver initialization failed for handler: cdb: Update opera
8282Failed to open DB
8383Test 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
8686Test 3
8787
8888Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments