@@ -17,7 +17,6 @@ class FileLock implements Lock
17
17
private $ lock_file ;
18
18
private $ exclusive ;
19
19
private $ blocking ;
20
- private $ identifier ;
21
20
private $ fh ;
22
21
private $ remove_on_release ;
23
22
@@ -28,22 +27,19 @@ class FileLock implements Lock
28
27
* @param boolean $exclusive true for an exclusive lock, false for shared one
29
28
* @param boolean $blocking true to wait for lock to be available,
30
29
* false to throw exception instead of waiting
31
- * @param string|null $identifier resource identifier (default to $lock_file) for logging
32
30
* @param boolean $remove_on_release remove file on release if no other lock remains
33
31
* @param LoggerInterface $logger
34
32
*/
35
33
public function __construct (
36
34
$ lock_file ,
37
35
$ exclusive = FileLock::EXCLUSIVE ,
38
36
$ blocking = FileLock::NON_BLOCKING ,
39
- $ identifier = null ,
40
37
$ remove_on_release = false ,
41
38
LoggerInterface $ logger = null
42
39
) {
43
40
$ this ->lock_file = $ lock_file ;
44
41
$ this ->exclusive = $ exclusive ;
45
42
$ this ->blocking = $ blocking ;
46
- $ this ->identifier = $ identifier ?:$ lock_file ;
47
43
$ this ->remove_on_release = $ remove_on_release ;
48
44
49
45
$ this ->logger = $ logger ?: new NullLogger ;
@@ -79,20 +75,20 @@ public function acquire()
79
75
private function tryAcquire ($ operation , $ lock_type )
80
76
{
81
77
$ log_data = [
82
- 'identifier ' => $ this ->identifier ,
78
+ 'lock_file ' => $ this ->lock_file ,
83
79
'lock_type ' => $ lock_type
84
80
];
85
81
86
82
if (!$ this ->flock ($ operation )) {
87
- $ this ->logger ->debug ('could not acquire {lock_type} lock on {identifier } ' , $ log_data );
83
+ $ this ->logger ->debug ('could not acquire {lock_type} lock on {lock_file } ' , $ log_data );
88
84
89
85
throw new Exception (
90
- 'Could not acquire ' .$ lock_type .' lock on ' .$ this ->identifier
86
+ 'Could not acquire ' .$ lock_type .' lock on ' .$ this ->lock_file
91
87
);
92
88
93
89
}
94
90
95
- $ this ->logger ->debug ('{lock_type} lock acquired on {identifier } ' , $ log_data );
91
+ $ this ->logger ->debug ('{lock_type} lock acquired on {lock_file } ' , $ log_data );
96
92
}
97
93
98
94
public function release ()
@@ -109,7 +105,7 @@ public function release()
109
105
fclose ($ this ->fh );
110
106
$ this ->fh = null ;
111
107
112
- $ this ->logger ->debug ('{lock_type} lock released on {identifier } ' , ['identifier ' => $ this ->identifier ]);
108
+ $ this ->logger ->debug ('{lock_type} lock released on {lock_file } ' , ['lock_file ' => $ this ->lock_file ]);
113
109
}
114
110
115
111
public function __destruct ()
0 commit comments