|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-01-16 15:18 UTC] mattsch at gmail dot com
Description:
------------
symlink improperly creates a recursive link on existing symlink without a target. This appears to be a regression since php 5.2 which was broken in php 5.3 and all subsequent versions. In php 5.2, calling symlink on an existing symlink always failed regardless whether the target existed.
Test script:
---------------
<?php
/*
Make symlink create a symbolic link that does not link to anything (link does not exist)
*/
symlink('43', '0'); // Result: 0 -> 43
// second call to the same thing
symlink('43', '0'); // Result: 43 -> 43
/*
third call will fail with a warning:
PHP Warning: symlink(): No such file or directory in test.php on line 2
*/
symlink('43', '0');
Expected result:
----------------
symlink should fail and emit a warning after the second call to a non-existing link and not create a recursive link on the target.
Actual result:
--------------
symlink fails on the third call to create a symlink that already exists after creating a recursive symlink to the target.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 04:00:02 2025 UTC |
I just stumbled over the same problem on Ubuntu 14.10 and a current Linux Mint. Note that ln behaves differently: /tmp/foo $ ls -l /tmp/foo/ lrwxrwxrwx 1 alex alex 4 Jan 7 12:58 testjobs -> jobs /tmp/foo $ ln -s /tmp/foo/jobs /tmp/foo/testjobs ln: failed to create symbolic link '/tmp/foo/testjobs': File exists /tmp/foo $ php -r "symlink('/tmp/foo/jobs', '/tmp/foo/testjobs');" /tmp/foo $ ls -l /tmp/foo/ lrwxrwxrwx 1 alex alex 13 Jan 7 13:21 jobs -> /tmp/foo/jobs lrwxrwxrwx 1 alex alex 4 Jan 7 12:58 testjobs -> jobs /tmp/foo $ cat jobs cat: jobs: Too many levels of symbolic links