# MTEngine Upgrade Guide

Always back up before upgrading.

---

## Before Every Upgrade

1. Export full SQL dump from phpMyAdmin
2. Download/zip: `.env`, `storage/`, `uploads/`, `settings.json`
3. Optionally enable maintenance mode

---

## v1.0.0 → v1.0.1

### What changed
- CSRF protection added to `admin/assets/ajax/generate_product_description.php`
- HTML sanitizer (HtmlSanitizer.php) applied to product descriptions and AI landing pages
- .htaccess: ErrorDocument 404/403 fixed — no longer redirects to `/` (soft-404 fix)
- Pagination added: OrderModel::getPaginated() and ProductModel::getPaginated()
- SEO: order/success and lp-order-form/* now set noindex, nofollow
- OrderLifecycleEventModel schema migration hardened with static guard
- New: core/system/HtmlSanitizer.php
- New: install/upgrade_v1.0.0_to_v1.0.1.sql

### Step 1 — Run database migration

In phpMyAdmin SQL tab, run the contents of:
install/upgrade_v1.0.0_to_v1.0.1.sql

All statements are idempotent — safe to run on already-upgraded databases.

### Step 2 — Upload new files

Replace all files EXCEPT:
- .env
- storage/ folder
- uploads/ folder
- settings.json

### Step 3 — Clear OPcache
If your server uses OPcache, reset it from cPanel or restart PHP-FPM.

### Step 4 — Test
- Homepage and product pages load correctly
- Test order placement and order/success page
- Admin Products list shows pagination
- Admin Orders list shows pagination
- AI landing page public URL (/lp/slug) loads without errors

---

## Rollback

Restore file backup and database dump to return to previous state.

---

## Support
Contact support via your purchase platform's support page.
