Mantis - Quercus
Viewing Issue Advanced Details
2362 major always 01-23-08 12:03 06-05-08 19:19
davidsklar  
nam  
normal  
closed 3.1.5  
fixed  
none    
none 3.2.0  
0002362: When extending a built-in class (DOMXPath), parent constructor never gets called
Instantiating a class that extends DOMXPath doesn't work, because the parent constructor never gets called. This happens whether or not the child class explicitly calls the parent constructor.

Test case:

<?php

class Broken1 extends DOMXPath { }
class Broken2 extends DOMXPath { public function __construct($d) { parent::__construct($d); } }

$doc = new DOMDocument();
$doc->loadXml('<cake>chocolate</cake>');

$xpath = new DOMXPath($doc);
$broken1 = new Broken1($doc);
$broken2 = new Broken2($doc);

print "
\n";

print "DOMXPath:
\n";
print $xpath->query('/cake')->item(0)->textContent;
print "\n<hr/>\n";

print "Broken 1:
\n";
print $broken1->query('/cake')->item(0)->textContent;
print "\n<hr/>\n";

print "Broken 2:
\n";
print $broken2->query('/cake')->item(0)->textContent;
print "\n<hr/>\n";
?>

When run under Resin/Quercus 3.1.4 or 3.1.s080114, this produces the following results:

/home/david/quercus/resin-3.1.s080114/webapps/ROOT/inherit-test.php:10: Warning: function '__construct' has 1 required arguments, but only 0 were provided /home/david/quercus/resin-3.1.s080114/webapps/ROOT/inherit-test.php:11: Warning: function '__construct' has 1 required arguments, but only 0 were provided

DOMXPath:
chocolate

Broken 1:
500 Servlet Exception

com.caucho.quercus.QuercusException: com.caucho.quercus.lib.dom.DOMXPath.query:
null
    at com.caucho.quercus.env.JavaMethod.invoke(JavaMethod.java:104)
    at com.caucho.quercus.env.JavaInvoker.callMethod(JavaInvoker.java:604)
    at com.caucho.quercus.env.ObjectExtValue.callMethod(ObjectExtValue.java:602)
    at com.caucho.quercus.expr.MethodCallExpr.eval(MethodCallExpr.java:104)
    at com.caucho.quercus.expr.MethodCallExpr.eval(MethodCallExpr.java:92)
    at com.caucho.quercus.expr.FieldGetExpr.eval(FieldGetExpr.java:72)
    at com.caucho.quercus.env.JavaInvoker.evalArguments(JavaInvoker.java:415)
    at com.caucho.quercus.expr.FunctionExpr.evalImpl(FunctionExpr.java:170)
    at com.caucho.quercus.expr.FunctionExpr.eval(FunctionExpr.java:126)
    at com.caucho.quercus.program.ExprStatement.execute(ExprStatement.java:64)
    at com.caucho.quercus.program.BlockStatement.execute(BlockStatement.java:99)
    at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:239)
    at com.caucho.quercus.page.InterpretedPage.execute(InterpretedPage.java:61)
    at com.caucho.quercus.page.QuercusPage.executeTop(QuercusPage.java:119)
    at com.caucho.quercus.servlet.ResinQuercusServlet.service(ResinQuercusServlet.java:146)
    at com.caucho.quercus.servlet.QuercusServlet.service(QuercusServlet.java:353)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
    at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
    at com.caucho.server.port.TcpConnection.run(TcpConnection.java:603)
    at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
    at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
    at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.NullPointerException
    at com.caucho.quercus.lib.dom.DOMXPath.query(DOMXPath.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.caucho.quercus.env.JavaMethod.invoke(JavaMethod.java:97)
    at com.caucho.quercus.env.JavaInvoker.callMethod(JavaInvoker.java:604)
    at com.caucho.quercus.env.ObjectExtValue.callMethod(ObjectExtValue.java:602)
    at com.caucho.quercus.expr.MethodCallExpr.eval(MethodCallExpr.java:104)
    at com.caucho.quercus.expr.MethodCallExpr.eval(MethodCallExpr.java:92)
    at com.caucho.quercus.expr.FieldGetExpr.eval(FieldGetExpr.java:72)
    at com.caucho.quercus.env.JavaInvoker.evalArguments(JavaInvoker.java:415)
    at com.caucho.quercus.expr.FunctionExpr.evalImpl(FunctionExpr.java:170)
    at com.caucho.quercus.expr.FunctionExpr.eval(FunctionExpr.java:126)
    at com.caucho.quercus.program.ExprStatement.execute(ExprStatement.java:64)
    at com.caucho.quercus.program.BlockStatement.execute(BlockStatement.java:99)
    at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:239)
    at com.caucho.quercus.page.InterpretedPage.execute(InterpretedPage.java:61)
    at com.caucho.quercus.page.QuercusPage.executeTop(QuercusPage.java:119)
    at com.caucho.quercus.servlet.ResinQuercusServlet.service(ResinQuercusServlet.java:146)
    at com.caucho.quercus.servlet.QuercusServlet.service(QuercusServlet.java:353)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
    at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
    at com.caucho.server.port.TcpConnection.run(TcpConnection.java:603)
    at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
    at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
    at java.lang.Thread.run(Thread.java:613)


If you comment out the $broken1->query() line, then the same 500 error/NPE happens on the $broken2->query() line.

The expected result, run against PHP 5.2.3 is:



DOMXPath:

chocolate
<hr/>
Broken 1:

chocolate
<hr/>
Broken 2:

chocolate
<hr/>


Notes
(0003146)
nam   
06-05-08 19:19   
php/0k3-
php/1z11