Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug #811: PHP Documentation Link.

Still one more thing to do here, as the link in the header is still escaped.
  • Loading branch information...
commit cf303ac625b2caddb80935b1b561f58b584eeac0 1 parent ef6c2f9
@derickr authored
Showing with 98 additions and 43 deletions.
  1. +50 −0 tests/bug00811.phpt
  2. +3 −0  xdebug.c
  3. +0 −1  xdebug_private.h
  4. +45 −42 xdebug_var.c
View
50 tests/bug00811.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test for bug #811:
+--SKIPIF--
+<?php if (!version_compare(phpversion(), "5.3", '>=')) echo "skip >= PHP 5.3 needed\n"; ?>
+--INI--
+docref_root=http://www.php.net/
+docref_ext=.php
+html_errors=1
+xdebug.default_enable=1
+xdebug.file_link_format=
+--FILE--
+<?php
+// normal function
+date_create("hocuspocus", "fasdfasdf", "afsdfasdf");
+
+// static method
+DateTime::createFromFormat("fasdfdsaf", "fasdf", "fasdf");
+
+// ctor
+new ArrayObject("fasdfdsaf", "fasdf", "fasdf");
+?>
+--EXPECTF--
+<br />
+<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: date_create() expects at most 2 parameters, 3 given in %sbug00811.php on line <i>3</i></th></tr>
+<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
+<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
+<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00811.php' bgcolor='#eeeeec'>../bug00811.php<b>:</b>0</td></tr>
+<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.date-create.php' target='_new'>date_create</a>
+(%s)</td><td title='%sbug00811.php' bgcolor='#eeeeec'>../bug00811.php<b>:</b>3</td></tr>
+</table></font>
+<br />
+<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, string given in %sbug00811.php on line <i>6</i></th></tr>
+<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
+<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
+<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00811.php' bgcolor='#eeeeec'>../bug00811.php<b>:</b>0</td></tr>
+<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'><a href='http://www.php.net/DateTime.createFromFormat.php' target='_new'>createFromFormat</a>
+(%s)</td><td title='%sbug00811.php' bgcolor='#eeeeec'>../bug00811.php<b>:</b>6</td></tr>
+</table></font>
+<br />
+<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught exception 'InvalidArgumentException' with message 'ArrayObject::__construct() expects parameter 2 to be long, string given' in %sbug00811.php on line <i>9</i></th></tr>
+<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> InvalidArgumentException: ArrayObject::__construct() expects parameter 2 to be long, string given in %sbug00811.php on line <i>9</i></th></tr>
+<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
+<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
+<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00811.php' bgcolor='#eeeeec'>../bug00811.php<b>:</b>0</td></tr>
+<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'><a href='http://www.php.net/ArrayObject.construct.php' target='_new'>__construct</a>
+(%s)</td><td title='%sbug00811.php' bgcolor='#eeeeec'>../bug00811.php<b>:</b>9</td></tr>
+</table></font>
View
3  xdebug.c
@@ -1370,6 +1370,8 @@ void xdebug_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
}
fse = xdebug_add_stack_frame(edata, op_array, XDEBUG_EXTERNAL TSRMLS_CC);
+ fse->function.internal = 0;
+
/* A hack to make __call work with profiles. The function *is* user defined after all. */
if (fse && fse->prev && fse->function.function && (strcmp(fse->function.function, "__call") == 0)) {
fse->prev->user_defined = XDEBUG_EXTERNAL;
@@ -1516,6 +1518,7 @@ void xdebug_execute_internal(zend_execute_data *current_execute_data, struct _ze
}
fse = xdebug_add_stack_frame(edata, edata->op_array, XDEBUG_INTERNAL TSRMLS_CC);
+ fse->function.internal = 1;
function_nr = XG(function_count);
xdebug_trace_function_begin(fse, function_nr TSRMLS_CC);
View
1  xdebug_private.h
@@ -54,7 +54,6 @@ typedef struct xdebug_var {
#define XFUNC_NORMAL 0x01
#define XFUNC_STATIC_MEMBER 0x02
#define XFUNC_MEMBER 0x03
-#define XFUNC_NEW 0x04
#define XFUNC_INCLUDES 0x10
#define XFUNC_EVAL 0x10
View
87 xdebug_var.c
@@ -1691,64 +1691,67 @@ char* xdebug_xmlize(char *string, int len, int *newlen)
/*****************************************************************************
** Function name printing function
*/
-
-char* xdebug_show_fname(xdebug_func f, int html, int flags TSRMLS_DC)
+static char* xdebug_create_doc_link(xdebug_func f TSRMLS_DC)
{
- char *tmp;
+ char *tmp_target, *p, *retval;
switch (f.type) {
case XFUNC_NORMAL: {
- zend_function *zfunc;
+ tmp_target = xdebug_sprintf("function.%s", f.function);
+ break;
+ }
- if (PG(html_errors) && EG(function_table) && zend_hash_find(EG(function_table), f.function, strlen(f.function) + 1, (void**) &zfunc) == SUCCESS) {
- if (html && zfunc->type == ZEND_INTERNAL_FUNCTION) {
- return xdebug_sprintf("<a href='%s/%s%s' target='_new'>%s</a>\n",
- (PG(docref_root) && PG(docref_root)[0]) ? PG(docref_root) : "http://www.php.net",
- f.function, PG(docref_ext), f.function);
- } else {
- return xdstrdup(f.function);
- }
+ case XFUNC_STATIC_MEMBER:
+ case XFUNC_MEMBER: {
+ if (strcmp(f.function, "__construct") == 0) {
+ tmp_target = xdebug_sprintf("%s.construct", f.class);
} else {
- return xdstrdup(f.function);
+ tmp_target = xdebug_sprintf("%s.%s", f.class, f.function);
}
break;
}
+ }
- case XFUNC_NEW:
- if (!f.class) {
- f.class = "?";
- }
- if (!f.function) {
- f.function = "?";
- }
- tmp = xdmalloc(strlen(f.class) + 4 + 1);
- sprintf(tmp, "new %s", f.class);
- return tmp;
- break;
+ while ((p = strchr(tmp_target, '_')) != NULL) {
+ *p = '-';
+ }
- case XFUNC_STATIC_MEMBER:
- if (!f.class) {
- f.class = "?";
- }
- if (!f.function) {
- f.function = "?";
+ retval = xdebug_sprintf("<a href='%s%s%s' target='_new'>%s</a>\n",
+ (PG(docref_root) && PG(docref_root)[0]) ? PG(docref_root) : "http://www.php.net/",
+ tmp_target, PG(docref_ext), f.function);
+
+ xdfree(tmp_target);
+
+ return retval;
+}
+
+char* xdebug_show_fname(xdebug_func f, int html, int flags TSRMLS_DC)
+{
+ char *tmp;
+
+ switch (f.type) {
+ case XFUNC_NORMAL: {
+ if (PG(html_errors) && html && f.internal) {
+ return xdebug_create_doc_link(f TSRMLS_CC);
+ } else {
+ return xdstrdup(f.function);
}
- tmp = xdmalloc(strlen(f.function) + strlen(f.class) + 2 + 1);
- sprintf(tmp, "%s::%s", f.class, f.function);
- return tmp;
break;
+ }
- case XFUNC_MEMBER:
- if (!f.class) {
- f.class = "?";
- }
- if (!f.function) {
- f.function = "?";
+ case XFUNC_STATIC_MEMBER:
+ case XFUNC_MEMBER: {
+ if (PG(html_errors) && html && f.internal) {
+ return xdebug_create_doc_link(f TSRMLS_CC);
+ } else {
+ return xdebug_sprintf("%s%s%s",
+ f.class ? f.class : "?",
+ f.type == XFUNC_STATIC_MEMBER ? "::" : "->",
+ f.function ? f.function : "?"
+ );
}
- tmp = xdmalloc(strlen(f.function) + strlen(f.class) + 2 + 1);
- sprintf(tmp, "%s->%s", f.class, f.function);
- return tmp;
break;
+ }
case XFUNC_EVAL:
return xdstrdup("eval");
Please sign in to comment.
Something went wrong with that request. Please try again.