|
| 1 | +================ |
| 2 | +Maintenance Page |
| 3 | +================ |
| 4 | + |
| 5 | +Overview |
| 6 | +======== |
| 7 | + |
| 8 | +The maintenance page in phpBB 4.0 is designed to be a "zero-dependency" interceptor page. It resides in ``includes/startup.php`` and triggers before the autoloader, database, session, or language systems are initialized. |
| 9 | + |
| 10 | +This architecture ensures that even if the database is offline or core files are being overwritten during an update, the user is served a professional, localized maintenance page rather than a PHP error. |
| 11 | + |
| 12 | +Functional Flow |
| 13 | +--------------- |
| 14 | + |
| 15 | +1. **Detection**: The system checks for the existence of ``store/UPDATE_LOCK.php``. |
| 16 | +2. **Execution**: If the file exists, ``send_maintenance_screen()`` is called. |
| 17 | +3. **Data Loading**: The function ``include``'s the lock file to retrieve metadata. |
| 18 | +4. **Rendering**: A static HTML/CSS page is output with the necessary data added as a JSON payload for client-side logic. |
| 19 | +5. **Polling**: The page includes a ``<meta http-equiv="refresh" content="30">`` tag to refresh the page every 30 seconds and automatically reconnect the user once the lock file is removed. |
| 20 | + |
| 21 | +The Update Lock File |
| 22 | +==================== |
| 23 | + |
| 24 | +The ``store/UPDATE_LOCK.php`` is an auto-generated PHP array-export. It acts as the "source of truth" for the maintenance screen. |
| 25 | + |
| 26 | +Data Schema |
| 27 | +----------- |
| 28 | + |
| 29 | +The file must return an associative array with the following structure: |
| 30 | + |
| 31 | +initiated |
| 32 | + *(int)* Unix timestamp of the start of maintenance. Used by the frontend to calculate "Started on" strings. |
| 33 | + |
| 34 | +config |
| 35 | + *(array)* Global metadata. |
| 36 | + |
| 37 | + * ``default_lang``: Fallback ISO language code, should be the default board language and fitting language strings **MUST** be provided for this language in the ``lang`` array. |
| 38 | + * ``sitename``: The name of the board to be used in titles and messaging, same as the site name stored in the board config. |
| 39 | + |
| 40 | +lang |
| 41 | + *(array)* A collection of language-specific blocks. Each block is keyed by the language ISO code and contains the following keys: |
| 42 | + |
| 43 | + * ``BOARD_MAINTENANCE``: The main body text for the board maintenance message. |
| 44 | + * ``BOARD_MAINTENANCE_START``: The localized "Started on" label (supports ``%1$s`` for the date). |
| 45 | + * ``BOARD_MAINTENANCE_TITLE``: The HTML title tag template (supports ``%1$s`` for the sitename). |
| 46 | + |
| 47 | +links |
| 48 | + *(array)* A list of external community links. Each entry is an array with ``title`` and ``url``. |
| 49 | + |
| 50 | +Example Implementation |
| 51 | +---------------------- |
| 52 | + |
| 53 | +.. code-block:: php |
| 54 | +
|
| 55 | + <?php |
| 56 | + /** |
| 57 | + * phpBB Update Lock File |
| 58 | + * This file is auto-generated. Do not edit manually. |
| 59 | + */ |
| 60 | +
|
| 61 | + if (!defined('IN_PHPBB')) |
| 62 | + { |
| 63 | + exit; |
| 64 | + } |
| 65 | +
|
| 66 | + return [ |
| 67 | + 'initiated' => 1738200000, |
| 68 | + 'config' => [ |
| 69 | + 'default_lang' => 'en', |
| 70 | + 'sitename' => 'yourdomain.com', |
| 71 | + ], |
| 72 | + 'lang' => [ |
| 73 | + 'en' => [ |
| 74 | + 'BOARD_MAINTENANCE' => 'The board is currently down for maintenance.', |
| 75 | + 'BOARD_MAINTENANCE_START' => 'Started on %1$s', |
| 76 | + 'BOARD_MAINTENANCE_TITLE' => 'Board maintenance - %1$s', |
| 77 | + ] |
| 78 | + ], |
| 79 | + 'links' => [ |
| 80 | + ['title' => 'Discord', 'url' => 'https://discord.gg/example'], |
| 81 | + ['title' => 'Status Page', 'url' => 'https://status.example.com'], |
| 82 | + ], |
| 83 | + ]; |
| 84 | +
|
| 85 | +Best Practices for Developers |
| 86 | +============================= |
| 87 | + |
| 88 | +1. **Atomic Writes**: When creating the lock file, always write to a temporary file (e.g., ``UPDATE_LOCK.php.tmp``) and use ``rename()`` to move it to its final destination. This prevents the interceptor from including a half-written file. |
| 89 | +2. **Minimalism**: Do not include heavy logic in the lock file. It is intended only for data storage. |
| 90 | +3. **Localization**: Always provide at least the key corresponding to your default language in the ``lang`` array to satisfy the ``default_lang`` fallback. |
0 commit comments