Ticket #58536: 58536.diff
| File 58536.diff, 2.1 KB (added by , 3 years ago) |
|---|
-
src/wp-includes/rewrite.php
594 594 } 595 595 } 596 596 597 if ( preg_match( '/^[^%]*%(?:postname|category|tag|author)%/', get_option( 'permalink_structure' ) ) ) { 598 $use_verbose_page_rules = true; 599 } else { 600 $use_verbose_page_rules = false; 601 } 602 597 603 // Look for matches. 598 604 $request_match = $request; 599 605 foreach ( (array) $rewrite as $match => $query ) { … … 606 612 607 613 if ( preg_match( "#^$match#", $request_match, $matches ) ) { 608 614 609 if ( $ wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {615 if ( $use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { 610 616 // This is a verbose page match, let's check to be sure about it. 611 617 $page = get_page_by_path( $matches[ $varmatch[1] ] ); 612 618 if ( ! $page ) { -
tests/phpunit/tests/rewrite.php
504 504 $this->assertIsArray( $rewrite_rules ); 505 505 $this->assertNotEmpty( $rewrite_rules ); 506 506 } 507 508 /** 509 * @group multisite 510 * @ticket 58536 511 */ 512 public function test_url_to_postid_of_verose_page_rules_upon_switch_to_blog() { 513 global $wp_rewrite; 514 515 // Make sure the current blog does not use verbose page rules. 516 $this->assertFalse( $wp_rewrite->use_verbose_page_rules ); 517 518 $new_blog_id = self::factory()->blog->create(); 519 switch_to_blog( $new_blog_id ); 520 521 $this->set_permalink_structure( '/blog/%postname%/' ); 522 523 $post_id = self::factory()->post->create(); 524 $permalink = get_permalink( $post_id ); 525 526 restore_current_blog(); 527 // Re-initialise the rewrite rule as if switch_to_blog would never happen. 528 $wp_rewrite->init(); 529 $this->assertFalse( $wp_rewrite->use_verbose_page_rules ); 530 531 switch_to_blog( $new_blog_id ); 532 $this->assertEquals( url_to_postid( $permalink ), $post_id ); 533 } 507 534 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)