@@ -43,24 +43,26 @@ public function handle(Event $event): void {
4343 }
4444
4545 $ document = $ this ->documentMapper ->load ($ context ->getType (), $ context ->getId ());
46- if (!$ document || $ this -> documentService -> isSaveFromText () ) {
47- $ this ->logger ->debug ('No document or event triggered by text itself ' , ['document ' => $ document ]);
46+ if (!$ document ) {
47+ $ this ->logger ->debug ('No document for context. ' , ['context ' => $ context -> toString () ]);
4848 return ;
4949 }
5050
51- $ oldChecksum = $ document ->getChecksum ();
52- $ updatedDocument = $ context ->updateDocument ($ document );
53- if (!$ updatedDocument ) {
54- $ this ->logger ->info ('Nothing changed ' , ['document ' => $ document ]);
55- // nothing changed.
51+ if ($ this ->documentService ->isSaveFromText ()) {
52+ $ this ->logger ->debug ('DocumentContentUpdated triggered by text itself ' , ['document ' => $ document ->jsonSerialize ()]);
5653 return ;
5754 }
5855
59- $ newChecksum = $ updatedDocument ->getChecksum ();
60- if ($ oldChecksum !== null && $ newChecksum !== null && $ oldChecksum === $ newChecksum ) {
61- // Same content: no need to reset document session. Still update document mtime and etag as they might have changed
62- $ this ->logger ->info ('Same checksum ' , ['document ' => $ document ->jsonSerialize (), 'updated ' => $ updatedDocument ->jsonSerialize ()]);
63- $ this ->documentMapper ->update ($ updatedDocument );
56+ $ context ->updateDocument ($ document );
57+ if (empty ($ document ->getUpdatedFields ())) {
58+ $ this ->logger ->debug ('Nothing changed ' , ['document ' => $ document ->jsonSerialize ()]);
59+ return ;
60+ }
61+
62+ if (!isset ($ document ->getUpdatedFields ()['checksum ' ])) {
63+ // Same content: no need to reset document session. Still update document mtime and etag.
64+ $ this ->logger ->debug ('DocumentContentUpdated with same checksum ' , ['document ' => $ document ->jsonSerialize ()]);
65+ $ this ->documentMapper ->update ($ document );
6466 return ;
6567 }
6668
0 commit comments