WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 20 months ago

Last modified 4 months ago

#41655 closed enhancement (fixed)

Enable dead_db() to be trappable always.

Reported by: gitlost Owned by: SergeyBiryukov
Milestone: 5.2 Priority: normal
Severity: normal Version:
Component: Database Keywords: has-patch
Focuses: Cc:

Description

It would be handy if dead_db() could be made trappable always, either through using wp_die() instead of die() in the terse case, or via a filter.

It currently causes WP-CLI (see https://github.com/wp-cli/wp-cli/pull/4303) to resort to a brittle hack in order to trap database connection errors.

Attachments (5)

terse_die-360.jpg (34.6 KB) - added by gitlost 3 years ago.
Terse die() at 360 width Firefox.
terse_wp_die-360.jpg (19.8 KB) - added by gitlost 3 years ago.
Terse wp_die() at 360 width Firefox.
terse_die-1280.jpg (37.5 KB) - added by gitlost 3 years ago.
Terse die() at 1280 width Firefox.
terse_wp_die-1280.jpg (22.6 KB) - added by gitlost 3 years ago.
Terse wp_die() at 1280 width Firefox.
41655.patch (856 bytes) - added by gitlost 3 years ago.
Patch to use wp_die() instead of die() in the terse case in dead_db().

Download all attachments as: .zip

Change History (14)

@gitlost
3 years ago

Terse die() at 360 width Firefox.

@gitlost
3 years ago

Terse wp_die() at 360 width Firefox.

@gitlost
3 years ago

Terse die() at 1280 width Firefox.

@gitlost
3 years ago

Terse wp_die() at 1280 width Firefox.

#1 @gitlost
3 years ago

The above are before/afters if die() were replaced by wp_die() in the terse case, eg

wp_die( '<h1>' . __( 'Error establishing a database connection' ) . '</h1>', __( 'Database Error' ) );
Last edited 3 years ago by gitlost (previous) (diff)

@gitlost
3 years ago

Patch to use wp_die() instead of die() in the terse case in dead_db().

#2 @Soean
3 years ago

  • Keywords has-patch added

#4 @spacedmonkey
21 months ago

  • Milestone changed from Awaiting Review to 5.2

Marking as 5.2. See arguments for this ticket here

#5 @SergeyBiryukov
20 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
20 months ago

Introduced in [6447] for #5500.

#7 @SergeyBiryukov
20 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 44827:

Database: Use wp_die() instead of die() in dead_db(), for more flexibility and consistency with other error messages in core.

Props gitlost.
Fixes #41655.

#8 @spacedmonkey
18 months ago

  • Keywords needs-dev-note added

#9 @desrosj
4 months ago

  • Keywords needs-dev-note removed

As far as I can tell, this one never received a dev note. Going to remove needs-dev-note as the ship has already sailed.

Note: See TracTickets for help on using tickets.