Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#45970 new defect (bug)

in IIS if web.confing <configuration has xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" attribute the WordPress creates new <configuration> section and the site craches with wrong web.config

Reported by: boychev's profile boychev Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0.3
Component: Rewrite Rules Keywords: needs-patch
Focuses: administration Cc:

Description (last modified by swissspidy)

in IIS if web.confing <configuration has xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" attribute the WordPress creates new <configuration> section and the site craches with wrong web.config error (2 <configuration> sections). It happens/triggers by example if you are trying to change the "Permalink Settings".

The code responsible for this check is located in \wp-admin\includes\misc.php (line 748)

	// First check if the rule already exists as in that case there is no need to re-add it
	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
	if ( $wordpress_rules->length > 0 )
		return true;

The fix could be to register the namespace:

$xpath->registerNamespace("x", "http://schemas.microsoft.com/.NetConfiguration/v2.0");

and then in $xpath->query to check also for /x:configuration/x:system.webServer/x:rewrite/x:rules/x:rule[starts-with(@name,\'WordPress\')]

In this way it works without problem and does not break the site.

Change History (1)

#1 @swissspidy
6 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.