dev/core#1713 - At end of upgrade, perform a system flush. Move menu-rebuild.
authorTim Otten <totten@civicrm.org>
Tue, 21 Apr 2020 02:53:35 +0000 (19:53 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 21 Apr 2020 05:59:13 +0000 (22:59 -0700)
commit3af5c3fe5f91800f582527da31b089c3bfbedb7d
tree2638f4a23a073c61a9786cff96a0c23bae6833e2
parent29b6189cb56160781f37b840989968e0331acaed
dev/core#1713 - At end of upgrade, perform a system flush. Move menu-rebuild.

Before
------

If/when an administrator opens the `civicrm/upgrade?reset=1` UI, then it rebuilds the menu (`CRM_Core_Menu::store()`).

This runs in upgrade-mode, so the menu does not include any routes defined via hook.

After
-----

At the end of upgrade, after the general schema has reached canonical form,
after most hooks are re-enabled for extensions, then it performs a full
system flush.  This incldues rebuilding the menu (and other caches).

Comments
--------

You might think that it serves some purpose to call `CRM_Core_Menu::store()` from
`CRM_Upgrade_Page_Upgrade::runIntro()`.  I can't figure one in the current regimen.  Consider:

* After loading a new source tree, do we need to rebuild the menu to
  access `civicrm/upgrade?reset=1`? Conceivably. But... if that's the case, then we
  wouldn't be able to visit `civicrm/upgrade?reset=1` at all. Moreover, the
  other upgrade routes (eg `civicrm/upgrade/queue*`) are hard-coded into
  the router specifically to resolve that chicken-egg issue.
* Code in `CRM_Upgrade_Page_Upgrade::runIntro()` only runs if you use the
  web-based upgrader (not headless upgraders). So that line isn't a reliable
  part of upgrade logic.
* When that old line runs, lots of hooks are disabled (incl `hook_xmlMenu` and `hook_alterMenu`),
  so it doesn't build a proper route table.
* Consider subsystems like Afform and Data Processor - which allow admins to define new pages.
  These routes have to be stored somewhere and then loaded programmatically (eg `hook_alterMenu`).
  The logic which reads the list probably involves APIs, database tables, and/or settings -- i.e.
  things that are not be reliably functional with old schema.
CRM/Upgrade/Form.php
CRM/Upgrade/Page/Upgrade.php