Bugfix: Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0

Additional check that libxml is running at an appropriate version by testing if libxml flag value constants are defined
This commit is contained in:
MarkBaker 2014-09-05 10:20:12 +01:00
parent 57ce19d20a
commit f77d3d1668
3 changed files with 10 additions and 6 deletions

View File

@ -424,7 +424,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
// Create a new DOM object // Create a new DOM object
$dom = new DOMDocument; $dom = new DOMDocument;
// Reload the HTML file into the DOM object // Reload the HTML file into the DOM object
if (version_compare(PHP_VERSION, '5.4.0') >= 0) { if ((version_compare(PHP_VERSION, '5.4.0') >= 0) && defined(LIBXML_DTDLOAD)) {
$loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions()); $loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions());
} else { } else {
$loaded = $dom->loadHTMLFile($pFilename); $loaded = $dom->loadHTMLFile($pFilename);

View File

@ -363,10 +363,12 @@ class PHPExcel_Settings
*/ */
public static function setLibXmlLoaderOptions($options = null) public static function setLibXmlLoaderOptions($options = null)
{ {
if (is_null($options)) { if (is_null($options) && defined(LIBXML_DTDLOAD)) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR; $options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
} }
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
self::$_libXmlLoaderOptions = $options; self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions } // function setLibXmlLoaderOptions
@ -378,10 +380,12 @@ class PHPExcel_Settings
*/ */
public static function getLibXmlLoaderOptions() public static function getLibXmlLoaderOptions()
{ {
if (is_null(self::$_libXmlLoaderOptions)) { if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
} }
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
return self::$_libXmlLoaderOptions; return self::$_libXmlLoaderOptions;
} // function getLibXmlLoaderOptions } // function getLibXmlLoaderOptions
} }

View File

@ -29,7 +29,7 @@ Planned for v1.8.1
- Bugfix: (MBaker) - Fix to ensure that current cell is maintained when executing formula calculations - Bugfix: (MBaker) - Fix to ensure that current cell is maintained when executing formula calculations
- Bugfix: (MBaker) Work Item GH-350 - Keep/set the value on Reader _loadSheetsOnly as NULL, courtesy of Restless-ET - Bugfix: (MBaker) Work Item GH-350 - Keep/set the value on Reader _loadSheetsOnly as NULL, courtesy of Restless-ET
- Bugfix: (MBaker) Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception - Bugfix: (MBaker) Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception
- Bugfix: (MBaker) - Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag - Bugfix: (MBaker) Work Item GH-388 - Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag
- Bugfix: (MBaker) Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0 - Bugfix: (MBaker) Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0
- Bugfix: (MBaker) - Fix for percentage operator in formulae for BIFF Writer - Bugfix: (MBaker) - Fix for percentage operator in formulae for BIFF Writer
- General: (MBaker) - Small performance improvement for autosize columns - General: (MBaker) - Small performance improvement for autosize columns