Merge branch '4.4' into 5.1

* 4.4:
  [Filesystem] Check if failed unlink was caused by permission denied
  fix APCu installation for the nightly build job
  skip Vulcain-based tests if the binary cannot be executed
This commit is contained in:
Fabien Potencier 2020-10-21 06:47:05 +02:00
commit baf8c2355f
4 changed files with 34 additions and 3 deletions

View File

@ -157,15 +157,14 @@ before_install:
fi
if [[ $PHP = nightly ]]; then
tfold ext.memcached tpecl memcached-3.1.5 memcached.so $INI
tfold ext.apcu install_apcu_dev 9c36db45100d4d27ec33072f4be90f1f5a0108b7 $INI
else
tfold ext.apcu tpecl apcu-5.1.19 apcu.so $INI
tfold ext.mongodb tpecl mongodb-1.6.16 mongodb.so $INI
tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI
tfold ext.amqp tpecl amqp-1.10.2 amqp.so $INI
tfold ext.redis tpecl redis-5.2.2 redis.so $INI "no"
fi
tfold ext.apcu tpecl apcu-5.1.19 apcu.so $INI
tfold ext.igbinary tpecl igbinary-3.1.6 igbinary.so $INI
done
- |

View File

@ -175,7 +175,7 @@ class Filesystem
if (!self::box('rmdir', $file) && file_exists($file)) {
throw new IOException(sprintf('Failed to remove directory "%s": ', $file).self::$lastError);
}
} elseif (!self::box('unlink', $file) && file_exists($file)) {
} elseif (!self::box('unlink', $file) && (false !== strpos(self::$lastError, 'Permission denied') || file_exists($file))) {
throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError);
}
}

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Filesystem\Tests;
use Symfony\Component\Filesystem\Exception\IOException;
/**
* Test class for Filesystem.
*/
@ -334,6 +336,28 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFileDoesNotExist($basePath.'dir');
}
public function testRemoveThrowsExceptionOnPermissionDenied()
{
$this->markAsSkippedIfChmodIsMissing();
$basePath = $this->workspace.\DIRECTORY_SEPARATOR.'dir_permissions';
mkdir($basePath);
$file = $basePath.\DIRECTORY_SEPARATOR.'file';
touch($file);
chmod($basePath, 0400);
try {
$this->filesystem->remove($file);
$this->fail('Filesystem::remove() should throw an exception');
} catch (IOException $e) {
$this->assertStringContainsString('Failed to remove file "'.$file.'"', $e->getMessage());
$this->assertStringContainsString('Permission denied', $e->getMessage());
} finally {
// Make sure we can clean up this file
chmod($basePath, 0777);
}
}
public function testRemoveCleansInvalidLinks()
{
$this->markAsSkippedIfSymlinkIsMissing();

View File

@ -243,6 +243,14 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
sleep('\\' === \DIRECTORY_SEPARATOR ? 10 : 1);
if (!$process->isRunning()) {
if ('\\' !== \DIRECTORY_SEPARATOR && 127 === $process->getExitCode()) {
self::markTestSkipped('vulcain binary is missing');
}
if ('\\' !== \DIRECTORY_SEPARATOR && 126 === $process->getExitCode()) {
self::markTestSkipped('vulcain binary is not executable');
}
self::markTestSkipped((new ProcessFailedException($process))->getMessage());
}