WordPress.org

Make WordPress Core

#43952 closed defect (bug) (fixed)

Database error inserting cron job on fresh install

Reported by: iandunn Owned by: iandunn
Milestone: 4.9.6 Priority: high
Severity: normal Version:
Component: Upgrade/Install Keywords: gdpr fixed-major
Focuses: Cc:

Description

A database error occurs when installing a fresh copy of trunk (and presumably the 4.9 branch).

WordPress database error: [Table 'wordpress_develop.wp_options' doesn't exist]
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('cron', 'a:2:{i:1525380534;a:1:{s:34:\"wp_privacy_delete_old_export_files\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:6:\"hourly\";s:4:\"args\";a:0:{}s:8:\"interval\";i:3600;}}}s:7:\"version\";i:2;}', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)

Reported in Slack, props @helen for catching it.

wp_schedule_delete_old_privacy_export_files() should be returning early during the install phase, but it's not. The bug was introduced in r43046.

Change History (3)

#1 @iandunn
16 months ago

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

In 43162:

Privacy: Return before scheduling cron during install to avoid error.

r43046 introduced wp_schedule_delete_old_privacy_export_files() to schedule the wp_privacy_delete_old_export_files cron job, but it did not check to make sure it wasn't running in the context of the install process. When it did run in that context, it created a database error, because the necessary database tables don't exist at that point.

Checking the current context and returning early during the installation phase avoids that issue.

Props helen, timothyblynjacobs, iandunn.
Fixes #43952.

#2 @iandunn
16 months ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backport to 4.9.

#3 @azaozz
16 months ago

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

In 43163:

Privacy: Return before scheduling cron during install to avoid error.

r43046 introduced wp_schedule_delete_old_privacy_export_files() to schedule the wp_privacy_delete_old_export_files cron job, but it did not check to make sure it wasn't running in the context of the install process. When it did run in that context, it created a database error, because the necessary database tables don't exist at that point.

Checking the current context and returning early during the installation phase avoids that issue.

Props helen, timothyblynjacobs, iandunn.
Merges [43162] to the 4.9 branch.
Fixes #43952.

Note: See TracTickets for help on using tickets.