@@ -106,15 +106,18 @@ private function lock(Key $key, bool $read, bool $blocking)
106
106
107
107
// Silence error reporting
108
108
set_error_handler (function ($ type , $ msg ) use (&$ error ) { $ error = $ msg ; });
109
- if (!$ handle = fopen ($ fileName , 'r+ ' ) ?: fopen ($ fileName , 'r ' )) {
110
- if ($ handle = fopen ($ fileName , 'x ' )) {
111
- chmod ($ fileName , 0666 );
112
- } elseif (!$ handle = fopen ($ fileName , 'r+ ' ) ?: fopen ($ fileName , 'r ' )) {
113
- usleep (100 ); // Give some time for chmod() to complete
114
- $ handle = fopen ($ fileName , 'r+ ' ) ?: fopen ($ fileName , 'r ' );
109
+ try {
110
+ if (!$ handle = fopen ($ fileName , 'r+ ' ) ?: fopen ($ fileName , 'r ' )) {
111
+ if ($ handle = fopen ($ fileName , 'x ' )) {
112
+ chmod ($ fileName , 0666 );
113
+ } elseif (!$ handle = fopen ($ fileName , 'r+ ' ) ?: fopen ($ fileName , 'r ' )) {
114
+ usleep (100 ); // Give some time for chmod() to complete
115
+ $ handle = fopen ($ fileName , 'r+ ' ) ?: fopen ($ fileName , 'r ' );
116
+ }
115
117
}
118
+ } finally {
119
+ restore_error_handler ();
116
120
}
117
- restore_error_handler ();
118
121
}
119
122
120
123
if (!$ handle ) {
0 commit comments