WATranslate v4.8 — Admin Settings Moved to MySQL

PURPOSE

Application/admin settings are now stored in the existing WATranslate MySQL
database instead of using storage/branding/settings.json as the live store.

MYSQL TABLE

wa_settings

Structure:

setting_key    VARCHAR(100) PRIMARY KEY
setting_value  LONGTEXT NULL
updated_at     TIMESTAMP

SETTINGS STORED IN MYSQL

- Application name
- Login subtitle
- Web logo URL
- Web logo MIME type / dimensions
- Mobile logo URL
- Mobile logo MIME type / dimensions
- App icon/favicon URL
- App icon MIME type / dimensions
- Branding cache/version token

IMAGE FILES

The actual PNG/JPG/WebP files remain on disk:

uploads/branding/

MySQL stores the paths and metadata. Image binary data is NOT stored inside
MySQL.

ADMIN WORKFLOW DOES NOT CHANGE

... → Settings
change name/logo/icon/etc.
Save settings

The save operation now writes the values directly to wa_settings.

AUTOMATIC MIGRATION

No settings should be lost.

On the first request after installing v4.8:

1. WATranslate creates wa_settings automatically if it does not exist.
2. It reads the existing:
   storage/branding/settings.json
3. It imports the current values into MySQL.
4. It stores a migration marker in wa_settings.
5. It renames the old JSON file to:
   storage/branding/settings.pre-mysql-v4.8.json

That backup is no longer the active settings store.

After migration:
MYSQL = authoritative settings store.

The old backup is retained only for recovery/reference.

BACKWARD COMPATIBILITY

Older single-logo settings are still understood:
logo_url

If encountered during migration, that old logo is used as both:
- web_logo_url
- mobile_logo_url

until separate logos are saved.

DATABASE OUTAGE BEHAVIOR

If MySQL is temporarily unavailable during a page load, WATranslate falls back
to legacy/default branding so the login page can still render.

However:
ADMIN SAVES REQUIRE MYSQL.

If the database is unavailable, Settings will return a storage error rather
than pretending the change was saved.

TABLE CREATION

The PHP code runs:

CREATE TABLE IF NOT EXISTS wa_settings ...

automatically.

Therefore no manual SQL step is required if the configured MySQL user has the
normal CREATE TABLE permission.

database-v4.8.sql is included in this package for:
- inspection
- documentation
- optional manual creation through phpMyAdmin

FILES TO OVERWRITE

src/Branding.php

FILE INCLUDED FOR REFERENCE / OPTIONAL MANUAL SQL

database-v4.8.sql

NO OTHER FILES CHANGE.

In particular, this patch does NOT change:
- public/index.php
- public/api.php
- public/webhook.php
- app.js
- service-worker.js
- PushService.php
- Meta configuration
- Google configuration
- WhatsApp configuration
- database message/contact tables

INSTALL

1. Back up:
   public_html/whatsapp-server-translator/

2. Upload this ZIP into:
   public_html/whatsapp-server-translator/

3. Extract and overwrite.

4. Open/reload WATranslate once.

That first request triggers the MySQL table creation and JSON → MySQL import.

VERIFY IN PHPMYADMIN

Open the WATranslate database.

You should see:
wa_settings

Expected keys include:

name
login_subtitle
web_logo_url
web_logo_mime
web_logo_width
web_logo_height
mobile_logo_url
mobile_logo_mime
mobile_logo_width
mobile_logo_height
icon_url
icon_mime
icon_width
icon_height
updated_at
__branding_mysql_migration_v4_8

Then change something through:
... → Settings

and refresh wa_settings in phpMyAdmin.
The corresponding setting_value should update.

IMPORTANT

Do not manually edit image filenames in MySQL unless you know the exact
uploads/branding/ path.

Use the WATranslate Settings UI for normal changes.
