Description
Some areas of the core code have config files defined for the "setup" area. E.g., Magento_CmsUrlRewrite/etc/setup/events.xml. However, these config files are not read during the command-line setup:upgrade operation.
Reproduction steps:
- Create a module data upgrade script that saves a new CMS page.
- Run "magento setup:upgrade".
- Observe that, in the database, a new record exists in cms_page for the new page, but no new record exists in url_rewrite (which would normally occur when saving a new page in the admin).
The logic that is responsible for saving this URL rewrite record is in an observer defined in Magento_CmsUrlRewrite/etc/adminhtml/events.xml and Magento_CmsUrlRewrite/etc/setup/events.xml. This works fine for the adminhtml area, but no setup area is ever loaded.
Areas are defined in di.xml in the "areas" argument of Magento\Framework\App\AreaList. There are no di.xml files defining a "setup" item in this argument. I have confirmed that, when running "magento setup:upgrade", the result of Magento\Framework\Config::getCurrentScope (which returns "frontend" when the area context is "frontend") is "global".