#34023 [NEW]: [Patch] tidy extension misses getParent
| From: | mfischer@php.net | Date: | Sat, 06 Aug 2005 23:01:44 +0000 |
| Subject: | #34023 [NEW]: [Patch] tidy extension misses getParent | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-83108@lists.php.net to get a copy of this message | ||
From: mfischer@php.net
Operating system:
PHP version: 5CVS-2005-08-07 (dev)
PHP Bug Type: Feature/Change Request
Bug description: [Patch] tidy extension misses getParent
Description:
------------
The tidy library provides the getParent function which is currently not
exposed to PHP.
This patch enabled the getParent method:
Index: php_tidy.h
===================================================================
RCS file: /repository/php-src/ext/tidy/php_tidy.h,v
retrieving revision 1.25
diff -u -r1.25 php_tidy.h
--- php_tidy.h 25 Apr 2005 20:46:16 -0000 1.25
+++ php_tidy.h 15 Jul 2005 09:59:44 -0000
@@ -89,6 +89,7 @@
TIDY_NODE_METHOD(isJste);
TIDY_NODE_METHOD(isAsp);
TIDY_NODE_METHOD(isPhp);
+TIDY_NODE_METHOD(getParent);
ZEND_BEGIN_MODULE_GLOBALS(tidy)
char *default_config;
Index: tidy.c
===================================================================
RCS file: /repository/php-src/ext/tidy/tidy.c,v
retrieving revision 1.65
diff -u -r1.65 tidy.c
--- tidy.c 25 Apr 2005 20:46:16 -0000 1.65
+++ tidy.c 15 Jul 2005 09:59:45 -0000
@@ -291,6 +291,7 @@
TIDY_NODE_ME(isJste, NULL)
TIDY_NODE_ME(isAsp, NULL)
TIDY_NODE_ME(isPhp, NULL)
+ TIDY_NODE_ME(getParent, NULL)
{NULL, NULL, NULL}
};
@@ -1668,6 +1669,30 @@
}
/* }}} */
+/* {{{ proto boolean tidyNode::getParent()
+ Returns the parent node if available or NULL */
+TIDY_NODE_METHOD(getParent)
+{
+ TidyNode parent_node;
+ PHPTidyObj *newobj;
+ TIDY_FETCH_ONLY_OBJECT;
+
+ parent_node = tidyGetParent(obj->node);
+ if(parent_node) {
+ tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC);
+ newobj = (PHPTidyObj *) zend_object_store_get_object(return_value
TSRMLS_CC);
+ newobj->node = parent_node;
+ newobj->type = is_node;
+ newobj->ptdoc = obj->ptdoc;
+ newobj->ptdoc->ref_count++;
+ tidy_add_default_properties(newobj, is_node TSRMLS_CC);
+ } else {
+ ZVAL_NULL(return_value);
+ }
+}
+/* }}} */
+
+
static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS)
{
TIDY_NODE_CONST(ROOT, Root);
I've been running this patch on a nearly daily basis in a web crawling
application for a few thousands documents each run and saw no problems.
--
Edit bug report at http://bugs.php.net/?id=34023&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34023&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34023&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34023&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34023&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34023&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34023&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34023&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34023&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34023&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34023&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34023&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34023&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34023&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34023&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34023&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34023&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34023&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34023&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34023&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34023&r=mysqlcfg