| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | * - 6: the Trash stopped registering a desktop icon. Removes the |
| 57 | 57 | * placement the shell had auto-placed for it and closes the hole that |
| 58 | 58 | * leaves in the icon column. |
| 59 | 59 | */ |
| 60 | -const OPENSTATION_MIGRATION_VERSION = 6; | |
| 60 | +const OPENSTATION_MIGRATION_VERSION = 8; | |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Option storing the highest migration version that has run. autoload=no. |
| 64 | 64 | * |
| @@ -156,11 +156,77 @@ | ||
| 156 | 156 | |
| 157 | 157 | if ( $from < 6 ) { |
| 158 | 158 | openstation_migrate_close_recycle_bin_icon_gap(); |
| 159 | 159 | } |
| 160 | + | |
| 161 | + if ( $from < 7 ) { | |
| 162 | + openstation_migrate_seed_agent_faces(); | |
| 163 | + } | |
| 164 | + | |
| 165 | + if ( $from < 8 ) { | |
| 166 | + openstation_migrate_remove_comments_ai(); | |
| 167 | + } | |
| 160 | 168 | } |
| 161 | 169 | |
| 162 | 170 | /** |
| 171 | + * Migration 7 — give the agents that predate faces a seed to grow one | |
| 172 | + * from. | |
| 173 | + * | |
| 174 | + * Agents used to share a single grey robot glyph. They now carry a Mio | |
| 175 | + * look, and an agent created from here on gets a seed at birth. The | |
| 176 | + * ones already on the site do not, and without a seed there is nothing | |
| 177 | + * to derive a face from. | |
| 178 | + * | |
| 179 | + * **This writes the seed and stops.** It does not write the face. The | |
| 180 | + * face comes from `randomMioLook()`, which lives in TypeScript, and | |
| 181 | + * porting it is exactly the wrong trade: it is a taste filter with a | |
| 182 | + * dozen judgment calls in it, pinned by `mio-randomize.test.ts`, and a | |
| 183 | + * PHP twin of it would drift with nothing watching. So the shell fills | |
| 184 | + * the looks in on its next paint of the Agents section, rolling each | |
| 185 | + * one from the seed written here. | |
| 186 | + * | |
| 187 | + * That is a client writing on the server's behalf, which is worth | |
| 188 | + * naming rather than slipping past. It is safe because it is entirely | |
| 189 | + * derived: the seed is `crc32` of the login, so two admins racing the | |
| 190 | + * backfill produce byte-identical faces, and running it twice changes | |
| 191 | + * nothing. | |
| 192 | + * | |
| 193 | + * The five shipped agents are unaffected: their faces are written out | |
| 194 | + * in `default-definitions.php` and were never rolled. | |
| 195 | + * | |
| 196 | + * @return void | |
| 197 | + */ | |
| 198 | +function openstation_migrate_seed_agent_faces() { | |
| 199 | + // Agents is behind a feature flag, so on a site that has never | |
| 200 | + // turned it on there is nothing to seed, and none of the module's | |
| 201 | + // functions exist to call. A site that turns it on later creates | |
| 202 | + // its agents through `openstation_agent_create`, which seeds them | |
| 203 | + // at birth, so nothing is missed by returning here. | |
| 204 | + if ( | |
| 205 | + ! function_exists( 'openstation_agent_get_agents' ) | |
| 206 | + || ! function_exists( 'openstation_agent_get_face_seed' ) | |
| 207 | + || ! defined( 'OPENSTATION_AGENT_FACE_SEED_META' ) | |
| 208 | + ) { | |
| 209 | + return; | |
| 210 | + } | |
| 211 | + | |
| 212 | + foreach ( openstation_agent_get_agents() as $agent ) { | |
| 213 | + $user_id = isset( $agent->ID ) ? (int) $agent->ID : 0; | |
| 214 | + if ( $user_id <= 0 ) { | |
| 215 | + continue; | |
| 216 | + } | |
| 217 | + if ( openstation_agent_get_face_seed( $user_id ) > 0 ) { | |
| 218 | + continue; | |
| 219 | + } | |
| 220 | + update_user_meta( | |
| 221 | + $user_id, | |
| 222 | + OPENSTATION_AGENT_FACE_SEED_META, | |
| 223 | + crc32( (string) $agent->user_login ) | |
| 224 | + ); | |
| 225 | + } | |
| 226 | +} | |
| 227 | + | |
| 228 | +/** | |
| 163 | 229 | * Grid the desktop auto-placer lays icons out on: 16px of padding, a |
| 164 | 230 | * 96px column, a 110px row. Mirrored from `src/desktop-files/grid.ts` |
| 165 | 231 | * via {@see openstation_files_auto_place_orphans}, which is what wrote |
| 166 | 232 | * the coordinates this migration edits. |
| @@ -185,10 +251,10 @@ | ||
| 185 | 251 | * put that icon there and the shell is taking it away, so the shell |
| 186 | 252 | * tidies up after itself rather than leaving a gap nobody chose. |
| 187 | 253 | * |
| 188 | 254 | * A user who wants the bin back on the wallpaper picks "On the desktop" |
| 189 | - * in Apps & Plugins, which promotes the dock tile and never touches | |
| 190 | - * these rows. | |
| 255 | + * in Preferences → Navigation, which promotes the dock tile and never | |
| 256 | + * touches these rows. | |
| 191 | 257 | * |
| 192 | 258 | * @return void |
| 193 | 259 | */ |
| 194 | 260 | function openstation_migrate_close_recycle_bin_icon_gap() { |
| @@ -291,9 +357,9 @@ | ||
| 291 | 357 | array_merge( |
| 292 | 358 | get_users( |
| 293 | 359 | array( |
| 294 | 360 | 'fields' => 'ID', |
| 295 | - 'meta_key' => 'desktop_mode_mode', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- runs once per install; the key is indexed in usermeta and both callers are guarded to a single pass. | |
| 361 | + 'meta_key' => 'desktop_mode_mode', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- the key is indexed in usermeta; the migration callers run once per install, and the deactivation feedback route once per admin submission. | |
| 296 | 362 | 'meta_compare' => 'EXISTS', |
| 297 | 363 | ) |
| 298 | 364 | ), |
| 299 | 365 | get_users( |
| @@ -552,8 +618,33 @@ | ||
| 552 | 618 | wp_unschedule_hook( 'desktop_mode_ai_analyze_term' ); |
| 553 | 619 | } |
| 554 | 620 | |
| 555 | 621 | /** |
| 622 | + * Migration 8 — retire the "Score new comments with AI" feature. | |
| 623 | + * | |
| 624 | + * Automatic AI scoring of incoming comments was removed: nothing | |
| 625 | + * schedules `desktop_mode_ai_analyze_comment` any more, and the | |
| 626 | + * `desktop_mode_comments_ai_moderation` option no longer gates | |
| 627 | + * anything. Queued single-events would simply no-op, but we clear | |
| 628 | + * them so the cron array stays tidy and `wp cron event list` doesn't | |
| 629 | + * show an orphaned hook. | |
| 630 | + * | |
| 631 | + * The option row is dropped too — unlike a frozen identifier that | |
| 632 | + * still has a reader, this one has none left, so leaving it would | |
| 633 | + * only strand a value no code consults. | |
| 634 | + * | |
| 635 | + * Existing `_desktop_mode_ai_analysis` comment meta is left in place | |
| 636 | + * (hidden, harmless, and still what the on-demand | |
| 637 | + * `desktop-mode/analyze-comment` ability writes). | |
| 638 | + * | |
| 639 | + * @return void | |
| 640 | + */ | |
| 641 | +function openstation_migrate_remove_comments_ai() { | |
| 642 | + wp_unschedule_hook( 'desktop_mode_ai_analyze_comment' ); | |
| 643 | + delete_option( 'desktop_mode_comments_ai_moderation' ); | |
| 644 | +} | |
| 645 | + | |
| 646 | +/** | |
| 556 | 647 | * Migration 3 — delete self-managed AI credentials. |
| 557 | 648 | * |
| 558 | 649 | * WordPress 7.0 owns provider credentials (Settings → Connectors), so the |
| 559 | 650 | * copilot no longer stores keys of its own. Remove the platform key option and |
| @@ -599,4 +690,7 @@ | ||
| 599 | 690 | |
| 600 | 691 | openstation_save_os_settings( (int) $user_id, $raw ); |
| 601 | 692 | } |
| 602 | 693 | } |
| 694 | + | |
| 695 | +// Presence owns a verified checkpoint so failures never advance unrelated migrations. | |
| 696 | +add_action( 'admin_init', 'openstation_presence_migration_tick', 20 ); | |