File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
wcfsetup/install/files/lib/system/file/command Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public function __invoke(): File
3535 $ this ->validatePathname ($ this ->file ->getPathnameWebp ());
3636
3737 $ file = $ this ->replaceSource ();
38+ $ file = $ this ->discardWebpVariantOfWebpFile ($ file );
3839 $ this ->regenerateExistingThumbnails ($ file );
3940
4041 return $ file ;
@@ -131,6 +132,28 @@ private function replaceSource(): File
131132 }
132133 }
133134
135+ private function discardWebpVariantOfWebpFile (File $ file ): File
136+ {
137+ if ($ file ->mimeType !== 'image/webp ' ) {
138+ return $ file ;
139+ }
140+
141+ $ pathname = $ file ->getPathnameWebp ();
142+ if ($ pathname === null ) {
143+ return $ file ;
144+ }
145+
146+ if (\file_exists ($ pathname )) {
147+ \unlink ($ file ->getPathnameWebp ());
148+ }
149+
150+ (new FileEditor ($ file ))->update ([
151+ 'fileHashWebp ' => null ,
152+ ]);
153+
154+ return new File ($ file ->fileID );
155+ }
156+
134157 private function regenerateExistingThumbnails (File $ file ): void
135158 {
136159 $ sql = "SELECT COUNT(*)
You can’t perform that action at this time.
0 commit comments