diff --git a/package.xml b/package.xml index bc587bbf7d..bfc6d5161c 100644 --- a/package.xml +++ b/package.xml @@ -108,6 +108,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> -- Thanks to Juliette Reinders Folmer for the patch - Fixed bug #2566 : Author tag email validation doesn't support all TLDs -- Thanks to Juliette Reinders Folmer for the patch + - Fixed bug #2575 : Custom error messages don't have data replaced when cache is enabled diff --git a/src/Files/File.php b/src/Files/File.php index 4d47640d01..4a2e047167 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -170,6 +170,13 @@ class File */ protected $fixedCount = 0; + /** + * TRUE if errors are being replayed from the cache. + * + * @var boolean + */ + protected $replayingErrors = false; + /** * An array of sniffs that are being ignored. * @@ -1029,8 +1036,13 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s return true; } - // Work out the error message. - if (isset($this->ruleset->ruleset[$sniffCode]['message']) === true) { + // See if there is a custom error message format to use. + // But don't do this if we are replaying errors because replayed + // errors have already used the custom format and have had their + // data replaced. + if ($this->replayingErrors === false + && isset($this->ruleset->ruleset[$sniffCode]['message']) === true + ) { $message = $this->ruleset->ruleset[$sniffCode]['message']; } diff --git a/src/Files/LocalFile.php b/src/Files/LocalFile.php index 39b1073276..c0bc08b27a 100644 --- a/src/Files/LocalFile.php +++ b/src/Files/LocalFile.php @@ -171,6 +171,8 @@ private function replayErrors($errors, $warnings) $this->warningCount = 0; $this->fixableCount = 0; + $this->replayingErrors = true; + foreach ($errors as $line => $lineErrors) { foreach ($lineErrors as $column => $colErrors) { foreach ($colErrors as $error) { @@ -207,6 +209,8 @@ private function replayErrors($errors, $warnings) } } + $this->replayingErrors = false; + }//end replayErrors()