Make WordPress Core

Opened 17 years ago

Closed 16 years ago

#5553 closed defect (bug) (fixed)

add_rewrite_endpoint does not work for attachments

Reported by: curioso's profile Curioso Owned by: westi's profile westi
Milestone: 2.9 Priority: normal
Severity: normal Version:
Component: Permalinks Keywords: needs-patch needs-testing
Focuses: Cc:

Description

The functionality for adding endpoints in rewrite rules does not work for attachments.
In wp-includes/rewrite.php:

                    //do endpoints for attachments
                    if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
                        if ($ep[0] & EP_ATTACHMENT) {
                            $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
                            $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
                        }
                    } }                                                                                              

should be:

                    //do endpoints for attachments
                    if ($endpoints) { foreach ($ep_query_append as $regex => $ep) {
                        if ($ep[0] & EP_ATTACHMENT) {
                            $rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(2);
                            $rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(2);
                        }
                    } }                                                                                              

Note the typing error in $endpoints, and the '?' is already present in $subquery.

Attachments (1)

5553.diff (835 bytes) - added by lloydbudd 17 years ago.
created diff based on code in Description. untested.

Download all attachments as: .zip

Change History (11)

#1 @westi
17 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.5 to 2.4
  • Owner changed from anonymous to westi
  • Status changed from new to assigned

#2 @lloydbudd
17 years ago

  • Summary changed from add_rewrite_endpoint does not work to add_rewrite_endpoint does not work for attachments

@lloydbudd
17 years ago

created diff based on code in Description. untested.

#3 @ffemtcj
17 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#4 @Denis-de-Bernardy
16 years ago

  • Keywords changed from has-patch, needs-testing to has-patch needs-testing
  • Milestone changed from 2.9 to 2.8

#5 @Denis-de-Bernardy
16 years ago

  • Component changed from General to Permalinks

#6 @Denis-de-Bernardy
16 years ago

see also: #9477. same bug, with a plugin to test

#7 @Denis-de-Bernardy
16 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 2.8 to Future Release

broken patch

#8 @Denis-de-Bernardy
16 years ago

  • Milestone changed from Future Release to 2.9

#9 @hakre
16 years ago

see also: #5553 (#9477 was a dupe)

#10 @ryan
16 years ago

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

(In [12271]) Fix attachment rewrite endpoints. Props Curioso. fixes #5553

Note: See TracTickets for help on using tickets.