[wp-trac] [WordPress Trac] #59866: Attachment pages are only disabled for users that are logged in

WordPress Trac noreply at wordpress.org
Tue Dec 5 13:56:53 UTC 2023


#59866: Attachment pages are only disabled for users that are logged in
-------------------------------------------------+-------------------------
 Reporter:  joppuyo                              |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  6.4.2
Component:  Media                                |     Version:  6.4
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing has-unit-    |     Focuses:
  tests dev-feedback                             |
-------------------------------------------------+-------------------------
Changes (by chesio):

 * keywords:  has-patch needs-testing has-unit-tests => has-patch needs-
     testing has-unit-tests dev-feedback


Comment:

 Replying to [comment:20 SergeyBiryukov]:
 > Would be great to have some unit tests for this.

 I had a look and there is already a [https://github.com/WordPress
 /wordpress-develop/blob/trunk/tests/phpunit/tests/canonical.php#L411-L428
 test for this feature]. It currently passes, because the whole
 `Tests_Canonical` suite, which the test is part of,
 [https://github.com/WordPress/wordpress-
 develop/blob/trunk/tests/phpunit/tests/canonical.php#L15 sets up a backend
 user] before start. So the redirect feature is being tested for logged in
 user.

 I'm not sure how to proceed here: if the consensus is that the redirect
 should work for anonymous users in the same way as logged ones, then I
 believe the existing test should be fixed.

 Also I'm not sure why the `Tests_Canonical` suite is run with backend user
 set. I tend to think this is just a relic of some past refactoring. If I
 run the suite without call to `wp_set_current_user( self::$author_id );`
 in its setup method, all tests pass just fine - except for the
 `test_canonical_attachment_page_redirect_with_option_disabled` test...

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59866#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list