Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#42579 closed defect (bug) (fixed)

Correct the logic in extract_from_markers()

Reported by: stodorovic's profile stodorovic Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.9.1 Priority: high
Severity: normal Version: 4.9
Component: Rewrite Rules Keywords: fixed-major
Focuses: administration Cc:

Description

I created simple PHP script to test function extract_from_markers:

<?php
include_once( __DIR__.'/wp-load.php' );
require_once(ABSPATH . 'wp-admin/includes/admin.php');

$wprules = extract_from_markers( ABSPATH.'.htaccess', 'WordPress' );

var_dump( $wprules );

Result (WP 4.9):

array(0) {
}

Result (WP 4.8.3):

array(9) {
  [0] =>
  string(24) "<IfModule mod_rewrite.c>"
  [1] =>
  string(16) "RewriteEngine On"
  [2] =>
  string(13) "RewriteBase /"
  [3] =>
  string(30) "RewriteRule ^index\.php$ - [L]"
  [4] =>
  string(35) "RewriteCond %{REQUEST_FILENAME} !-f"
  [5] =>
  string(35) "RewriteCond %{REQUEST_FILENAME} !-d"
  [6] =>
  string(28) "RewriteRule . /index.php [L]"
  [7] =>
  string(11) "</IfModule>"
  [8] =>
  string(0) ""
}

It seems that's bug and correct code should be (function extract_from_markers):

        foreach ( $markerdata as $markerline ) {
                if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
                        $state = false;  
                }
                if ( $state ) {
                        $result[] = $markerline;
                }
                if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
                                $state = true;
                }
        }

Related topic: https://wordpress.org/support/topic/rewrite-rules-must-be-updated-message-on-wordpress-4-9/

Thanks in advance,
Sasa

Change History (6)

#1 @SergeyBiryukov
7 years ago

  • Milestone changed from Awaiting Review to 4.9.1
  • Priority changed from normal to high

#2 @SergeyBiryukov
7 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 42199:

Rewrite Rules: Correct the logic in extract_from_markers() after [41928].

Props stodorovic.
Fixes #42579. See #39920.

#3 @SergeyBiryukov
7 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 4.9 branch.

#4 @dd32
7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 42213:

Rewrite Rules: Correct the logic in extract_from_markers() after [41928].

Props stodorovic, SergeyBiryukov.
Merges [42199] to the 4.9 branch.
Fixes #42579. See #39920.

#5 @johnbillion
7 years ago

  • Summary changed from Issue after Changeset 41928 to Correct the logic in extract_from_markers()

#6 @dd32
7 years ago

#42657 was marked as a duplicate.

Note: See TracTickets for help on using tickets.