| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /**
- * Data migration page, part of the update procedure: upload the new files, then
- * open this once and press the button.
- *
- * Nothing runs by itself. The application keeps reading old gallery files
- * correctly whether or not this has been run — see app/migrate.php — so this is
- * a tidy-up the operator triggers, never a gate that can lock a site out of its
- * own data after an FTP upload.
- */
- require dirname(__DIR__) . '/app/bootstrap.php';
- auth_require();
- $results = null;
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- csrf_verify();
- // Large installations touch every gallery file; the work itself is small,
- // but there is no reason to be caught by a low default time limit.
- @set_time_limit(0);
- $results = migrate_run();
- flash_set('Migration finished.');
- }
- $pending = migrate_pending();
- admin_header('Data migration');
- flash_render();
- ?>
- <h1>Data migration</h1>
- <div class="card">
- <p class="help" style="margin-top:0;margin-bottom:1rem">
- Run this once after updating the software. It brings every gallery's data
- file up to the current format — currently schema version
- <?= (int)SCHEMA_VERSION ?>. It is safe to run again at any time: each step
- is written so that repeating it changes nothing, and no images, archives
- or S3 objects are ever removed.
- </p>
- <?php if ($results !== null): ?>
- <h2 style="margin-top:0">Result</h2>
- <table style="margin-bottom:1rem">
- <tr><th>Gallery</th><th style="width:110px">Applied</th><th>Notes</th></tr>
- <?php foreach ($results as $row): ?>
- <tr>
- <td><a href="gallery-edit.php?g=<?= e(rawurlencode($row['slug'])) ?>"><?= e($row['title']) ?></a></td>
- <td>
- <?php if ($row['error'] !== null): ?>
- <span class="tag tag-expired">failed</span>
- <?php elseif ($row['applied'] === []): ?>
- <span class="tag">up to date</span>
- <?php else: ?>
- <span class="tag tag-lock">v<?= e(implode(', v', $row['applied'])) ?></span>
- <?php endif; ?>
- </td>
- <td class="help" style="margin:0">
- <?php if ($row['error'] !== null): ?>
- <?= e($row['error']) ?>
- <?php else: ?>
- <?= $row['notes'] === [] ? '—' : e(implode(' ', $row['notes'])) ?>
- <?php endif; ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php if ($results === []): ?>
- <tr><td colspan="3" class="help">No galleries yet.</td></tr>
- <?php endif; ?>
- </table>
- <?php endif; ?>
- <?php if ($pending === []): ?>
- <p style="margin-bottom:1rem">Everything is up to date.</p>
- <?php else: ?>
- <h2 style="margin-top:0">Pending</h2>
- <table style="margin-bottom:1rem">
- <tr><th>Gallery</th><th style="width:140px">Missing steps</th></tr>
- <?php foreach ($pending as $slug => $info): ?>
- <tr>
- <td><a href="gallery-edit.php?g=<?= e(rawurlencode($slug)) ?>"><?= e($info['title']) ?></a></td>
- <td>v<?= e(implode(', v', $info['versions'])) ?></td>
- </tr>
- <?php endforeach; ?>
- </table>
- <?php endif; ?>
- <form method="post">
- <?= csrf_field() ?>
- <button type="submit" style="margin:0">
- <?= $pending === [] ? 'Run again' : 'Run migration' ?>
- </button>
- </form>
- </div>
- <div class="card">
- <h2 style="margin-top:0">What version <?= (int)SCHEMA_VERSION ?> does</h2>
- <p class="help" style="margin:0">
- <strong>Topics.</strong> Galleries can now be split into named sections.
- Existing galleries need no conversion — they simply have no topics and
- look exactly as before — so this step only normalises the new fields and
- clears any leftover reference to a topic that does not exist.
- One thing it cannot do: photos uploaded through a guest link before the
- update are indistinguishable from your own, because nothing recorded who
- uploaded them. They stay without a topic. Guest uploads made from now on
- land in "<?= e(GALLERY_GUEST_TOPIC_NAME) ?>" automatically.
- </p>
- </div>
- <?php admin_footer(); ?>
|