diff --git a/CHANGELOG.md b/CHANGELOG.md index a510ecce..9570f580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ #Changelog All Notable changes to `League\Csv` will be documented in this file +## 7.1.1 - 2015-05-20 + +### Fixed + +- `SplFileObject` flags were not always applied using query filter [bug fix #99](http://github.com/thephpleague/csv/issues/99) + ## 7.1.0 - 2015-05-06 ### Added diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index bf967aa9..72b1959f 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Config/Controls.php b/src/Config/Controls.php index ba6c76a9..92194a57 100644 --- a/src/Config/Controls.php +++ b/src/Config/Controls.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Config/Output.php b/src/Config/Output.php index 3d85a1f3..dd6e1acc 100644 --- a/src/Config/Output.php +++ b/src/Config/Output.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Exception/InvalidRowException.php b/src/Exception/InvalidRowException.php index 9649cf81..0fb02278 100644 --- a/src/Exception/InvalidRowException.php +++ b/src/Exception/InvalidRowException.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Modifier/MapIterator.php b/src/Modifier/MapIterator.php index 504b9b24..2306f1c3 100644 --- a/src/Modifier/MapIterator.php +++ b/src/Modifier/MapIterator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Modifier/QueryFilter.php b/src/Modifier/QueryFilter.php index 739028da..03beb52c 100644 --- a/src/Modifier/QueryFilter.php +++ b/src/Modifier/QueryFilter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -241,6 +241,10 @@ public function clearFilter() */ protected function applyBomStripping(Iterator $iterator) { + if (! $this->strip_bom) { + return $iterator; + } + if (! $this->isBomStrippable()) { $this->strip_bom = false; return $iterator; diff --git a/src/Modifier/RowFilter.php b/src/Modifier/RowFilter.php index 8f8f7967..b340a68b 100644 --- a/src/Modifier/RowFilter.php +++ b/src/Modifier/RowFilter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Modifier/StreamFilter.php b/src/Modifier/StreamFilter.php index a948101b..76321c4d 100644 --- a/src/Modifier/StreamFilter.php +++ b/src/Modifier/StreamFilter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Plugin/ColumnConsistencyValidator.php b/src/Plugin/ColumnConsistencyValidator.php index da8b0fe5..aa013b3d 100644 --- a/src/Plugin/ColumnConsistencyValidator.php +++ b/src/Plugin/ColumnConsistencyValidator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Plugin/ForbiddenNullValuesValidator.php b/src/Plugin/ForbiddenNullValuesValidator.php index c9f0ca8a..c4c36ae0 100644 --- a/src/Plugin/ForbiddenNullValuesValidator.php +++ b/src/Plugin/ForbiddenNullValuesValidator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Plugin/SkipNullValuesFormatter.php b/src/Plugin/SkipNullValuesFormatter.php index b00403cc..37118e0a 100644 --- a/src/Plugin/SkipNullValuesFormatter.php +++ b/src/Plugin/SkipNullValuesFormatter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Reader.php b/src/Reader.php index 64f72383..2955e11f 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Writer.php b/src/Writer.php index a25e29f3..824203a2 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/test/ControlsTest.php b/test/ControlsTest.php index ea4c45c4..d1837ce4 100644 --- a/test/ControlsTest.php +++ b/test/ControlsTest.php @@ -189,4 +189,37 @@ public function testCustomNewline() $csv->setNewline("\r\n"); $this->assertSame("\r\n", $csv->getNewline()); } + + /** + * @param $flag + * @param $line_count + * @dataProvider appliedFlagsProvider + */ + public function testAppliedFlags($flag, $line_count) + { + $path = __DIR__."/data/tmp.txt"; + $obj = new SplFileObject($path, "w+"); + $obj->fwrite("1st\n2nd\n"); + $reader = Reader::createFromFileObject($obj); + $reader->setFlags($flag); + $this->assertCount($line_count, $reader->fetchAll()); + unlink($path); + } + + public function appliedFlagsProvider() + { + return [ + "NONE" => [0, 3], + "DROP_NEW_LINE" => [SplFileObject::DROP_NEW_LINE, 3], + "READ_AHEAD" => [SplFileObject::READ_AHEAD, 3], + "SKIP_EMPTY" => [SplFileObject::SKIP_EMPTY, 2], + "READ_AHEAD|DROP_NEW_LINE" => [SplFileObject::READ_AHEAD|SplFileObject::DROP_NEW_LINE, 3], + "READ_AHEAD|SKIP_EMPTY" => [SplFileObject::READ_AHEAD|SplFileObject::SKIP_EMPTY, 2], + "DROP_NEW_LINE|SKIP_EMPTY" => [SplFileObject::DROP_NEW_LINE|SplFileObject::SKIP_EMPTY, 2], + "READ_AHEAD|DROP_NEW_LINE|SKIP_EMPTY" => [ + SplFileObject::READ_AHEAD|SplFileObject::DROP_NEW_LINE|SplFileObject::SKIP_EMPTY, + 2 + ], + ]; + } }