(Translated by https://www.hiragana.jp/)
⚓ T227157 SVG thumbnailing fails on windows due to symlink call
Page MenuHomePhabricator

SVG thumbnailing fails on windows due to symlink call
Closed, ResolvedPublic

Description

There is, as far as I can see, only one use of symlink in MediaWiki core. Symlinks are lightweight and ideal, but some systems may not allow them.

Instead of failing outright, an attempt should be made to copy the file and, only if that also fails, declare that the thumbnail creation has failed.

Event Timeline

Change 520347 had a related patch set uploaded (by markahershberger; owner: markahershberger):
[mediawiki/core@master] Use copy if symlink fails

https://gerrit.wikimedia.org/r/520347

Bawolff renamed this task from Use copy if symlink fails to SVG thumbnailing fails on windows due to symlink call.Apr 29 2022, 9:03 PM

Change 520347 merged by jenkins-bot:

[mediawiki/core@master] Use copy if symlink fails

https://gerrit.wikimedia.org/r/520347

TheDJ subscribed.

Considering this solved, but reopen if required

I have just encountered this issue. I can see in SvgHandler.php that you are attempting to Fallback because symlink often fails on Windows from a symlink() call to a copy() call, but this does not seem to be working. I think the symlink() call throws an exception in this case (not even sure PHP has exceptions), whereas your code is testing the return value of symlink(). According to the documentation for symlink() it sounds like it returns an error value in cases where the link already exists or the target does not exist. It (I guess) does not return an error value but throws an exception on permission denied. For me, when this happens, I get a 500 error from a normal PC, and the following error from the server:

PHP Warning: symlink(): Permission denied in \includes\media\SvgHandler.php on line 313

This is version 1.41.

I was able to correct the issue just by replacing the symlink() call with a copy() call but thought I should report this after seeing the other copy() call that was already there in an attempt to fix this.

I suppose maybe you should try to catch an exception from the symlink() call as well as test the return value, but I am not a PHP dev so am not exactly sure what that would look like.

This is version 1.41.

I suppose maybe you should try to catch an exception from the symlink() call as well as test the return value, but I am not a PHP dev so am not exactly sure what that would look like.

That happens in f8bfb2c48e8cf6df8a77f5db9580820fa09aa752, but that is 1.42.