In the case of Zend_Dom_Query and warnings raised by DOMDocument, would it
be a bad idea to capture the warnings and store them in an array?
BTW I found a dirty, filthy workaround for my problem with javascript in the
template... I updated the script to look like this, and now there are no
more complaints from DOMDocument:
<script type="text/javascript">
//<![CDATA[
document.write('<*'+'*a href="?enhanced=1" class="switch_modes">Switch to
Enhanced Mode<*'+'*/a>');
//]]>
</script>
But normally I don't think I should have to do this, so capturing the errors
would be really nice as to not upset PHPUnit.
--
Hector
On Mon, Feb 22, 2010 at 2:44 PM, Andrew Ballard <[email protected]> wrote:
> On Mon, Feb 22, 2010 at 5:13 PM, Hector Virgen <[email protected]> wrote:
> > It's amazing what a simple "@" can do to a line of code in PHP :)
> > hvir...@hector-mac:~/Web/library/ZendFramework-1.10.1$ svn diff -r
> > 20701:21134 library/Zend/Dom/Query.php
> > Index: library/Zend/Dom/Query.php
> > ===================================================================
> > --- library/Zend/Dom/Query.php
> > (.../branches/release-1.10/library/Zend/Dom/Query.php) (revision 20701)
> > +++ library/Zend/Dom/Query.php
> > (.../tags/release-1.10.1/library/Zend/Dom/Query.php) (revision 21134)
> > @@ -178,12 +178,12 @@
> > $type = $this->getDocumentType();
> > switch ($type) {
> > case self::DOC_XML:
> > - $success = @$domDoc->loadXML($document);
> > + $success = $domDoc->loadXML($document);
> > break;
> > case self::DOC_HTML:
> > case self::DOC_XHTML:
> > default:
> > - $success = @$domDoc->loadHTML($document);
> > + $success = $domDoc->loadHTML($document);
> > break;
> > }
> > So this explains why it worked in 1.10.0 and not in 1.10.1. Since PHPUnit
> > automatically promotes all warnings to exceptions, errors in loading the
> > HTML causes PHPUnit tests to fail.
> > As mentioned in the DOMDocument documentation (ha, what a mouthful!),
> > perhaps ZF should be handling these errors with a custom error handler:
> > http://us3.php.net/manual/en/domdocument.loadhtml.php
> > It seems the issue tracker is being worked on at the moment so I'll wait
> > until later to file the bug.
> > --
> > Hector
>
> I recently reported a similar issue (that has since been fixed) with
> Zend_Db_Adapter_Sqlsrv. In my case, it was a warning being generated
> by the DB adapter constructor that was raising an exception inside a
> custom error handler in Zend_Session. There are a number of places
> where ZF classes use the error control operator on function calls to
> suppress errors or warnings. A problem arises when this happens inside
> the scope of one of a handful of methods that defines a custom error
> handler to deal with their own errors and/or warnings.
>
> I'm not sure what the best solution is to deal with this, but I think
> it could use some attention.
>
> Andrew
>