Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#3078] fix failing tests in 5.4.5
Browse files Browse the repository at this point in the history
- DOMXPath::query() no longer raises an exception on failure; it now
  raises an E_WARNING. Updated code to detect an E_WARNING and raise an
  exception when discovered.
  • Loading branch information
weierophinney committed Dec 10, 2012
1 parent 6956129 commit 11e62a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}
},
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"extra": {
"branch-alias": {
Expand Down
10 changes: 9 additions & 1 deletion src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use DOMDocument;
use DOMXPath;
use Zend\Stdlib\ErrorHandler;

/**
* Query DOM structures based on CSS selectors and/or XPath
Expand Down Expand Up @@ -314,6 +315,13 @@ protected function getNodeList($document, $xpathQuery)
: $xpath->registerPHPFunctions($this->xpathPhpFunctions);
}
$xpathQuery = (string) $xpathQuery;
return $xpath->query($xpathQuery);

ErrorHandler::start();
$nodeList = $xpath->query($xpathQuery);
$error = ErrorHandler::stop();
if ($error) {
throw $error;
}
return $nodeList;
}
}

0 comments on commit 11e62a7

Please sign in to comment.