Skip to content
Codewright

Work

ZoopaTeq: a shop working again after a hosting move

Client work · An online computer shop in Brackenfell, Cape Town ·

Diagnosis and repair. I didn't design or build the site. Visit zoopateq.co.za

from the owner’s first message to the shop open again
1 day
database tables repaired
86
rows backed up and checked before I changed anything
1 million
stuck background tasks running again
3,700

The short answer: ZoopaTeq moved its online shop to a new host in late October, and from then on the site couldn’t save anything new: not orders, not user accounts, not product imports, not design changes. One fault in the database caused all of it. I found it, repaired it, and had the shop open again within a day of the owner’s first message.

I didn’t design or build ZoopaTeq’s site. I was brought in to find out why it had stopped working after the move, and to fix it.

What the owner was seeing

  • The shop was hidden behind a “coming soon” page.
  • He couldn’t add a new administrator account.
  • Publishing CSS from the theme’s editor ended in an error.
  • WP All Import failed whenever it tried to update products and stock.

The last three looked like separate problems, each pointing at a different part of the site. They had one cause. The “coming soon” page was a WooCommerce setting, and it had to stay on until the database was fixed: with it off, customers would have reached a checkout that couldn’t save their order.

What was actually wrong

Every table in a WordPress database numbers its new rows itself: the next order gets the next number, the next user the one after that. When the site was copied to the new host, that numbering was stripped from 126 of the database’s 146 tables, and 80 of them also lost the rule that stops two rows sharing a number.

So from late October, new records in almost every part of the site were saved with the number 0. The first one went in. After that, new records either clashed with it or were saved in a state WordPress couldn’t find again. Changing things that already existed still worked, which is why so much of the site looked normal.

The site’s own error log said so, once I knew where to look:

Uncaught Exception: Duplicate entry '0' for key 'PRIMARY'
Uncaught TypeError: … Argument #2 ($post) must be of type WP_Post, null given

The first line is WP All Import trying to save a new record when one numbered 0 already existed. The second came from publishing CSS: the theme’s editor saves a new record before it publishes, that record got the number 0, and a plugin that checks every save was handed nothing to check.

The same fault had quietly stopped WooCommerce’s background tasks. Each run starts by saving a small record, and that record clashed every time. About 3,700 tasks had piled up, including WooCommerce’s own database update.

What I did

  1. Backed up the whole database before touching it: 146 tables and about a million rows, with each backup read back and counted against the live table.
  2. Took the correct structure for each table from the code installed on the site itself (WordPress, WooCommerce and each plugin), rather than from memory.
  3. Kept everything that had saved properly since the move, such as settings and page styles, and gave each a proper number. Records that had never saved properly were copied aside, not deleted.
  4. Restored the numbering and the rules on 86 tables. The rest belonged to plugins that are no longer installed, so I left them alone.
  5. Tested it by creating one of each kind of record: a post, a user, a setting, a background task and a shop order. Each got a proper number, and I deleted them again.
  6. Let the background queue catch up, WooCommerce’s database update included.
  7. Switched the “coming soon” page off, cleared the site’s cache, and went through the shop as a customer would on a phone: products, prices, the cart, and checkout with Payfast and EFT.

Every change went into a written log on the server, next to the backup.

The result

The shop has been open since 16 November. New orders, user accounts, CSS changes and product imports save again, and the background queue went from about 3,700 overdue tasks to a handful.

If you’re moving a site to a new host

Ask whoever moves it to confirm the database kept its keys and its numbering. Then check it yourself, which takes two minutes: in WordPress, go to Users, then Add New, and create a test user. If it saves, delete it and carry on. If WordPress won’t save it, stop and get the database looked at before customers try to buy anything.

Cameron

If your site broke after a move or an update, send me the address and a sentence about what you’re seeing. I reply within a working day.