WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#38874 new defect (bug)

Change include of "includes/plugin-install.php" to include_once

Reported by: engelen Owned by:
Milestone: 5.3 Priority: normal
Severity: normal Version: 3.1
Component: Plugins Keywords: has-patch needs-testing
Focuses: administration Cc:

Description

The file wp-admin/includes/plugin-install.php, which contains only functions and does not directly execute anything, is included from 4 different files:

  1. wp-admin/includes/ajax-actions.php - using include_once
  2. wp-admin/includes/class-wp-plugin-install-list-table.php - using include
  3. wp-admin/update-core.php - using require_once
  4. wp-admin/update.php - using include_once

The second yields problems when including wp-admin/includes/plugin-install.php using custom code, as the unconditional include will then yield a fatal error ("Cannot redeclare plugins_api()").

The include should be changed to include_once.

Attachments (1)

plugin-install-include.38874.diff (620 bytes) - added by engelen 3 years ago.
Change "include" to "include-once" for including "wp-admin/includes/plugin-install.php" in "wp-admin/includes/class-wp-plugin-install-list-table.php"

Download all attachments as: .zip

Change History (3)

@engelen
3 years ago

Change "include" to "include-once" for including "wp-admin/includes/plugin-install.php" in "wp-admin/includes/class-wp-plugin-install-list-table.php"

#1 @SergeyBiryukov
3 years ago

  • Component changed from Administration to Plugins

#2 @desrosj
3 months ago

  • Keywords has-patch needs-testing added
  • Milestone changed from Awaiting Review to 5.3
  • Version changed from 4.6.1 to 3.1

Hi @engelen,

First off, sorry that it took so long or someone to get back to you on this.

I've done some digging to connect the dots on some history. For reference, here is what I found:

  • The include_once in wp-admin/includes/ajax-actions.php was introduced in [37714] for version 4.6.
  • The include in wp-admin/includes/class-wp-plugin-install-list-table.php was introduced in [15491] for version 3.1.
  • The require_once in wp-admin/update-core.php was introduced in [12157] for version 2.9.
  • The include_once in wp-admin/update.php was introduced in [11005] for version 2.8 (formatting modified in [28500]).

The patch still applies for me, and this makes sense. I am going to milestone this for the next release to get it some attention, testing, and feedback.

Note: See TracTickets for help on using tickets.