Make WordPress Core

Opened 7 years ago

Last modified 4 years ago

#43893 new defect (bug)

The maybe_create_table() function has two definitions

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Awaiting Review Priority: low
Severity: normal Version:
Component: Database Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

The maybe_create_table() function has two definitions:

  1. https://github.com/WordPress/wordpress-develop/blob/c71a898f784d8435c07bcf9ec9e30560dd3abe19/src/wp-admin/includes/upgrade.php#L2187-L2219
  2. https://github.com/WordPress/wordpress-develop/blob/c71a898f784d8435c07bcf9ec9e30560dd3abe19/src/wp-admin/install-helper.php#L40-L70

The latter is contained within a function_exists() check, but this still means the function's behaviour can differ depending on which definition happens to load.

The function is not used at all in WordPress core. It (they?) should probably be deprecated.

Attachments (1)

43893.diff (2.0 KB) - added by valchovski 5 years ago.

Download all attachments as: .zip

Change History (6)

#1 @johnbillion
7 years ago

Oh, this applies to maybe_add_column() too. Again, not used in core.

#2 @subrataemfluence
7 years ago

Exactly. None of those functions are being used anywhere in the core. Also the comment in the first definition of maybe_create_table function is incorrect. It says:

This method checks for an existing database and creates a new one if it's not already present.

while it should be

This method checks for an existing table in the database and creates a new one if it's not already present.

May I please go for a patch? If yes, which function definition of the two to be considered for maybe_create_table?

#3 @johnjamesjacoby
5 years ago

May I please go for a patch?

You never need to ask. Go for it!

which function definition of the two to be considered

Go with the one in upgrade.php as it was more recently optimized in #8977.

@valchovski
5 years ago

#4 @valchovski
5 years ago

  • Keywords has-patch added; needs-patch removed

Hey!

Chiming in here with a patch removing the function definition from the install-helper.php and adjusting the comment at the upgrade.php definition.

Looking forward to hearing your thoughts!

#5 @johnbillion
4 years ago

  • Keywords 2nd-opinion added

Removing this definition is a bit complicated because different plugins use different definitions. Some manually include install-helper.php and some manually include upgrade.php.

Ref: https://wpdirectory.net/search/01EH56AVEDWNMKRTN5FE9W9QAN

Note: See TracTickets for help on using tickets.