@@ -1098,7 +1098,8 @@ PHP_METHOD(DOM_Document, normalizeDocument)
1098
1098
}
1099
1099
/* }}} end dom_document_normalize_document */
1100
1100
1101
- void php_dom_document_constructor (INTERNAL_FUNCTION_PARAMETERS )
1101
+ /* {{{ */
1102
+ PHP_METHOD (DOMDocument , __construct )
1102
1103
{
1103
1104
xmlDoc * docp = NULL , * olddoc ;
1104
1105
dom_object * intern ;
@@ -1137,19 +1138,13 @@ void php_dom_document_constructor(INTERNAL_FUNCTION_PARAMETERS)
1137
1138
}
1138
1139
php_libxml_increment_node_ptr ((php_libxml_node_object * )intern , (xmlNodePtr )docp , (void * )intern );
1139
1140
}
1140
-
1141
- /* {{{ */
1142
- PHP_METHOD (DOMDocument , __construct )
1143
- {
1144
- php_dom_document_constructor (INTERNAL_FUNCTION_PARAM_PASSTHRU );
1145
- }
1146
1141
/* }}} end DOMDocument::__construct */
1147
1142
1148
- char * _dom_get_valid_file_path (char * source , char * resolved_path , int resolved_path_len ) /* {{{ */
1143
+ const char * _dom_get_valid_file_path (const char * source , char * resolved_path , int resolved_path_len ) /* {{{ */
1149
1144
{
1150
1145
xmlURI * uri ;
1151
1146
xmlChar * escsource ;
1152
- char * file_dest ;
1147
+ const char * file_dest ;
1153
1148
int isFileUri = 0 ;
1154
1149
1155
1150
uri = xmlCreateURI ();
@@ -1199,7 +1194,7 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p
1199
1194
}
1200
1195
/* }}} */
1201
1196
1202
- static xmlDocPtr dom_document_parser (zval * id , int mode , char * source , size_t source_len , size_t options ) /* {{{ */
1197
+ xmlDocPtr dom_document_parser (zval * id , int mode , const char * source , size_t source_len , size_t options ) /* {{{ */
1203
1198
{
1204
1199
xmlDocPtr ret ;
1205
1200
xmlParserCtxtPtr ctxt = NULL ;
@@ -1208,10 +1203,14 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so
1208
1203
int old_error_reporting = 0 ;
1209
1204
char * directory = NULL , resolved_path [MAXPATHLEN + 1 ];
1210
1205
1211
- dom_object * intern = Z_DOMOBJ_P (id );
1212
- php_libxml_ref_obj * document = intern -> document ;
1213
-
1214
- libxml_doc_props const * doc_props = dom_get_doc_props_read_only (document );
1206
+ libxml_doc_props const * doc_props ;
1207
+ if (id == NULL ) {
1208
+ doc_props = dom_get_doc_props_read_only (NULL );
1209
+ } else {
1210
+ dom_object * intern = Z_DOMOBJ_P (id );
1211
+ php_libxml_ref_obj * document = intern -> document ;
1212
+ doc_props = dom_get_doc_props_read_only (document );
1213
+ }
1215
1214
validate = doc_props -> validateonparse ;
1216
1215
resolve_externals = doc_props -> resolveexternals ;
1217
1216
keep_blanks = doc_props -> preservewhitespace ;
@@ -1221,12 +1220,11 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so
1221
1220
xmlInitParser ();
1222
1221
1223
1222
if (mode == DOM_LOAD_FILE ) {
1224
- char * file_dest ;
1225
1223
if (CHECK_NULL_PATH (source , source_len )) {
1226
- zend_value_error ( "Path to document must not contain any null bytes" );
1224
+ zend_argument_value_error ( 1 , " must not contain any null bytes" );
1227
1225
return NULL ;
1228
1226
}
1229
- file_dest = _dom_get_valid_file_path (source , resolved_path , MAXPATHLEN );
1227
+ const char * file_dest = _dom_get_valid_file_path (source , resolved_path , MAXPATHLEN );
1230
1228
if (file_dest ) {
1231
1229
ctxt = xmlCreateFileParserCtxt (file_dest );
1232
1230
}
@@ -1312,15 +1310,15 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so
1312
1310
}
1313
1311
/* }}} */
1314
1312
1315
- void php_dom_finish_loading_document (zval * this , zval * return_value , xmlDocPtr newdoc )
1313
+ static void php_dom_finish_loading_document (zval * this , zval * return_value , xmlDocPtr newdoc )
1316
1314
{
1317
1315
if (!newdoc )
1318
1316
RETURN_FALSE ;
1319
1317
1320
1318
dom_object * intern = Z_DOMOBJ_P (this );
1321
1319
size_t old_modification_nr = 0 ;
1322
1320
if (intern != NULL ) {
1323
- bool is_html5_class = intern -> document -> is_html5_class ;
1321
+ bool is_modern_api_class = intern -> document -> is_modern_api_class ;
1324
1322
xmlDocPtr docp = (xmlDocPtr ) dom_object_get_node (intern );
1325
1323
dom_doc_propsptr doc_prop = NULL ;
1326
1324
if (docp != NULL ) {
@@ -1340,7 +1338,7 @@ void php_dom_finish_loading_document(zval *this, zval *return_value, xmlDocPtr n
1340
1338
RETURN_FALSE ;
1341
1339
}
1342
1340
intern -> document -> doc_props = doc_prop ;
1343
- intern -> document -> is_html5_class = is_html5_class ;
1341
+ intern -> document -> is_modern_api_class = is_modern_api_class ;
1344
1342
}
1345
1343
1346
1344
php_libxml_increment_node_ptr ((php_libxml_node_object * )intern , (xmlNodePtr )newdoc , (void * )intern );
@@ -1354,7 +1352,8 @@ void php_dom_finish_loading_document(zval *this, zval *return_value, xmlDocPtr n
1354
1352
RETURN_TRUE ;
1355
1353
}
1356
1354
1357
- void dom_parse_document (INTERNAL_FUNCTION_PARAMETERS , int mode , xmlDocPtr * doc_out ) {
1355
+ static void dom_parse_document (INTERNAL_FUNCTION_PARAMETERS , int mode )
1356
+ {
1358
1357
char * source ;
1359
1358
size_t source_len ;
1360
1359
zend_long options = 0 ;
@@ -1377,8 +1376,6 @@ void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode, xmlDocPtr *doc_o
1377
1376
}
1378
1377
1379
1378
xmlDocPtr newdoc = dom_document_parser (ZEND_THIS , mode , source , source_len , options );
1380
- * doc_out = newdoc ;
1381
-
1382
1379
php_dom_finish_loading_document (ZEND_THIS , return_value , newdoc );
1383
1380
}
1384
1381
@@ -1387,8 +1384,7 @@ Since: DOM Level 3
1387
1384
*/
1388
1385
PHP_METHOD (DOMDocument , load )
1389
1386
{
1390
- xmlDocPtr unused ;
1391
- dom_parse_document (INTERNAL_FUNCTION_PARAM_PASSTHRU , DOM_LOAD_FILE , & unused );
1387
+ dom_parse_document (INTERNAL_FUNCTION_PARAM_PASSTHRU , DOM_LOAD_FILE );
1392
1388
}
1393
1389
/* }}} end dom_document_load */
1394
1390
@@ -1397,8 +1393,7 @@ Since: DOM Level 3
1397
1393
*/
1398
1394
PHP_METHOD (DOMDocument , loadXML )
1399
1395
{
1400
- xmlDocPtr unused ;
1401
- dom_parse_document (INTERNAL_FUNCTION_PARAM_PASSTHRU , DOM_LOAD_STRING , & unused );
1396
+ dom_parse_document (INTERNAL_FUNCTION_PARAM_PASSTHRU , DOM_LOAD_STRING );
1402
1397
}
1403
1398
/* }}} end dom_document_loadxml */
1404
1399
@@ -1661,7 +1656,8 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
1661
1656
zval * id ;
1662
1657
xmlDoc * docp ;
1663
1658
dom_object * intern ;
1664
- char * source = NULL , * valid_file = NULL ;
1659
+ char * source = NULL ;
1660
+ const char * valid_file = NULL ;
1665
1661
size_t source_len = 0 ;
1666
1662
int valid_opts = 0 ;
1667
1663
zend_long flags = 0 ;
@@ -1771,7 +1767,8 @@ static void _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int typ
1771
1767
zval * id ;
1772
1768
xmlDoc * docp ;
1773
1769
dom_object * intern ;
1774
- char * source = NULL , * valid_file = NULL ;
1770
+ char * source = NULL ;
1771
+ const char * valid_file = NULL ;
1775
1772
size_t source_len = 0 ;
1776
1773
xmlRelaxNGParserCtxtPtr parser ;
1777
1774
xmlRelaxNGPtr sptr ;
@@ -2071,6 +2068,11 @@ PHP_METHOD(DOM_Document, registerNodeClass)
2071
2068
RETURN_THROWS ();
2072
2069
}
2073
2070
2071
+ if (basece -> ce_flags & ZEND_ACC_ABSTRACT ) {
2072
+ zend_argument_value_error (1 , "must be a non-abstract class" );
2073
+ RETURN_THROWS ();
2074
+ }
2075
+
2074
2076
if (ce == NULL || instanceof_function (ce , basece )) {
2075
2077
DOM_GET_THIS_INTERN (intern );
2076
2078
dom_set_doc_classmap (intern -> document , basece , ce );
0 commit comments