Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP-r56657: Disable attachment pages for new installations #1436

Merged
merged 13 commits into from
Jun 23, 2024

Conversation

xxsimoxx
Copy link
Member

@xxsimoxx xxsimoxx commented May 8, 2024

As requested in #1434 this PR backports several WP changesets to achieve the result:

See https://core.trac.wordpress.org/ticket/57913

Backported:

Can't backport https://core.trac.wordpress.org/changeset/57358. Can't understand if it's needed.

Also a checkbox for this options in Settings -> Media would be nice.

Closes #1434

Description

Disable attachment pages for new installation.
wp_attachment_pages_enabled can be set to 0 from wp-admin/options.php page.

How has this been tested?

Locally and backported unit tests.

Types of changes

  • New feature

SergeyBiryukov and others added 7 commits May 8, 2024 09:02
WordPress creates attachment pages by default for every attachment uploaded. On the vast majority of sites, these attachment pages don't contain any meaningful information. They do however exist, get indexed by search engines, and sometimes even rank in search results, leading to bad results for users and site owners.

This commit introduces a `wp_attachment_pages_enabled` database option to control the attachment pages behavior:

* On existing sites, the option is set to `1` on upgrade, so that attachment pages continue to work as is.
* For new sites, the option is set to to `0` by default, which means attachment pages are redirected to the attachment URL.
* Sites that want to enable or disable the attachment pages can set the option to `1` or `0`, respectively.

Follow-up to https://core.trac.wordpress.org/changeset/2958, https://core.trac.wordpress.org/changeset/3303, https://core.trac.wordpress.org/changeset/7149, https://core.trac.wordpress.org/changeset/34690.

WP:Props aristath, poena, afercia, joostdevalk, jonoaldersonwp, azaozz, johnbillion, joedolson, basiliskan, audrasjb, davelo, rilwis, manfcarlo, tyxla, garrett-eclipse, seedsca, eatingrules, matveb, antpb, zodiac1978, oglekler, zunaid321, costdev, SergeyBiryukov.
Fixes https://core.trac.wordpress.org/ticket/57913.

Conflicts:
- src/wp-admin/includes/upgrade.php
- src/wp-includes/version.php
- tests/phpunit/tests/canonical.php

---

Merges https://core.trac.wordpress.org/changeset/56657 / WordPress/wordpress-develop@15e37005db to ClassicPress.
When attachment pages are disabled, change the links from "View Attachment Page" to "View Media File".

Follow-up to https://core.trac.wordpress.org/changeset/56657, https://core.trac.wordpress.org/changeset/56658.

WP:Props joedolson, ironprogrammer, oglekler.
Fixes https://core.trac.wordpress.org/ticket/57913.

---

Merges https://core.trac.wordpress.org/changeset/56711 / WordPress/wordpress-develop@dc31cf0624 to ClassicPress.
…sers.

Ensure logged out users are redirected to the media file when attachment pages are inactive. This removes the read_post capability check from the canonical redirects as anonymous users lack the permission.

This was previously committed in https://core.trac.wordpress.org/changeset/57310 before being reverted in https://core.trac.wordpress.org/changeset/57318. This update includes a fix to cover instances where revealing a URL could be considered a data leak and greatly expands the unit tests to ensure that this is covered along with many other instances.

Follow-up to https://core.trac.wordpress.org/changeset/56657, https://core.trac.wordpress.org/changeset/56658, https://core.trac.wordpress.org/changeset/56711, https://core.trac.wordpress.org/changeset/57310, https://core.trac.wordpress.org/changeset/57318.

WP:Props peterwilsoncc, jorbin, afercia, aristath, chesio, joppuyo, jorbin, lakshmananphp, poena, sergeybiryukov, swissspidy, johnbillion.
Fixes https://core.trac.wordpress.org/ticket/59866.
See https://core.trac.wordpress.org/ticket/57913.

Conflicts:
- tests/phpunit/tests/canonical.php

---

Merges https://core.trac.wordpress.org/changeset/57357 / WordPress/wordpress-develop@fe1df4023c to ClassicPress.
@xxsimoxx xxsimoxx added this to the 2.2 milestone May 8, 2024
@xxsimoxx xxsimoxx requested a review from KTS915 May 8, 2024 08:17
Copy link
Member

@KTS915 KTS915 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well!

aaronjorbin and others added 2 commits May 14, 2024 13:38
…sers.

Ensure logged out users are redirected to the media file when attachment pages are inactive. This removes the read_post capability check from the canonical redirects as anonymous users lack the permission.

This was previously committed in https://core.trac.wordpress.org/changeset/57310 before being reverted in https://core.trac.wordpress.org/changeset/57318. This update includes a fix to cover instances where revealing a URL could be considered a data leak and greatly expands the unit tests to ensure that this is covered along with many other instances.

Follow-up to https://core.trac.wordpress.org/changeset/56657, https://core.trac.wordpress.org/changeset/56658, https://core.trac.wordpress.org/changeset/56711, https://core.trac.wordpress.org/changeset/57310, https://core.trac.wordpress.org/changeset/57318.

WP:Props peterwilsoncc, jorbin, afercia, aristath, chesio, joppuyo, jorbin, lakshmananphp, poena, sergeybiryukov, swissspidy, johnbillion.
Fixes https://core.trac.wordpress.org/ticket/59866.
See https://core.trac.wordpress.org/ticket/57913.

Conflicts:
- tests/phpunit/tests/canonical.php

---

Merges https://core.trac.wordpress.org/changeset/57357 / WordPress/wordpress-develop@fe1df4023c to ClassicPress.
@xxsimoxx
Copy link
Member Author

@mattyrob mattyrob merged commit be1a1ea into ClassicPress:develop Jun 23, 2024
20 checks passed
@xxsimoxx xxsimoxx deleted the merge/wp-r56657 branch June 24, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💡 Disable attachment pages for new ClassicPress installations.
6 participants