WATranslate v4.8.2 — MySQL Settings Save Fix

SYMPTOM

Settings displayed:

Settings error: The server could not save the branding settings.

while wa_settings had already been created and the JSON → MySQL migration had
completed successfully.

WHAT THIS PATCH FIXES

1. REUSE THE EXISTING MYSQL CONNECTION

public/api.php already loads:

src/bootstrap.php

bootstrap.php creates the WATranslate PDO connection as:

$db

The v4.8 BrandingSettings class was capable of opening its own database
connection when one had not explicitly been supplied.

For Settings/API requests that could therefore mean:

connection 1:
bootstrap.php

connection 2:
BrandingSettings

v4.8.2 now explicitly executes:

BrandingSettings::setDatabase($db);

so Settings reads/writes use the SAME PDO connection already opened by
WATranslate.

This is cleaner and avoids hosting/MySQL connection-limit problems.

2. GUARANTEE THE CURRENT BRANDING SAVE SIGNATURE

The current Settings UI has THREE image fields:

web_logo
mobile_logo
icon

v4.8.2 explicitly uses:

BrandingSettings::update(
    $name,
    $loginSubtitle,
    $_FILES['web_logo'] ?? null,
    $_FILES['mobile_logo'] ?? null,
    $_FILES['icon'] ?? null
);

This also protects against an older public/api.php surviving from the
single-logo implementation.

3. SERVER ERROR LOGGING

If another unexpected PHP/MySQL exception occurs, public/api.php now writes a
short random error ID plus the real server-side exception into the PHP error
log.

Sensitive SQL/database details are NOT returned to the browser.

FILES TO OVERWRITE

public/api.php
public/webhook.php

NO FRONTEND CHANGE.
NO MYSQL TABLE CHANGE.
NO SQL REQUIRED.
NO config.php CHANGE.
NO GOOGLE CHANGE.
NO META/WHATSAPP CHANGE.
NO UI CHANGE.

IMPORTANT

Keep the v4.8 file already installed:

src/Branding.php

Do NOT replace it with an older Branding.php.

INSTALL

1. Upload this ZIP into:

public_html/whatsapp-server-translator/

2. Extract and overwrite:

public/api.php
public/webhook.php

3. Do NOT change the root wrappers:

api.php
webhook.php

4. Reload WATranslate.

5. Open:
... → Settings

6. Change only:
Application name
Login subtitle

7. Click:
Save settings

8. Open phpMyAdmin → wa_settings and refresh.

The setting_value rows for:

name
login_subtitle

should now contain the new values and their table updated_at timestamps should
change.

If the save still fails, the server PHP error log will now contain:

WATranslate branding save error [xxxxxxxx]: ...

That exact log line will identify the remaining server-side cause.
