Merge branch '2.7' into 2.8
* 2.7: fixed CS [DomCrawler] Dont use LIBXML_PARSEHUGE by default [Filesystem] Reduce complexity of ->remove() added tests for non-trusted proxies add 'guid' to list of exception to filter out Ensure backend slashes for symlinks on Windows systems [Filesystem] Try to delete broken symlinks fixed tests [FrameworkBundle] Test that ObjectNormalizer is registered
This commit is contained in:
commit
ef08c07329
@ -106,6 +106,13 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
||||
$values = array_values(array_filter($values, function ($v) {
|
||||
return (string) $v === (string) (int) $v;
|
||||
}));
|
||||
} elseif ('guid' === $metadata->getTypeOfField($identifier)) {
|
||||
$parameterType = Connection::PARAM_STR_ARRAY;
|
||||
|
||||
// Like above, but we just filter out empty strings.
|
||||
$values = array_values(array_filter($values, function ($v) {
|
||||
return (string) $v !== '';
|
||||
}));
|
||||
} else {
|
||||
$parameterType = Connection::PARAM_STR_ARRAY;
|
||||
}
|
||||
|
@ -457,6 +457,17 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.normalizer.object')->getArgument(1));
|
||||
}
|
||||
|
||||
public function testObjectNormalizerRegistered()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
|
||||
$definition = $container->getDefinition('serializer.normalizer.object');
|
||||
$tag = $definition->getTag('serializer.normalizer');
|
||||
|
||||
$this->assertEquals('Symfony\Component\Serializer\Normalizer\ObjectNormalizer', $definition->getClass());
|
||||
$this->assertEquals(-1000, $tag[0]['priority']);
|
||||
}
|
||||
|
||||
public function testAssetHelperWhenAssetsAreEnabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
|
@ -215,8 +215,11 @@ class Crawler extends \SplObjectStorage
|
||||
*
|
||||
* @param string $content The XML content
|
||||
* @param string $charset The charset
|
||||
* @param int $options Bitwise OR of the libxml option constants
|
||||
* LIBXML_PARSEHUGE is dangerous, see
|
||||
* http://symfony.com/blog/security-release-symfony-2-0-17-released
|
||||
*/
|
||||
public function addXmlContent($content, $charset = 'UTF-8')
|
||||
public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NONET)
|
||||
{
|
||||
// remove the default namespace if it's the only namespace to make XPath expressions simpler
|
||||
if (!preg_match('/xmlns:/', $content)) {
|
||||
@ -230,7 +233,7 @@ class Crawler extends \SplObjectStorage
|
||||
$dom->validateOnParse = true;
|
||||
|
||||
if ('' !== trim($content)) {
|
||||
@$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0));
|
||||
@$dom->loadXML($content, $options);
|
||||
}
|
||||
|
||||
libxml_use_internal_errors($internalErrors);
|
||||
|
@ -158,26 +158,23 @@ class Filesystem
|
||||
$files = iterator_to_array($this->toIterator($files));
|
||||
$files = array_reverse($files);
|
||||
foreach ($files as $file) {
|
||||
if (!$this->exists($file) && !is_link($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($file) && !is_link($file)) {
|
||||
if (is_link($file)) {
|
||||
// Workaround https://bugs.php.net/52176
|
||||
if (!@unlink($file) && !@rmdir($file)) {
|
||||
$error = error_get_last();
|
||||
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message']));
|
||||
}
|
||||
} elseif (is_dir($file)) {
|
||||
$this->remove(new \FilesystemIterator($file));
|
||||
|
||||
if (true !== @rmdir($file)) {
|
||||
throw new IOException(sprintf('Failed to remove directory "%s".', $file), 0, null, $file);
|
||||
if (!@rmdir($file)) {
|
||||
$error = error_get_last();
|
||||
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message']));
|
||||
}
|
||||
} else {
|
||||
// https://bugs.php.net/bug.php?id=52176
|
||||
if ('\\' === DIRECTORY_SEPARATOR && is_dir($file)) {
|
||||
if (true !== @rmdir($file)) {
|
||||
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
|
||||
}
|
||||
} else {
|
||||
if (true !== @unlink($file)) {
|
||||
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
|
||||
}
|
||||
} elseif ($this->exists($file)) {
|
||||
if (!@unlink($file)) {
|
||||
$error = error_get_last();
|
||||
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -308,10 +305,15 @@ class Filesystem
|
||||
*/
|
||||
public function symlink($originDir, $targetDir, $copyOnWindows = false)
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR && $copyOnWindows) {
|
||||
$this->mirror($originDir, $targetDir);
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$originDir = strtr($originDir, '/', '\\');
|
||||
$targetDir = strtr($targetDir, '/', '\\');
|
||||
|
||||
return;
|
||||
if ($copyOnWindows) {
|
||||
$this->mirror($originDir, $targetDir);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->mkdir(dirname($targetDir));
|
||||
|
@ -278,7 +278,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->remove($basePath);
|
||||
|
||||
$this->assertTrue(!is_dir($basePath));
|
||||
$this->assertFileNotExists($basePath);
|
||||
}
|
||||
|
||||
public function testRemoveCleansArrayOfFilesAndDirectories()
|
||||
@ -294,8 +294,8 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->remove($files);
|
||||
|
||||
$this->assertTrue(!is_dir($basePath.'dir'));
|
||||
$this->assertTrue(!is_file($basePath.'file'));
|
||||
$this->assertFileNotExists($basePath.'dir');
|
||||
$this->assertFileNotExists($basePath.'file');
|
||||
}
|
||||
|
||||
public function testRemoveCleansTraversableObjectOfFilesAndDirectories()
|
||||
@ -311,8 +311,8 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->remove($files);
|
||||
|
||||
$this->assertTrue(!is_dir($basePath.'dir'));
|
||||
$this->assertTrue(!is_file($basePath.'file'));
|
||||
$this->assertFileNotExists($basePath.'dir');
|
||||
$this->assertFileNotExists($basePath.'file');
|
||||
}
|
||||
|
||||
public function testRemoveIgnoresNonExistingFiles()
|
||||
@ -327,7 +327,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->remove($files);
|
||||
|
||||
$this->assertTrue(!is_dir($basePath.'dir'));
|
||||
$this->assertFileNotExists($basePath.'dir');
|
||||
}
|
||||
|
||||
public function testRemoveCleansInvalidLinks()
|
||||
@ -339,11 +339,19 @@ class FilesystemTest extends FilesystemTestCase
|
||||
mkdir($basePath);
|
||||
mkdir($basePath.'dir');
|
||||
// create symlink to nonexistent file
|
||||
@symlink($basePath.'file', $basePath.'link');
|
||||
@symlink($basePath.'file', $basePath.'file-link');
|
||||
|
||||
// create symlink to dir using trailing forward slash
|
||||
$this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
|
||||
$this->assertTrue(is_dir($basePath.'dir-link'));
|
||||
|
||||
// create symlink to nonexistent dir
|
||||
rmdir($basePath.'dir');
|
||||
$this->assertFalse(is_dir($basePath.'dir-link'));
|
||||
|
||||
$this->filesystem->remove($basePath);
|
||||
|
||||
$this->assertTrue(!is_dir($basePath));
|
||||
$this->assertFileNotExists($basePath);
|
||||
}
|
||||
|
||||
public function testFilesExists()
|
||||
@ -1172,8 +1180,8 @@ class FilesystemTest extends FilesystemTestCase
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$sourceFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_source_file';
|
||||
$targetFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_target_file';
|
||||
$sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file';
|
||||
$targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
|
||||
|
||||
file_put_contents($sourceFilePath, 'SOURCE FILE');
|
||||
chmod($sourceFilePath, 0745);
|
||||
|
@ -1566,6 +1566,13 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(80, $request->getPort());
|
||||
$this->assertFalse($request->isSecure());
|
||||
|
||||
// request is forwarded by a non-trusted proxy
|
||||
Request::setTrustedProxies(array('2.2.2.2'));
|
||||
$this->assertEquals('3.3.3.3', $request->getClientIp());
|
||||
$this->assertEquals('example.com', $request->getHost());
|
||||
$this->assertEquals(80, $request->getPort());
|
||||
$this->assertFalse($request->isSecure());
|
||||
|
||||
// trusted proxy via setTrustedProxies()
|
||||
Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2'));
|
||||
$this->assertEquals('1.1.1.1', $request->getClientIp());
|
||||
|
Reference in New Issue
Block a user