Make WordPress Core

Opened 7 months ago

Closed 2 months ago

#63627 closed enhancement (fixed)

General: Only override `$table_prefix` if not defined

Reported by: ninos-ego's profile Ninos Ego Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.0 Priority: normal
Severity: normal Version: 6.9
Component: Bootstrap/Load Keywords: has-patch
Focuses: php-compatibility Cc:

Description

Only set the variable $table_prefix, if set before (e.g. via some kind of custom bootstrapper).

To use ??= operator we need >= php8.4, but happily referring to your documentation, this is already the current minimum requirement :D
https://wordpress.org/about/requirements/
-> bumped version in composer.json

Ref: https://github.com/WordPress/wordpress-develop/pull/9087

Change History (5)

This ticket was mentioned in PR #9087 on WordPress/wordpress-develop by @Ninos Ego.


7 months ago
#1

  • Keywords has-patch added

Only set the variable $table_prefix, if set before (e.g. via some kind of custom bootstrapper).

To use ??= operator we need >= php8.4, but happily referring to your documentation, this is already the current minimum requirement :D
https://wordpress.org/about/requirements/
-> bumped version in composer.json

Trac:
https://core.trac.wordpress.org/ticket/63627

#2 @dd32
7 months ago

Hi @ninos-ego,

Could you expand on the reasoning for the change? What are you attempting to achieve, what problem does this solve? etc

#3 @Ninos Ego
3 months ago

Sorry for the late response...

I'm using some kind of wordpress bootstrapper to preload some environment configs before initializing wordpress, e.g. database, url, proxy, settings, ... Useful at least for containerized environments.

My current workaround is writing following line of code before including wp-settings.php:

$table_prefix = $GLOBALS['table_prefix'];

Its not much line of codes, but I want to get rid of it (object-oriented coding). My patch will not break anything, it just gives a bit more flexibility initializing wordpress :-)

#4 @SergeyBiryukov
2 months ago

  • Component changed from General to Bootstrap/Load
  • Milestone changed from Awaiting Review to 7.0

#5 @SergeyBiryukov
2 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 61250:

Bootstrap/Load: Only override the $table_prefix global if not already defined.

This aims to provide more flexibility in preloading some environment settings before initializing WordPress.

Follow-up to [18993], [57748].

Props ninos-ego, dd32, swissspidy, SergeyBiryukov.
Fixes #63627.

Note: See TracTickets for help on using tickets.