Recursive storagePid does not work in command controller
I created a basic command controller which retrieves records from an Extbase repository but failed to retrieve any records. When debugging the query I noticed that the where statement checks for pid IN, which is the negative ID of the storage folder I configured in the module.tx_extension.persistence.storagePid, together with persistence.recursive = 2.
When debugging further I found that in TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager::getConfiguration() the ID is negated ($storagePid = -$storagePid). The comment above states:
// All implementations of getTreeList allow to pass the ids negative to include them into the result
// otherwise only childpages are returned
However the BackendConfigurationManager calls \TYPO3\CMS\Core\Database\QueryGenerator::getTreeList(), which does not support negative ids. Because of that the recursion will not work either because there are no pages with pid -16.
The FrontendConfigurationManager calls \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList(), which checks for the negative ID and uses abs() to make it positive again. When I do this in the QueryGenerator getTreeList it works as expected.
In addition to this: Can anyone tell me how to configure a command controller/scheduled task to use a specific root page? I know you can set parameters from the scheduler, but the TypoScript configuration seems to be already loaded from the first found root page before the controller is executed. The only way to override this seems to be by using an URL parameter id, but I'm not sure how to do this with a command controller running from the scheduler.