# CustomQueryPage

CustomQueryPage rebuilds the historical "Approved Manuals" workflow for MediaWiki 1.35.x. It provides two special pages:

* `Special:ApprovedManuals` – read-only listing of manual procedure pages that are tagged with a ROUTINE value in the legacy `tag_pages`/`tags` tables. Sorting by title or deployment date is handled via simple query-string toggles.
* `Special:CustomQuerySettings` – a tiny control panel restricted to the `customquerypage-manage` right (sysops by default) so Lisa or another release manager can update which ROUTINE tag drives the listing without editing `LocalSettings.php`.

## Installation

1. Copy this directory into `extensions/CustomQueryPage` inside your MediaWiki checkout.
2. Add `wfLoadExtension( 'CustomQueryPage' );` to `LocalSettings.php`.
3. (Optional) Override the default ROUTINE via `$wgCustomQueryPageDefaultTag = 'ROUTINE_4.110';` in `LocalSettings.php` if you want a different fallback before the settings page is used.
4. Run `php maintenance/update.php --quick` to create the `customquerypage_settings` table on every wiki database.

## Usage notes

* Lisa (or any user with `customquerypage-manage`) can go to `Special:CustomQuerySettings`, input the exact `ROUTINE_x.xxx` identifier that already exists in `tag_pages`, and save. The change is timestamped and tracked with the updating user.
* The same page now exposes a **Clone ROUTINE release** form so you can copy every row from an existing tag into a new `ROUTINE_x.xxx` value. It copies the `tags`/`tag_pages` rows, lets you override the deploy comment, and automatically switches `Special:ApprovedManuals` to the new tag after the clone succeeds.
* `Special:ApprovedManuals` will immediately read from the stored tag and display matching pages. Sorting toggles are safe to use even on older browsers because they simply regenerate the URL parameters.
* If the control-table has not been created yet, the listing silently falls back to the default tag so the page keeps working during deployments.
* When seeding test data, add `[[Category:ManualProcedures]]` to each dummy page so they resemble the historical manuals.
* The `customquerypage-manage` right is assigned to `sysop` by default—ensure your admin account belongs to that group (`createAndPromote.php --force tux --sysop` if needed) so you can access `Special:CustomQuerySettings`.

### Quick clone workflow (sh1re/sh0re)

1. Log in as a sysop and open `Special:CustomQuerySettings`.
2. In the Clone form, set **Source ROUTINE** to the tag you just finished reviewing (for example, `ROUTINE_4.110`).
3. Set **New ROUTINE** to the next tag you want to publish (for example, `ROUTINE_4.111`) and optionally add a deployment note that will be stored in `mw_tags.comment`.
4. Submit the form. The extension copies every `mw_tag_pages` row from the source tag, clones the `mw_tags` record, and immediately updates the active tag so `Special:ApprovedManuals` points at the newly cloned release.
5. Refresh `Special:ApprovedManuals` to confirm it now shows the new tag.

## Working locally

You can build and test everything on a workstation that only has MediaWiki core (no production data) by seeding a few rows into `tag_pages`, `tags`, and `revision`. The extension relies on the MediaWiki load balancer, so reads/writes work the same locally and on the remote host. Once you're happy, rsync/scp the extension directory to the remote server, run `update.php`, and point it at your migrated database replica to see live data.

Because there is no PHP binary on this desktop image, syntax checks were not run here. Run `php -l src/**/*.php` (or Composer PHPCS) on a machine with PHP before deploying.

## Packaging for sh1re

When you need to ship this code to the legacy MW 1.35.9 environment without GitHub, create a tarball under `extensions-mw1359` and drop it somewhere reachable from your staging host:

```bash
cd ~/sh1re/mediawiki/manual\ procedures/extensions-mw1359
tar -czf /tmp/CustomQueryPage-mw1359.tar.gz CustomQueryPage
scp /tmp/CustomQueryPage-mw1359.tar.gz eckfordc@mw.eckford.ca:/home/eckfordc/mw.eckford.ca/downloads/
```

From your work laptop you can grab it with:

```bash
scp eckfordc@mw.eckford.ca:/home/eckfordc/mw.eckford.ca/downloads/CustomQueryPage-mw1359.tar.gz .
```

so you have the file handy before uploading it to the sh1re production host.
