Make WordPress Core

Opened 9 months ago

Last modified 12 days ago

#61071 reopened enhancement

Need to display appropriate error messages when the database table is empty or corrupted.

Reported by: vishalvaland's profile vishalvaland Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.4
Component: Database Keywords: 2nd-opinion reporter-feedback
Focuses: Cc:

Description

A few days ago, I received a new issue from the client regarding the "Error Establishing Database Connection." Upon investigation, I discovered that this error occurred due to an empty or corrupted wp_options table. After repairing the table, the site functioned normally.

Given that the error message may mislead frontend developers into troubleshooting database connection issues unnecessarily, I recommend implementing a specific error message indicating that the connection is intact but the site is experiencing issues due to a corrupted or empty table. This will provide clearer guidance for troubleshooting.

Please review this suggestion and let me know if you have any questions or concerns.

Thank you!

Change History (5)

#1 @jrf
9 months ago

  • Component changed from Upgrade/Install to Database
  • Focuses sustainability coding-standards removed
  • Keywords needs-patch 2nd-opinion added; dev-feedback needs-testing reporter-feedback has-unit-tests removed
  • Type changed from defect (bug) to enhancement

#2 @deepakrohilla
7 months ago

@vishalvaland When WordPress encounters a corrupted or empty table in its database, it generate an error message indicating a database-related issue.

If WordPress can't establish a connection to the database due wrong host/username/password than it generates "Error establishing a database connection"

but if database connection has established and table is empty or corrupted than it generate
"One or more database tables are unavailable. The database may need to be repaired."

Last edited 7 months ago by deepakrohilla (previous) (diff)

#3 @OllieJones
6 weeks ago

  • Keywords reporter-feedback added; needs-patch removed

Investigating this issue.

Is it possible that the database server had crashed and not yet restarted when your user received the "Error Establishing a Database Connection" message then passed on to you?

And is it possible that, by the time you or your colleague investigated, the server had already restarted, but that some table was damaged, either by the crash or at some other time?

That would explain the database connnection problem. That message only gets generated (in core at any rate) by actual connection failures, not by query failures for damaged tables.

Do you have any further information on what happened?

#4 @vishalvaland
12 days ago

  • Resolution set to invalid
  • Status changed from new to closed

Yes got it @OllieJones but I just want to suggest here, like if that table are damaged. On that case I recommend implementing a specific error message indicating that the connection is intact but the site is experiencing issues due to a corrupted or empty table. This will provide clearer guidance for troubleshooting.

#5 @vishalvaland
12 days ago

  • Resolution invalid deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.