@@ -800,7 +800,13 @@ protected function assertHookCall($callData, $signal, $hookPath) {
800800 }
801801
802802 /**
803- * Test whether locks are set before and after the operation
803+ * Test that PUT keeps hook-time lock semantics compatible:
804+ * - pre-write hooks run while the file is shared-locked
805+ * - post-write hooks also run while the file is shared-locked
806+ *
807+ * Post-write hooks are expected to observe a fully finalized file state,
808+ * but should still be able to access the file without exclusive-lock
809+ * contention.
804810 */
805811 public function testPutLocking (): void {
806812 $ view = new View ('/ ' . $ this ->user . '/files/ ' );
@@ -832,8 +838,8 @@ public function testPutLocking(): void {
832838 $ wasLockedPost = false ;
833839 $ eventHandler = $ this ->createMock (EventHandlerMock::class);
834840
835- // both pre and post hooks might need access to the file,
836- // so only shared lock is acceptable
841+ // Pre-write hooks should run under a shared lock so observers can safely
842+ // inspect the target while the write is in progress.
837843 $ eventHandler ->expects ($ this ->once ())
838844 ->method ('writeCallback ' )
839845 ->willReturnCallback (
@@ -842,6 +848,10 @@ function () use ($view, $path, &$wasLockedPre): void {
842848 $ wasLockedPre = $ wasLockedPre && !$ this ->isFileLocked ($ view , $ path , ILockingProvider::LOCK_EXCLUSIVE );
843849 }
844850 );
851+
852+ // Post-write hooks should also run under a shared lock. They are expected to
853+ // see fully finalized metadata/state, but still be able to access the file
854+ // during the callback.
845855 $ eventHandler ->expects ($ this ->once ())
846856 ->method ('postWriteCallback ' )
847857 ->willReturnCallback (
@@ -872,8 +882,8 @@ function () use ($view, $path, &$wasLockedPost): void {
872882 // afterMethod unlocks
873883 $ view ->unlockFile ($ path , ILockingProvider::LOCK_SHARED );
874884
875- $ this ->assertTrue ($ wasLockedPre , 'File was locked during pre-hooks ' );
876- $ this ->assertTrue ($ wasLockedPost , 'File was locked during post-hooks ' );
885+ $ this ->assertTrue ($ wasLockedPre , 'File was shared- locked during pre-hooks ' );
886+ $ this ->assertTrue ($ wasLockedPost , 'File was shared- locked during post-hooks ' );
877887
878888 $ this ->assertFalse (
879889 $ this ->isFileLocked ($ view , $ path , ILockingProvider::LOCK_SHARED ),
0 commit comments