diff --git a/CHANGELOG.md b/CHANGELOG.md index a5e4e5b90a..fd9e8fd4bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Improve Coverage for ODS Reader [#1545](https://github.com/phpoffice/phpspreadsheet/pull/1545) - Named formula implementation, and improved handling of Defined Names generally [#1535](https://github.com/PHPOffice/PhpSpreadsheet/pull/1535) - - fix resolution of relative named range values in the calculation engine; previously all named range values had been treated as absolute. +- fix resolution of relative named range values in the calculation engine; previously all named range values had been treated as absolute. +- Drop $this->spreadSheet null check from Xlsx Writer [#1646](https://github.com/phpoffice/phpspreadsheet/pull/1646) ### Deprecated @@ -49,6 +50,10 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - PrintArea causes exception [#1544](https://github.com/phpoffice/phpspreadsheet/pull/1544) +- Calculation/DateTime Failure With PHP8 [#1661](https://github.com/phpoffice/phpspreadsheet/pull/1661) +- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662) +- ReverseSort bug, exposed but not caused by PHP8 [#1660](https://github.com/phpoffice/phpspreadsheet/pull/1660) +- Bug setting Superscript/Subscript to false [#1567](https://github.com/phpoffice/phpspreadsheet/pull/1567) ## 1.14.1 - 2020-07-19 @@ -555,6 +560,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Ignore inlineStr type if formula element exists - @ncrypthic [#570](https://github.com/PHPOffice/PHPExcel/issues/570) - Excel 2007 Reader freezes because of conditional formatting - @rentalhost [#575](https://github.com/PHPOffice/PHPExcel/issues/575) - Readers will now parse files containing worksheet titles over 31 characters [#176](https://github.com/PHPOffice/PhpSpreadsheet/pull/176) +- Fixed PHP8 deprecation warning for libxml_disable_entity_loader() [#1625](https://github.com/phpoffice/phpspreadsheet/pull/1625) ### General @@ -576,4 +582,4 @@ For a comprehensive list of all class changes, and a semi-automated migration pa ## Previous versions of PHPExcel -The changelog for the project when it was called PHPExcel is [still available](./CHANGELOG.PHPExcel.md). +The changelog for the project when it was called PHPExcel is [still available](./CHANGELOG.PHPExcel.md). \ No newline at end of file diff --git a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index 55bba632ff..a65797c156 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -63,7 +63,7 @@ public static function threadSafeLibxmlDisableEntityLoaderAvailability() private function disableEntityLoaderCheck(): void { - if (Settings::getLibXmlDisableEntityLoader()) { + if (Settings::getLibXmlDisableEntityLoader() && \PHP_VERSION_ID < 80000) { $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); if (self::$libxmlDisableEntityLoaderValue === null) { @@ -74,7 +74,7 @@ private function disableEntityLoaderCheck(): void public static function shutdown(): void { - if (self::$libxmlDisableEntityLoaderValue !== null) { + if (self::$libxmlDisableEntityLoaderValue !== null && \PHP_VERSION_ID < 80000) { libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue); self::$libxmlDisableEntityLoaderValue = null; } diff --git a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php index 8f42af10cb..f98ff7e1e1 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -12,7 +12,10 @@ class XmlScannerTest extends TestCase { protected function setUp(): void { - libxml_disable_entity_loader(false); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader(false); + } } /** @@ -24,13 +27,19 @@ protected function setUp(): void */ public function testValidXML($filename, $expectedResult, $libxmlDisableEntityLoader): void { - $oldDisableEntityLoaderState = libxml_disable_entity_loader($libxmlDisableEntityLoader); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + $oldDisableEntityLoaderState = libxml_disable_entity_loader($libxmlDisableEntityLoader); + } $reader = XmlScanner::getInstance(new \PhpOffice\PhpSpreadsheet\Reader\Xml()); $result = $reader->scanFile($filename); self::assertEquals($expectedResult, $result); - libxml_disable_entity_loader($oldDisableEntityLoaderState); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader($oldDisableEntityLoaderState); + } } public function providerValidXML() @@ -56,13 +65,19 @@ public function testInvalidXML($filename, $libxmlDisableEntityLoader): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class); - libxml_disable_entity_loader($libxmlDisableEntityLoader); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader($libxmlDisableEntityLoader); + } $reader = XmlScanner::getInstance(new \PhpOffice\PhpSpreadsheet\Reader\Xml()); $expectedResult = 'FAILURE: Should throw an Exception rather than return a value'; $result = $reader->scanFile($filename); self::assertEquals($expectedResult, $result); - self::assertEquals($libxmlDisableEntityLoader, libxml_disable_entity_loader()); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + self::assertEquals($libxmlDisableEntityLoader, libxml_disable_entity_loader()); + } } public function providerInvalidXML() diff --git a/tests/PhpSpreadsheetTests/SettingsTest.php b/tests/PhpSpreadsheetTests/SettingsTest.php index 4dff2d2594..92f3bb1f66 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -14,20 +14,29 @@ class SettingsTest extends TestCase protected function setUp(): void { - $this->prevValue = libxml_disable_entity_loader(); - libxml_disable_entity_loader(false); // Enable entity loader + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + $this->prevValue = libxml_disable_entity_loader(); + libxml_disable_entity_loader(false); // Enable entity loader + } } protected function tearDown(): void { - libxml_disable_entity_loader($this->prevValue); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader($this->prevValue); + } } public function testGetXMLSettings(): void { $result = Settings::getLibXmlLoaderOptions(); self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR) & $result)); - self::assertFalse(libxml_disable_entity_loader()); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + self::assertFalse(libxml_disable_entity_loader()); + } } public function testSetXMLSettings(): void @@ -35,6 +44,9 @@ public function testSetXMLSettings(): void Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID); $result = Settings::getLibXmlLoaderOptions(); self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result)); - self::assertFalse(libxml_disable_entity_loader()); + // php 8.+ deprecated libxml_disable_entity_loader() - It's on by default + if (\PHP_VERSION_ID < 80000) { + self::assertFalse(libxml_disable_entity_loader()); + } } }