@@ -1318,20 +1318,14 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so
1318
1318
1319
1319
/* {{{ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) */
1320
1320
static void dom_parse_document (INTERNAL_FUNCTION_PARAMETERS , int mode ) {
1321
- zval * id ;
1322
1321
xmlDoc * docp = NULL , * newdoc ;
1323
1322
dom_doc_propsptr doc_prop ;
1324
1323
dom_object * intern ;
1325
1324
char * source ;
1326
1325
size_t source_len ;
1327
- int refcount , ret ;
1326
+ int refcount ;
1328
1327
zend_long options = 0 ;
1329
1328
1330
- id = getThis ();
1331
- if (id != NULL && ! instanceof_function (Z_OBJCE_P (id ), dom_document_class_entry )) {
1332
- id = NULL ;
1333
- }
1334
-
1335
1329
if (zend_parse_parameters (ZEND_NUM_ARGS (), "s|l" , & source , & source_len , & options ) == FAILURE ) {
1336
1330
RETURN_THROWS ();
1337
1331
}
@@ -1349,48 +1343,44 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) {
1349
1343
RETURN_FALSE ;
1350
1344
}
1351
1345
1352
- newdoc = dom_document_parser (id , mode , source , source_len , options );
1346
+ newdoc = dom_document_parser (ZEND_THIS , mode , source , source_len , options );
1353
1347
1354
1348
if (!newdoc )
1355
1349
RETURN_FALSE ;
1356
1350
1357
- if (id != NULL ) {
1358
- intern = Z_DOMOBJ_P (id );
1359
- size_t old_modification_nr = 0 ;
1360
- if (intern != NULL ) {
1361
- docp = (xmlDocPtr ) dom_object_get_node (intern );
1362
- doc_prop = NULL ;
1363
- if (docp != NULL ) {
1364
- const php_libxml_doc_ptr * doc_ptr = docp -> _private ;
1365
- ZEND_ASSERT (doc_ptr != NULL ); /* Must exist, we have a document */
1366
- old_modification_nr = doc_ptr -> cache_tag .modification_nr ;
1367
- php_libxml_decrement_node_ptr ((php_libxml_node_object * ) intern );
1368
- doc_prop = intern -> document -> doc_props ;
1369
- intern -> document -> doc_props = NULL ;
1370
- refcount = php_libxml_decrement_doc_ref ((php_libxml_node_object * )intern );
1371
- if (refcount != 0 ) {
1372
- docp -> _private = NULL ;
1373
- }
1374
- }
1375
- intern -> document = NULL ;
1376
- if (php_libxml_increment_doc_ref ((php_libxml_node_object * )intern , newdoc ) == -1 ) {
1377
- RETURN_FALSE ;
1351
+ intern = Z_DOMOBJ_P (ZEND_THIS );
1352
+ size_t old_modification_nr = 0 ;
1353
+ if (intern != NULL ) {
1354
+ docp = (xmlDocPtr ) dom_object_get_node (intern );
1355
+ doc_prop = NULL ;
1356
+ if (docp != NULL ) {
1357
+ const php_libxml_doc_ptr * doc_ptr = docp -> _private ;
1358
+ ZEND_ASSERT (doc_ptr != NULL ); /* Must exist, we have a document */
1359
+ old_modification_nr = doc_ptr -> cache_tag .modification_nr ;
1360
+ php_libxml_decrement_node_ptr ((php_libxml_node_object * ) intern );
1361
+ doc_prop = intern -> document -> doc_props ;
1362
+ intern -> document -> doc_props = NULL ;
1363
+ refcount = php_libxml_decrement_doc_ref ((php_libxml_node_object * )intern );
1364
+ if (refcount != 0 ) {
1365
+ docp -> _private = NULL ;
1378
1366
}
1379
- intern -> document -> doc_props = doc_prop ;
1380
1367
}
1381
-
1382
- php_libxml_increment_node_ptr ((php_libxml_node_object * )intern , (xmlNodePtr )newdoc , (void * )intern );
1383
- /* Since iterators should invalidate, we need to start the modification number from the old counter */
1384
- if (old_modification_nr != 0 ) {
1385
- php_libxml_doc_ptr * doc_ptr = (php_libxml_doc_ptr * ) ((php_libxml_node_object * ) intern )-> node ; /* downcast */
1386
- doc_ptr -> cache_tag .modification_nr = old_modification_nr ;
1387
- php_libxml_invalidate_node_list_cache (doc_ptr );
1368
+ intern -> document = NULL ;
1369
+ if (php_libxml_increment_doc_ref ((php_libxml_node_object * )intern , newdoc ) == -1 ) {
1370
+ RETURN_FALSE ;
1388
1371
}
1372
+ intern -> document -> doc_props = doc_prop ;
1373
+ }
1389
1374
1390
- RETURN_TRUE ;
1391
- } else {
1392
- DOM_RET_OBJ ((xmlNodePtr ) newdoc , & ret , NULL );
1375
+ php_libxml_increment_node_ptr ((php_libxml_node_object * )intern , (xmlNodePtr )newdoc , (void * )intern );
1376
+ /* Since iterators should invalidate, we need to start the modification number from the old counter */
1377
+ if (old_modification_nr != 0 ) {
1378
+ php_libxml_doc_ptr * doc_ptr = (php_libxml_doc_ptr * ) ((php_libxml_node_object * ) intern )-> node ; /* downcast */
1379
+ doc_ptr -> cache_tag .modification_nr = old_modification_nr ;
1380
+ php_libxml_invalidate_node_list_cache (doc_ptr );
1393
1381
}
1382
+
1383
+ RETURN_TRUE ;
1394
1384
}
1395
1385
/* }}} end dom_parser_document */
1396
1386
@@ -1865,18 +1855,15 @@ PHP_METHOD(DOMDocument, relaxNGValidateSource)
1865
1855
1866
1856
static void dom_load_html (INTERNAL_FUNCTION_PARAMETERS , int mode ) /* {{{ */
1867
1857
{
1868
- zval * id ;
1869
1858
xmlDoc * docp = NULL , * newdoc ;
1870
1859
dom_object * intern ;
1871
1860
dom_doc_propsptr doc_prop ;
1872
1861
char * source ;
1873
1862
size_t source_len ;
1874
- int refcount , ret ;
1863
+ int refcount ;
1875
1864
zend_long options = 0 ;
1876
1865
htmlParserCtxtPtr ctxt ;
1877
1866
1878
- id = getThis ();
1879
-
1880
1867
if (zend_parse_parameters (ZEND_NUM_ARGS (), "s|l" , & source , & source_len , & options ) == FAILURE ) {
1881
1868
RETURN_THROWS ();
1882
1869
}
@@ -1926,43 +1913,39 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
1926
1913
if (!newdoc )
1927
1914
RETURN_FALSE ;
1928
1915
1929
- if (id != NULL && instanceof_function (Z_OBJCE_P (id ), dom_document_class_entry )) {
1930
- intern = Z_DOMOBJ_P (id );
1931
- size_t old_modification_nr = 0 ;
1932
- if (intern != NULL ) {
1933
- docp = (xmlDocPtr ) dom_object_get_node (intern );
1934
- doc_prop = NULL ;
1935
- if (docp != NULL ) {
1936
- const php_libxml_doc_ptr * doc_ptr = docp -> _private ;
1937
- ZEND_ASSERT (doc_ptr != NULL ); /* Must exist, we have a document */
1938
- old_modification_nr = doc_ptr -> cache_tag .modification_nr ;
1939
- php_libxml_decrement_node_ptr ((php_libxml_node_object * ) intern );
1940
- doc_prop = intern -> document -> doc_props ;
1941
- intern -> document -> doc_props = NULL ;
1942
- refcount = php_libxml_decrement_doc_ref ((php_libxml_node_object * )intern );
1943
- if (refcount != 0 ) {
1944
- docp -> _private = NULL ;
1945
- }
1946
- }
1947
- intern -> document = NULL ;
1948
- if (php_libxml_increment_doc_ref ((php_libxml_node_object * )intern , newdoc ) == -1 ) {
1949
- RETURN_FALSE ;
1916
+ intern = Z_DOMOBJ_P (ZEND_THIS );
1917
+ size_t old_modification_nr = 0 ;
1918
+ if (intern != NULL ) {
1919
+ docp = (xmlDocPtr ) dom_object_get_node (intern );
1920
+ doc_prop = NULL ;
1921
+ if (docp != NULL ) {
1922
+ const php_libxml_doc_ptr * doc_ptr = docp -> _private ;
1923
+ ZEND_ASSERT (doc_ptr != NULL ); /* Must exist, we have a document */
1924
+ old_modification_nr = doc_ptr -> cache_tag .modification_nr ;
1925
+ php_libxml_decrement_node_ptr ((php_libxml_node_object * ) intern );
1926
+ doc_prop = intern -> document -> doc_props ;
1927
+ intern -> document -> doc_props = NULL ;
1928
+ refcount = php_libxml_decrement_doc_ref ((php_libxml_node_object * )intern );
1929
+ if (refcount != 0 ) {
1930
+ docp -> _private = NULL ;
1950
1931
}
1951
- intern -> document -> doc_props = doc_prop ;
1952
1932
}
1953
-
1954
- php_libxml_increment_node_ptr ((php_libxml_node_object * )intern , (xmlNodePtr )newdoc , (void * )intern );
1955
- /* Since iterators should invalidate, we need to start the modification number from the old counter */
1956
- if (old_modification_nr != 0 ) {
1957
- php_libxml_doc_ptr * doc_ptr = (php_libxml_doc_ptr * ) ((php_libxml_node_object * ) intern )-> node ; /* downcast */
1958
- doc_ptr -> cache_tag .modification_nr = old_modification_nr ;
1959
- php_libxml_invalidate_node_list_cache (doc_ptr );
1933
+ intern -> document = NULL ;
1934
+ if (php_libxml_increment_doc_ref ((php_libxml_node_object * )intern , newdoc ) == -1 ) {
1935
+ RETURN_FALSE ;
1960
1936
}
1937
+ intern -> document -> doc_props = doc_prop ;
1938
+ }
1961
1939
1962
- RETURN_TRUE ;
1963
- } else {
1964
- DOM_RET_OBJ ((xmlNodePtr ) newdoc , & ret , NULL );
1940
+ php_libxml_increment_node_ptr ((php_libxml_node_object * )intern , (xmlNodePtr )newdoc , (void * )intern );
1941
+ /* Since iterators should invalidate, we need to start the modification number from the old counter */
1942
+ if (old_modification_nr != 0 ) {
1943
+ php_libxml_doc_ptr * doc_ptr = (php_libxml_doc_ptr * ) ((php_libxml_node_object * ) intern )-> node ; /* downcast */
1944
+ doc_ptr -> cache_tag .modification_nr = old_modification_nr ;
1945
+ php_libxml_invalidate_node_list_cache (doc_ptr );
1965
1946
}
1947
+
1948
+ RETURN_TRUE ;
1966
1949
}
1967
1950
/* }}} */
1968
1951
0 commit comments