Make WordPress Core

Opened 16 years ago

Last modified 4 weeks ago

#12671 assigned enhancement

Installer page doesn't check if MySQL tables were created successfully

Reported by: thedotproduct's profile thedotproduct Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.9.2
Component: Upgrade/Install Keywords: needs-patch
Focuses: Cc:

Description

When running the web-based setup script - My Mysql user didn't have create permissions so no tables were created but the message (underneath all the MySQL errors) said setup was successful.

I think it would be worth doing a check for no MySQL errors before proclaiming the installation a success.

Change History (13)

#1 @scribu
16 years ago

  • Keywords needs-patch added; installer removed
  • Milestone changed from Unassigned to 3.0

I think it would be worth doing a check for no MySQL errors before proclaiming the installation a success.

Good idea. I think it should run with $wpdb->show_errors on.

#2 @nacin
16 years ago

  • Milestone changed from 3.0 to Future Release
  • Type changed from defect (bug) to enhancement

This one came in a little late for 3.0. Patches welcome :)

#3 @westi
16 years ago

  • Cc westi added

It might also be nice if possible to have a generic "capability" check for the mysql permissions that the db user has.

So that the core code / plugin can check to see if the db user has be granted x or y before it tries to do something.

#4 @wojtek.szkutnik
16 years ago

  • Keywords gsoc added

#5 @dd32
14 years ago

  • Owner dd32 deleted
  • Status changed from new to assigned

#6 @SergeyBiryukov
14 years ago

Closed #21136 as a duplicate.

#7 @r0uter
12 years ago

  • Cc 01tonythomas@… added

#8 @jwmarshall
12 years ago

Ran into this bug today. Very surprised, and disappointed, to see that this thread was opened over 4 years ago.

Screenshot: http://i.imgur.com/c1hDW9C.png

#9 @chriscct7
10 years ago

  • Keywords needs-testing added; mysql permissions gsoc removed

#10 @danielbachhuber
10 years ago

For WP-CLI, I've decided to assume any database errors during wp_install() is partial or total installation failure.

dbDelta() returns pretty helpful data for determining whether an installation was successful:

array (
  'wp_users' => 'Created table wp_users',
  'wp_usermeta' => 'Created table wp_usermeta',
  'wp_terms' => 'Created table wp_terms',
  'wp_term_taxonomy' => 'Created table wp_term_taxonomy',
  'wp_term_relationships' => 'Created table wp_term_relationships',
  'wp_commentmeta' => 'Created table wp_commentmeta',
  'wp_comments' => 'Created table wp_comments',
  'wp_links' => 'Created table wp_links',
  'wp_options' => 'Created table wp_options',
  'wp_postmeta' => 'Created table wp_postmeta',
  'wp_posts' => 'Created table wp_posts',
)

It would be nice if we could change the return signature of make_db_current_silent() to return this data, or just call dbDelta() directly in wp_install().

Because MySQL permissions can be restricted for table creation or SELECT, UPDATE, or DELETE statements, I think it would be difficult to write an interpreter for all potential errors.

Couple of options to improve things:

  1. Inspect the response value of dbDelta(), and warn the user if any tables weren't created as expected.
  2. Inspect $wpdb->last_error after make_db_current_silent(), populate_options(), and populate_roles() are called. It should be empty. If it's not, we can let the user know there were database errors on installation.

I'm not sure how to communicate "there were database errors on installation" to the end user, given they may be incapable of resolving them on their own. However, anything we do is better than the success message we currently show.

This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.


10 years ago

#12 @SergeyBiryukov
7 years ago

#45564 was marked as a duplicate.

#13 @juanmaguitar
4 weeks ago

  • Keywords needs-testing removed

Bug Report

Description

The installer reports a successful setup even when database table creation fails due to insufficient MySQL permissions.

Environment

  • WordPress: 6.9
  • PHP: 8.3.29
  • Server: PHP 8.3.29 Development Server (http://localhost:8080) started
  • Database: mysql 8.0.40(restricted user: no CREATE TABLE privilege)
  • Browser: Chrome 143.0.0.0
  • OS: macOS
  • Theme: n/a (fresh install)
  • MU Plugins: None
  • Plugins: None

Steps to Reproduce

Pre-requisites for these test instructions

  • Docker installed
  • PHP CLI (php -v should work)
  • A MySQL client (mysql CLI) – optional but handy

Start MySQL (example using Docker):

docker run --name wp-mysql-test \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_DATABASE=wp_test \
  -p 3306:3306 \
  -d mysql:8

Connect as root:

mysql -h 127.0.0.1 -P 3306 -u root -p

Create restricted DB user (no CREATE TABLE):

CREATE USER 'wpbroken'@'%' IDENTIFIED BY 'wpbroken';
GRANT SELECT, INSERT, UPDATE, DELETE ON wp_test.* TO 'wpbroken'@'%';
FLUSH PRIVILEGES;

Download and extract WordPress.

curl -LO https://wordpress.org/latest.zip
unzip latest.zip
cd wordpress

Serve locally:

php -S localhost:8080

Navigate to: http://localhost:8080
Use DB credentials:

  • Database: wp_test
  • User: wpbroken
  • Pass: wpbroken
  • Host: 127.0.0.1

Complete the installation steps.

Verify database contents:

SHOW TABLES FROM wp_test;

# Installer reports success despite missing tables.

Expected Results

Installer should detect database errors and fail the installation.

Actual Results

A lot of errors are displayed but after the errors a "success" message is displayed.

The errors show that the MySQL user (wpbroken) does not have permission to create tables. As a result, every CREATE TABLE query for WordPress core tables (e.g., wp_users, wp_options, wp_posts, taxonomy and comment tables) fails with “CREATE command denied”. Because those tables were never created, subsequent installer queries that assume they exist (INSERT, SELECT, SHOW FULL COLUMNS, DELETE) fail with “Table … doesn’t exist”, leading to a broken/empty database despite the installer continuing.

But after all those errors the installer displays success message even though no tables are created.

Success!
WordPress has been installed. Thank you, and enjoy!
Last edited 4 weeks ago by juanmaguitar (previous) (diff)
Note: See TracTickets for help on using tickets.