Merge branch '2.6' into 2.7
* 2.6: Add test for HHVM FatalErrors [2.6][Debug] Fix fatal-errors handling on HHVM [2.3][Debug] Fix fatal-errors handling on HHVM Standardize the name of the exception variables [2.3] Static Code Analysis for Components Remove duplicated paths Conflicts: src/Symfony/Component/Debug/ErrorHandler.php src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php src/Symfony/Component/Security/Http/Firewall/ContextListener.php src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php
This commit is contained in:
commit
2e7c2caaf2
@ -75,7 +75,7 @@ class TwigEngine extends BaseEngine implements EngineInterface
|
|||||||
try {
|
try {
|
||||||
// try to get the real file name of the template where the error occurred
|
// try to get the real file name of the template where the error occurred
|
||||||
$e->setTemplateFile(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateFile()))));
|
$e->setTemplateFile(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateFile()))));
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $e2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$value[$name] = $child->finalize($value[$name]);
|
$value[$name] = $child->finalize($value[$name]);
|
||||||
} catch (UnsetKeyException $unset) {
|
} catch (UnsetKeyException $e) {
|
||||||
unset($value[$name]);
|
unset($value[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,14 +307,10 @@ abstract class BaseNode implements NodeInterface
|
|||||||
foreach ($this->finalValidationClosures as $closure) {
|
foreach ($this->finalValidationClosures as $closure) {
|
||||||
try {
|
try {
|
||||||
$value = $closure($value);
|
$value = $closure($value);
|
||||||
} catch (Exception $correctEx) {
|
} catch (Exception $e) {
|
||||||
throw $correctEx;
|
throw $e;
|
||||||
} catch (\Exception $invalid) {
|
} catch (\Exception $e) {
|
||||||
throw new InvalidConfigurationException(sprintf(
|
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": %s', $this->getPath(), $e->getMessage()), $e->getCode(), $e);
|
||||||
'Invalid configuration for path "%s": %s',
|
|
||||||
$this->getPath(),
|
|
||||||
$invalid->getMessage()
|
|
||||||
), $invalid->getCode(), $invalid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
$this->prototype->setName($k);
|
$this->prototype->setName($k);
|
||||||
try {
|
try {
|
||||||
$value[$k] = $this->prototype->finalize($v);
|
$value[$k] = $this->prototype->finalize($v);
|
||||||
} catch (UnsetKeyException $unset) {
|
} catch (UnsetKeyException $e) {
|
||||||
unset($value[$k]);
|
unset($value[$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class FileLocator implements FileLocatorInterface
|
|||||||
array_unshift($paths, $currentPath);
|
array_unshift($paths, $currentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$paths = array_unique($paths);
|
||||||
$filepaths = array();
|
$filepaths = array();
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
@ -68,7 +69,7 @@ class FileLocator implements FileLocatorInterface
|
|||||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)));
|
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values(array_unique($filepaths));
|
return $filepaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1142,7 +1142,7 @@ class Application
|
|||||||
$lines[] = str_pad($line, $width);
|
$lines[] = str_pad($line, $width);
|
||||||
$line = $char;
|
$line = $char;
|
||||||
}
|
}
|
||||||
if (strlen($line)) {
|
if ('' !== $line) {
|
||||||
$lines[] = count($lines) ? str_pad($line, $width) : $line;
|
$lines[] = count($lines) ? str_pad($line, $width) : $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
*/
|
*/
|
||||||
public static function escape($text)
|
public static function escape($text)
|
||||||
{
|
{
|
||||||
return preg_replace('/([^\\\\]?)</is', '$1\\<', $text);
|
return preg_replace('/([^\\\\]?)</', '$1\\<', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,7 +146,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
$offset = 0;
|
$offset = 0;
|
||||||
$output = '';
|
$output = '';
|
||||||
$tagRegex = '[a-z][a-z0-9_=;-]*';
|
$tagRegex = '[a-z][a-z0-9_=;-]*';
|
||||||
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#isx", $message, $matches, PREG_OFFSET_CAPTURE);
|
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
|
||||||
foreach ($matches[0] as $i => $match) {
|
foreach ($matches[0] as $i => $match) {
|
||||||
$pos = $match[1];
|
$pos = $match[1];
|
||||||
$text = $match[0];
|
$text = $match[0];
|
||||||
|
@ -466,18 +466,18 @@ class DialogHelper extends InputAwareHelper
|
|||||||
*/
|
*/
|
||||||
private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
|
private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
|
||||||
{
|
{
|
||||||
$error = null;
|
$e = null;
|
||||||
while (false === $attempts || $attempts--) {
|
while (false === $attempts || $attempts--) {
|
||||||
if (null !== $error) {
|
if (null !== $e) {
|
||||||
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
|
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return call_user_func($validator, $interviewer());
|
return call_user_func($validator, $interviewer());
|
||||||
} catch (\Exception $error) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $error;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ EOF;
|
|||||||
} else {
|
} else {
|
||||||
$this->output->write($this->getPrompt());
|
$this->output->write($this->getPrompt());
|
||||||
$line = fgets(STDIN, 1024);
|
$line = fgets(STDIN, 1024);
|
||||||
$line = (!$line && strlen($line) == 0) ? false : rtrim($line);
|
$line = (false === $line || '' === $line) ? false : rtrim($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $line;
|
return $line;
|
||||||
|
@ -350,7 +350,7 @@ class ErrorHandler
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function handleError($type, $message, $file, $line, array $context)
|
public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
|
||||||
{
|
{
|
||||||
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR;
|
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR;
|
||||||
$log = $this->loggedErrors & $type;
|
$log = $this->loggedErrors & $type;
|
||||||
@ -367,6 +367,15 @@ class ErrorHandler
|
|||||||
$context = $e;
|
$context = $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $backtrace && $type & E_ERROR) {
|
||||||
|
// E_ERROR fatal errors are triggered on HHVM when
|
||||||
|
// hhvm.error_handling.call_user_handler_on_fatals=1
|
||||||
|
// which is the way to get their backtrace.
|
||||||
|
$this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($throw) {
|
if ($throw) {
|
||||||
if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
|
if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
|
||||||
// Checking for class existence is a work around for https://bugs.php.net/42098
|
// Checking for class existence is a work around for https://bugs.php.net/42098
|
||||||
@ -402,10 +411,17 @@ class ErrorHandler
|
|||||||
if ($this->scopedErrors & $type) {
|
if ($this->scopedErrors & $type) {
|
||||||
$e['scope_vars'] = $context;
|
$e['scope_vars'] = $context;
|
||||||
if ($trace) {
|
if ($trace) {
|
||||||
$e['stack'] = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
$e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||||
}
|
}
|
||||||
} elseif ($trace) {
|
} elseif ($trace) {
|
||||||
$e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
if (null === $backtrace) {
|
||||||
|
$e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
} else {
|
||||||
|
foreach ($backtrace as &$frame) {
|
||||||
|
unset($frame['args'], $frame);
|
||||||
|
}
|
||||||
|
$e['stack'] = $backtrace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +521,11 @@ class ErrorHandler
|
|||||||
*/
|
*/
|
||||||
public static function handleFatalError(array $error = null)
|
public static function handleFatalError(array $error = null)
|
||||||
{
|
{
|
||||||
self::$reservedMemory = '';
|
if (null === self::$reservedMemory) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$reservedMemory = null;
|
||||||
|
|
||||||
$handler = set_error_handler('var_dump', 0);
|
$handler = set_error_handler('var_dump', 0);
|
||||||
$handler = is_array($handler) ? $handler[0] : null;
|
$handler = is_array($handler) ? $handler[0] : null;
|
||||||
@ -527,14 +547,15 @@ class ErrorHandler
|
|||||||
// Handled below
|
// Handled below
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error && ($error['type'] & (E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR))) {
|
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
|
||||||
// Let's not throw anymore but keep logging
|
// Let's not throw anymore but keep logging
|
||||||
$handler->throwAt(0, true);
|
$handler->throwAt(0, true);
|
||||||
|
$trace = isset($error['backtrace']) ? $error['backtrace'] : null;
|
||||||
|
|
||||||
if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
|
if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
|
||||||
$exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false);
|
$exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
|
||||||
} else {
|
} else {
|
||||||
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true);
|
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
|
||||||
}
|
}
|
||||||
} elseif (!isset($exception)) {
|
} elseif (!isset($exception)) {
|
||||||
return;
|
return;
|
||||||
|
@ -35,11 +35,19 @@ use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErr
|
|||||||
*/
|
*/
|
||||||
class FatalErrorException extends LegacyFatalErrorException
|
class FatalErrorException extends LegacyFatalErrorException
|
||||||
{
|
{
|
||||||
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true)
|
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code, $severity, $filename, $lineno);
|
parent::__construct($message, $code, $severity, $filename, $lineno);
|
||||||
|
|
||||||
if (null !== $traceOffset) {
|
if (null !== $trace) {
|
||||||
|
if (!$traceArgs) {
|
||||||
|
foreach ($trace as &$frame) {
|
||||||
|
unset($frame['args'], $frame['this'], $frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setTrace($trace);
|
||||||
|
} elseif (null !== $traceOffset) {
|
||||||
if (function_exists('xdebug_get_function_stack')) {
|
if (function_exists('xdebug_get_function_stack')) {
|
||||||
$trace = xdebug_get_function_stack();
|
$trace = xdebug_get_function_stack();
|
||||||
if (0 < $traceOffset) {
|
if (0 < $traceOffset) {
|
||||||
@ -48,7 +56,7 @@ class FatalErrorException extends LegacyFatalErrorException
|
|||||||
|
|
||||||
foreach ($trace as &$frame) {
|
foreach ($trace as &$frame) {
|
||||||
if (!isset($frame['type'])) {
|
if (!isset($frame['type'])) {
|
||||||
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
|
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
|
||||||
if (isset($frame['class'])) {
|
if (isset($frame['class'])) {
|
||||||
$frame['type'] = '::';
|
$frame['type'] = '::';
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,9 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
if (PHP_VERSION_ID >= 70000) {
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
|
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
|
||||||
}
|
}
|
||||||
|
if (defined('HHVM_VERSION')) {
|
||||||
|
$this->markTestSkipped('HHVM is not handled in this test case.');
|
||||||
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@ -86,6 +89,9 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
|
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
|
||||||
$this->markTestSkipped('The ContextErrorException class is already loaded.');
|
$this->markTestSkipped('The ContextErrorException class is already loaded.');
|
||||||
}
|
}
|
||||||
|
if (defined('HHVM_VERSION')) {
|
||||||
|
$this->markTestSkipped('HHVM is not handled in this test case.');
|
||||||
|
}
|
||||||
|
|
||||||
ErrorHandler::register();
|
ErrorHandler::register();
|
||||||
|
|
||||||
|
@ -393,6 +393,52 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHandleFatalErrorOnHHVM()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$handler = ErrorHandler::register();
|
||||||
|
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
$logger
|
||||||
|
->expects($this->once())
|
||||||
|
->method('log')
|
||||||
|
->with(
|
||||||
|
$this->equalTo(LogLevel::CRITICAL),
|
||||||
|
$this->equalTo('Fatal Error: foo'),
|
||||||
|
$this->equalTo(array(
|
||||||
|
'type' => 1,
|
||||||
|
'file' => 'bar',
|
||||||
|
'line' => 123,
|
||||||
|
'level' => -1,
|
||||||
|
'stack' => array(456),
|
||||||
|
))
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
$handler->setDefaultLogger($logger, E_ERROR);
|
||||||
|
|
||||||
|
$error = array(
|
||||||
|
'type' => E_ERROR + 0x1000000, // This error level is used by HHVM for fatal errors
|
||||||
|
'message' => 'foo',
|
||||||
|
'file' => 'bar',
|
||||||
|
'line' => 123,
|
||||||
|
'context' => array(123),
|
||||||
|
'backtrace' => array(456),
|
||||||
|
);
|
||||||
|
|
||||||
|
call_user_func_array(array($handler, 'handleError'), $error);
|
||||||
|
$handler->handleFatalError($error);
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
restore_exception_handler();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
restore_error_handler();
|
||||||
|
restore_exception_handler();
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
*/
|
*/
|
||||||
|
@ -47,7 +47,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
|
|||||||
foreach ($definition->getMethodCalls() as $call) {
|
foreach ($definition->getMethodCalls() as $call) {
|
||||||
try {
|
try {
|
||||||
$calls[] = array($call[0], $this->processArguments($call[1], true));
|
$calls[] = array($call[0], $this->processArguments($call[1], true));
|
||||||
} catch (RuntimeException $ignore) {
|
} catch (RuntimeException $e) {
|
||||||
// this call is simply removed
|
// this call is simply removed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
|
|||||||
try {
|
try {
|
||||||
$value = $this->processArguments(array($value), true);
|
$value = $this->processArguments(array($value), true);
|
||||||
$properties[$name] = reset($value);
|
$properties[$name] = reset($value);
|
||||||
} catch (RuntimeException $ignore) {
|
} catch (RuntimeException $e) {
|
||||||
// ignore property
|
// ignore property
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ class GraphvizDumper extends Dumper
|
|||||||
*/
|
*/
|
||||||
private function dotize($id)
|
private function dotize($id)
|
||||||
{
|
{
|
||||||
return strtolower(preg_replace('/[^\w]/i', '_', $id));
|
return strtolower(preg_replace('/\W/i', '_', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -673,7 +673,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenameThrowsExceptionOnError()
|
public function testRenameThrowsExceptionOnError()
|
||||||
{
|
{
|
||||||
$file = $this->workspace.DIRECTORY_SEPARATOR.uniqid();
|
$file = $this->workspace.DIRECTORY_SEPARATOR.uniqid('fs_test_', true);
|
||||||
$newPath = $this->workspace.DIRECTORY_SEPARATOR.'new_file';
|
$newPath = $this->workspace.DIRECTORY_SEPARATOR.'new_file';
|
||||||
|
|
||||||
$this->filesystem->rename($file, $newPath);
|
$this->filesystem->rename($file, $newPath);
|
||||||
|
@ -272,7 +272,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
|||||||
public function testFilter($adapter)
|
public function testFilter($adapter)
|
||||||
{
|
{
|
||||||
$finder = $this->buildFinder($adapter);
|
$finder = $this->buildFinder($adapter);
|
||||||
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return preg_match('/test/', $f) > 0; }));
|
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); }));
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class CustomFilterIteratorTest extends IteratorTestCase
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
|
array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
|
||||||
array(array(function (\SplFileInfo $fileinfo) { return preg_match('/^test/', $fileinfo) > 0; }), array('test.php', 'test.py')),
|
array(array(function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }), array('test.php', 'test.py')),
|
||||||
array(array('is_dir'), array()),
|
array(array('is_dir'), array()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
public function isFile()
|
public function isFile()
|
||||||
{
|
{
|
||||||
if (null === $this->type) {
|
if (null === $this->type) {
|
||||||
return preg_match('/file/', $this->getFilename());
|
return false !== strpos($this->getFilename(), 'file');
|
||||||
};
|
};
|
||||||
|
|
||||||
return self::TYPE_FILE === $this->type;
|
return self::TYPE_FILE === $this->type;
|
||||||
@ -60,7 +60,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
public function isDir()
|
public function isDir()
|
||||||
{
|
{
|
||||||
if (null === $this->type) {
|
if (null === $this->type) {
|
||||||
return preg_match('/directory/', $this->getFilename());
|
return false !== strpos($this->getFilename(), 'directory');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::TYPE_DIRECTORY === $this->type;
|
return self::TYPE_DIRECTORY === $this->type;
|
||||||
|
@ -249,7 +249,7 @@ class MockArraySessionStorage implements SessionStorageInterface
|
|||||||
*/
|
*/
|
||||||
protected function generateId()
|
protected function generateId()
|
||||||
{
|
{
|
||||||
return hash('sha256', uniqid(mt_rand()));
|
return hash('sha256', uniqid('ss_mock_', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadSession()
|
protected function loadSession()
|
||||||
|
@ -132,7 +132,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
|||||||
'file' => $r->getFileName(),
|
'file' => $r->getFileName(),
|
||||||
'line' => $r->getStartLine(),
|
'line' => $r->getStartLine(),
|
||||||
);
|
);
|
||||||
} catch (\ReflectionException $re) {
|
} catch (\ReflectionException $e) {
|
||||||
if (is_callable($controller)) {
|
if (is_callable($controller)) {
|
||||||
// using __call or __callStatic
|
// using __call or __callStatic
|
||||||
$this->data['controller'] = array(
|
$this->data['controller'] = array(
|
||||||
|
@ -234,7 +234,7 @@ class Esi implements SurrogateInterface
|
|||||||
$chunks[$i] = sprintf('<?php echo $this->surrogate->handle($this, %s, %s, %s) ?>'."\n",
|
$chunks[$i] = sprintf('<?php echo $this->surrogate->handle($this, %s, %s, %s) ?>'."\n",
|
||||||
var_export($options['src'], true),
|
var_export($options['src'], true),
|
||||||
var_export(isset($options['alt']) ? $options['alt'] : '', true),
|
var_export(isset($options['alt']) ? $options['alt'] : '', true),
|
||||||
isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false'
|
isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false'
|
||||||
);
|
);
|
||||||
++$i;
|
++$i;
|
||||||
$chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]);
|
$chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]);
|
||||||
|
@ -103,10 +103,10 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
try {
|
try {
|
||||||
$kernel->handle($request, $type);
|
$kernel->handle($request, $type);
|
||||||
$this->fail('->handle() suppresses the controller exception');
|
$this->fail('->handle() suppresses the controller exception');
|
||||||
} catch (\PHPUnit_Framework_Exception $exception) {
|
} catch (\PHPUnit_Framework_Exception $e) {
|
||||||
throw $exception;
|
throw $e;
|
||||||
} catch (\Exception $actual) {
|
} catch (\Exception $e) {
|
||||||
$this->assertSame($expected, $actual, '->handle() throws the controller exception');
|
$this->assertSame($expected, $e, '->handle() throws the controller exception');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class ProcessUtils
|
|||||||
|
|
||||||
$escapedArgument = '';
|
$escapedArgument = '';
|
||||||
$quote = false;
|
$quote = false;
|
||||||
foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
|
foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
|
||||||
if ('"' === $part) {
|
if ('"' === $part) {
|
||||||
$escapedArgument .= '\\"';
|
$escapedArgument .= '\\"';
|
||||||
} elseif (self::isSurroundedBy($part, '%')) {
|
} elseif (self::isSurroundedBy($part, '%')) {
|
||||||
|
@ -32,7 +32,7 @@ while ($read || $write) {
|
|||||||
}
|
}
|
||||||
$out = (binary) substr($out, $written);
|
$out = (binary) substr($out, $written);
|
||||||
}
|
}
|
||||||
if (null === $read && strlen($out) < 1) {
|
if (null === $read && '' === $out) {
|
||||||
$write = array_diff($write, array(STDOUT));
|
$write = array_diff($write, array(STDOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ while ($read || $write) {
|
|||||||
}
|
}
|
||||||
$err = (binary) substr($err, $written);
|
$err = (binary) substr($err, $written);
|
||||||
}
|
}
|
||||||
if (null === $read && strlen($err) < 1) {
|
if (null === $read && '' === $err) {
|
||||||
$write = array_diff($write, array(STDERR));
|
$write = array_diff($write, array(STDERR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,13 +177,13 @@ class AclProvider implements AclProviderInterface
|
|||||||
if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
|
if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
|
||||||
try {
|
try {
|
||||||
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
|
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
|
||||||
} catch (AclNotFoundException $aclNotFoundException) {
|
} catch (AclNotFoundException $e) {
|
||||||
if ($result->count()) {
|
if ($result->count()) {
|
||||||
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
|
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
|
||||||
$partialResultException->setPartialResult($result);
|
$partialResultException->setPartialResult($result);
|
||||||
throw $partialResultException;
|
throw $partialResultException;
|
||||||
} else {
|
} else {
|
||||||
throw $aclNotFoundException;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($loadedBatch as $loadedOid) {
|
foreach ($loadedBatch as $loadedOid) {
|
||||||
|
@ -63,10 +63,10 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
|
|||||||
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
|
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
|
||||||
|
|
||||||
$this->connection->commit();
|
$this->connection->commit();
|
||||||
} catch (\Exception $failed) {
|
} catch (\Exception $e) {
|
||||||
$this->connection->rollBack();
|
$this->connection->rollBack();
|
||||||
|
|
||||||
throw $failed;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-read the ACL from the database to ensure proper caching, etc.
|
// re-read the ACL from the database to ensure proper caching, etc.
|
||||||
@ -91,10 +91,10 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
|
|||||||
$this->deleteObjectIdentity($oidPK);
|
$this->deleteObjectIdentity($oidPK);
|
||||||
|
|
||||||
$this->connection->commit();
|
$this->connection->commit();
|
||||||
} catch (\Exception $failed) {
|
} catch (\Exception $e) {
|
||||||
$this->connection->rollBack();
|
$this->connection->rollBack();
|
||||||
|
|
||||||
throw $failed;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// evict the ACL from the in-memory identity map
|
// evict the ACL from the in-memory identity map
|
||||||
@ -338,10 +338,10 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->connection->commit();
|
$this->connection->commit();
|
||||||
} catch (\Exception $failed) {
|
} catch (\Exception $e) {
|
||||||
$this->connection->rollBack();
|
$this->connection->rollBack();
|
||||||
|
|
||||||
throw $failed;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->propertyChanges->offsetSet($acl, array());
|
$this->propertyChanges->offsetSet($acl, array());
|
||||||
|
@ -68,8 +68,8 @@ final class ObjectIdentity implements ObjectIdentityInterface
|
|||||||
} elseif (method_exists($domainObject, 'getId')) {
|
} elseif (method_exists($domainObject, 'getId')) {
|
||||||
return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject));
|
return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject));
|
||||||
}
|
}
|
||||||
} catch (\InvalidArgumentException $invalid) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new InvalidDomainObjectException($invalid->getMessage(), 0, $invalid);
|
throw new InvalidDomainObjectException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".');
|
throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".');
|
||||||
|
@ -28,7 +28,7 @@ class ObjectIdentityRetrievalStrategy implements ObjectIdentityRetrievalStrategy
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return ObjectIdentity::fromDomainObject($domainObject);
|
return ObjectIdentity::fromDomainObject($domainObject);
|
||||||
} catch (InvalidDomainObjectException $failed) {
|
} catch (InvalidDomainObjectException $e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,21 +55,21 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
||||||
} catch (NoAceFoundException $noObjectAce) {
|
} catch (NoAceFoundException $e) {
|
||||||
$aces = $acl->getClassAces();
|
$aces = $acl->getClassAces();
|
||||||
|
|
||||||
if (!$aces) {
|
if (!$aces) {
|
||||||
throw $noObjectAce;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
||||||
}
|
}
|
||||||
} catch (NoAceFoundException $noClassAce) {
|
} catch (NoAceFoundException $e) {
|
||||||
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
|
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
|
||||||
return $parentAcl->isGranted($masks, $sids, $administrativeMode);
|
return $parentAcl->isGranted($masks, $sids, $administrativeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $noClassAce;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,20 +86,20 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
||||||
} catch (NoAceFoundException $noObjectAces) {
|
} catch (NoAceFoundException $e) {
|
||||||
$aces = $acl->getClassFieldAces($field);
|
$aces = $acl->getClassFieldAces($field);
|
||||||
if (!$aces) {
|
if (!$aces) {
|
||||||
throw $noObjectAces;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
|
||||||
}
|
}
|
||||||
} catch (NoAceFoundException $noClassAces) {
|
} catch (NoAceFoundException $e) {
|
||||||
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
|
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
|
||||||
return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode);
|
return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $noClassAces;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class SecurityIdentityRetrievalStrategy implements SecurityIdentityRetrievalStra
|
|||||||
if (!$token instanceof AnonymousToken) {
|
if (!$token instanceof AnonymousToken) {
|
||||||
try {
|
try {
|
||||||
$sids[] = UserSecurityIdentity::fromToken($token);
|
$sids[] = UserSecurityIdentity::fromToken($token);
|
||||||
} catch (\InvalidArgumentException $invalid) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
// ignore, user has no user security identity
|
// ignore, user has no user security identity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class MaskBuilder extends AbstractMaskBuilder
|
|||||||
if ('1' === $bitmask[$i]) {
|
if ('1' === $bitmask[$i]) {
|
||||||
try {
|
try {
|
||||||
$pattern[$i] = self::getCode(1 << ($length - $i - 1));
|
$pattern[$i] = self::getCode(1 << ($length - $i - 1));
|
||||||
} catch (\Exception $notPredefined) {
|
} catch (\Exception $e) {
|
||||||
$pattern[$i] = self::ON;
|
$pattern[$i] = self::ON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->getProvider()->findAcls($oids);
|
$this->getProvider()->findAcls($oids);
|
||||||
|
|
||||||
$this->fail('Provider did not throw an expected exception.');
|
$this->fail('Provider did not throw an expected exception.');
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $e) {
|
||||||
$this->assertInstanceOf('Symfony\Component\Security\Acl\Exception\AclNotFoundException', $ex);
|
$this->assertInstanceOf('Symfony\Component\Security\Acl\Exception\AclNotFoundException', $e);
|
||||||
$this->assertInstanceOf('Symfony\Component\Security\Acl\Exception\NotAllAclsFoundException', $ex);
|
$this->assertInstanceOf('Symfony\Component\Security\Acl\Exception\NotAllAclsFoundException', $e);
|
||||||
|
|
||||||
$partialResult = $ex->getPartialResult();
|
$partialResult = $e->getPartialResult();
|
||||||
$this->assertTrue($partialResult->contains($oids[0]));
|
$this->assertTrue($partialResult->contains($oids[0]));
|
||||||
$this->assertFalse($partialResult->contains($oids[1]));
|
$this->assertFalse($partialResult->contains($oids[1]));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
try {
|
try {
|
||||||
$provider->findAcl($oid);
|
$provider->findAcl($oid);
|
||||||
$this->fail('ACL has not been properly deleted.');
|
$this->fail('ACL has not been properly deleted.');
|
||||||
} catch (AclNotFoundException $notFound) {
|
} catch (AclNotFoundException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
try {
|
try {
|
||||||
$provider->findAcl(new ObjectIdentity(1, 'Foo'));
|
$provider->findAcl(new ObjectIdentity(1, 'Foo'));
|
||||||
$this->fail('Child-ACLs have not been deleted.');
|
$this->fail('Child-ACLs have not been deleted.');
|
||||||
} catch (AclNotFoundException $notFound) {
|
} catch (AclNotFoundException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
try {
|
try {
|
||||||
$provider->updateAcl($acl1);
|
$provider->updateAcl($acl1);
|
||||||
$this->fail('Provider failed to detect a concurrent modification.');
|
$this->fail('Provider failed to detect a concurrent modification.');
|
||||||
} catch (ConcurrentModificationException $ex) {
|
} catch (ConcurrentModificationException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ class PermissionGrantingStrategyTest extends \PHPUnit_Framework_TestCase
|
|||||||
try {
|
try {
|
||||||
$strategy->isGranted($acl, array($requiredMask), array($sid));
|
$strategy->isGranted($acl, array($requiredMask), array($sid));
|
||||||
$this->fail('The ACE is not supposed to match.');
|
$this->fail('The ACE is not supposed to match.');
|
||||||
} catch (NoAceFoundException $noAce) {
|
} catch (NoAceFoundException $e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->assertTrue($strategy->isGranted($acl, array($requiredMask), array($sid)));
|
$this->assertTrue($strategy->isGranted($acl, array($requiredMask), array($sid)));
|
||||||
|
@ -113,13 +113,13 @@ class AclVoter implements VoterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return self::ACCESS_DENIED;
|
return self::ACCESS_DENIED;
|
||||||
} catch (AclNotFoundException $noAcl) {
|
} catch (AclNotFoundException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug('No ACL found for the object identity. Voting to deny access.');
|
$this->logger->debug('No ACL found for the object identity. Voting to deny access.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::ACCESS_DENIED;
|
return self::ACCESS_DENIED;
|
||||||
} catch (NoAceFoundException $noAce) {
|
} catch (NoAceFoundException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug('ACL found, no ACE applicable. Voting to deny access.');
|
$this->logger->debug('ACL found, no ACE applicable. Voting to deny access.');
|
||||||
}
|
}
|
||||||
|
@ -87,13 +87,13 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
$notFound->setUsername($username);
|
$e->setUsername($username);
|
||||||
throw $notFound;
|
throw $e;
|
||||||
} catch (\Exception $repositoryProblem) {
|
} catch (\Exception $e) {
|
||||||
$ex = new AuthenticationServiceException($repositoryProblem->getMessage(), 0, $repositoryProblem);
|
$e = new AuthenticationServiceException($e->getMessage(), 0, $e);
|
||||||
$ex->setToken($token);
|
$e->setToken($token);
|
||||||
throw $ex;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,13 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$user = $this->retrieveUser($username, $token);
|
$user = $this->retrieveUser($username, $token);
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
if ($this->hideUserNotFoundExceptions) {
|
if ($this->hideUserNotFoundExceptions) {
|
||||||
throw new BadCredentialsException('Bad credentials.', 0, $notFound);
|
throw new BadCredentialsException('Bad credentials.', 0, $e);
|
||||||
}
|
}
|
||||||
$notFound->setUsername($username);
|
$e->setUsername($username);
|
||||||
|
|
||||||
throw $notFound;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user instanceof UserInterface) {
|
if (!$user instanceof UserInterface) {
|
||||||
|
@ -47,7 +47,7 @@ class ChainUserProvider implements UserProviderInterface
|
|||||||
foreach ($this->providers as $provider) {
|
foreach ($this->providers as $provider) {
|
||||||
try {
|
try {
|
||||||
return $provider->loadUserByUsername($username);
|
return $provider->loadUserByUsername($username);
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
// try next one
|
// try next one
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,18 +67,18 @@ class ChainUserProvider implements UserProviderInterface
|
|||||||
foreach ($this->providers as $provider) {
|
foreach ($this->providers as $provider) {
|
||||||
try {
|
try {
|
||||||
return $provider->refreshUser($user);
|
return $provider->refreshUser($user);
|
||||||
} catch (UnsupportedUserException $unsupported) {
|
} catch (UnsupportedUserException $e) {
|
||||||
// try next one
|
// try next one
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
$supportedUserFound = true;
|
$supportedUserFound = true;
|
||||||
// try next one
|
// try next one
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($supportedUserFound) {
|
if ($supportedUserFound) {
|
||||||
$ex = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
|
$e = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
|
||||||
$ex->setUsername($user->getUsername());
|
$e->setUsername($user->getUsername());
|
||||||
throw $ex;
|
throw $e;
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
|
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,8 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
list($user, $credentials) = $this->getPreAuthenticatedData($request);
|
list($user, $credentials) = $this->getPreAuthenticatedData($request);
|
||||||
} catch (BadCredentialsException $exception) {
|
} catch (BadCredentialsException $e) {
|
||||||
$this->clearToken($exception);
|
$this->clearToken($e);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -90,8 +90,8 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
|||||||
$loginEvent = new InteractiveLoginEvent($request, $token);
|
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||||
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
|
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException $failed) {
|
} catch (AuthenticationException $e) {
|
||||||
$this->clearToken($failed);
|
$this->clearToken($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,21 +73,21 @@ class BasicAuthenticationListener implements ListenerInterface
|
|||||||
try {
|
try {
|
||||||
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey));
|
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey));
|
||||||
$this->tokenStorage->setToken($token);
|
$this->tokenStorage->setToken($token);
|
||||||
} catch (AuthenticationException $failed) {
|
} catch (AuthenticationException $e) {
|
||||||
$token = $this->tokenStorage->getToken();
|
$token = $this->tokenStorage->getToken();
|
||||||
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
|
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
|
||||||
$this->tokenStorage->setToken(null);
|
$this->tokenStorage->setToken(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->info('Basic authentication failed for user.', array('username' => $username, 'exception' => $failed));
|
$this->logger->info('Basic authentication failed for user.', array('username' => $username, 'exception' => $e));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->ignoreFailure) {
|
if ($this->ignoreFailure) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->setResponse($this->authenticationEntryPoint->start($request, $failed));
|
$event->setResponse($this->authenticationEntryPoint->start($request, $e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,11 +160,11 @@ class ContextListener implements ListenerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
} catch (UnsupportedUserException $unsupported) {
|
} catch (UnsupportedUserException $e) {
|
||||||
// let's try the next user provider
|
// let's try the next user provider
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->warning('Username could not be found in the selected user provider.', array('username' => $notFound->getUsername(), 'provider' => get_class($provider)));
|
$this->logger->warning('Username could not be found in the selected user provider.', array('username' => $e->getUsername(), 'provider' => get_class($provider)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -93,7 +93,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$serverDigestMd5 = $digestAuth->calculateServerDigest($user->getPassword(), $request->getMethod());
|
$serverDigestMd5 = $digestAuth->calculateServerDigest($user->getPassword(), $request->getMethod());
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
$this->fail($event, $request, new BadCredentialsException(sprintf('Username %s not found.', $digestAuth->getUsername())));
|
$this->fail($event, $request, new BadCredentialsException(sprintf('Username %s not found.', $digestAuth->getUsername())));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -83,12 +83,12 @@ class RememberMeListener implements ListenerInterface
|
|||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug('Populated the token storage with a remember-me token.');
|
$this->logger->debug('Populated the token storage with a remember-me token.');
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException $failed) {
|
} catch (AuthenticationException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->warning(
|
$this->logger->warning(
|
||||||
'The token storage was not populated with remember-me token as the'
|
'The token storage was not populated with remember-me token as the'
|
||||||
.' AuthenticationManager rejected the AuthenticationToken returned'
|
.' AuthenticationManager rejected the AuthenticationToken returned'
|
||||||
.' by the RememberMeServices.', array('exception' => $failed)
|
.' by the RememberMeServices.', array('exception' => $e)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,21 +123,21 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new RememberMeToken($user, $this->providerKey, $this->key);
|
return new RememberMeToken($user, $this->providerKey, $this->key);
|
||||||
} catch (CookieTheftException $theft) {
|
} catch (CookieTheftException $e) {
|
||||||
$this->cancelCookie($request);
|
$this->cancelCookie($request);
|
||||||
|
|
||||||
throw $theft;
|
throw $e;
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} catch (UsernameNotFoundException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->info('User for remember-me cookie not found.');
|
$this->logger->info('User for remember-me cookie not found.');
|
||||||
}
|
}
|
||||||
} catch (UnsupportedUserException $unSupported) {
|
} catch (UnsupportedUserException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->warning('User class for remember-me cookie not supported.');
|
$this->logger->warning('User class for remember-me cookie not supported.');
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException $invalid) {
|
} catch (AuthenticationException $e) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug('Remember-Me authentication failed.', array('exception' => $invalid));
|
$this->logger->debug('Remember-Me authentication failed.', array('exception' => $e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,12 +42,12 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$user = $this->getUserProvider($class)->loadUserByUsername($username);
|
$user = $this->getUserProvider($class)->loadUserByUsername($username);
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $e) {
|
||||||
if (!$ex instanceof AuthenticationException) {
|
if (!$e instanceof AuthenticationException) {
|
||||||
$ex = new AuthenticationException($ex->getMessage(), $ex->getCode(), $ex);
|
$e = new AuthenticationException($e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $ex;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user instanceof UserInterface) {
|
if (!$user instanceof UserInterface) {
|
||||||
|
@ -115,7 +115,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
|
|||||||
try {
|
try {
|
||||||
$service->autoLogin($request);
|
$service->autoLogin($request);
|
||||||
$this->fail('Expected CookieTheftException was not thrown.');
|
$this->fail('Expected CookieTheftException was not thrown.');
|
||||||
} catch (CookieTheftException $theft) {
|
} catch (CookieTheftException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME));
|
$this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME));
|
||||||
|
@ -48,7 +48,7 @@ class Inline
|
|||||||
|
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
if (0 == strlen($value)) {
|
if ('' === $value) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,9 +546,9 @@ class Parser
|
|||||||
|
|
||||||
// deal with trailing newlines as indicated
|
// deal with trailing newlines as indicated
|
||||||
if ('' === $indicator) {
|
if ('' === $indicator) {
|
||||||
$text = preg_replace('/\n+$/s', "\n", $text);
|
$text = preg_replace('/\n+$/', "\n", $text);
|
||||||
} elseif ('-' === $indicator) {
|
} elseif ('-' === $indicator) {
|
||||||
$text = preg_replace('/\n+$/s', '', $text);
|
$text = preg_replace('/\n+$/', '', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
@ -647,7 +647,7 @@ class Parser
|
|||||||
$value = $trimmedValue;
|
$value = $trimmedValue;
|
||||||
|
|
||||||
// remove end of the document marker (...)
|
// remove end of the document marker (...)
|
||||||
$value = preg_replace('#\.\.\.\s*$#s', '', $value);
|
$value = preg_replace('#\.\.\.\s*$#', '', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
Reference in New Issue
Block a user