Trying to add new "Flow" triggers – AutoloadNotAllowedException

Dear Nextcloud community,

I’m trying to get my feet wet with some Nextcloud OSS development, hoping to create a proper PR in the end, and extend some of Nextcloud’s abilities. However I’m a frontend dev by occupation, so my PHP is a little rusty.

Specifically I’m trying to extend the current “Flow”/Workflow functionality by adding new, User-related triggers (e.g. User created, user modified, user deleted, etc.). So far I’m trying to do this outside of a custom app, but instead within the Nextcloud workflowengine code itself (these are pretty generic triggers, I feel like they should ship with Nextcloud, instead of putting them in a separate custom App). I also watched the great talk from Blizzz at CCC about the Workflow architecture to prepare myself for this task.

I pretty much stuck to the existing implementation for files in apps/workflowengine/lib/Entity/File.php. I created a new apps/workflowengine/lib/Entity/User.php and adjusted the logic accordingly. I referenced my new class in apps/workflowengine/lib/Manager.php in getBuildInEntities().

Anyway, I still can’t get my new User class to load. Whenever I visit the Flow app in the frontend, I get the following Exception:

Technical details

    Remote Address: 172.17.0.1
    Request ID: EpsF2C7zGLacMS1XdNqA
    Type: OCP\AutoloadNotAllowedException
    Code: 0
    Message: Autoload path not allowed: /var/www/html/apps/workflowengine/lib/entity/user.php
    File: /var/www/html/lib/autoloader.php
    Line: 140


Trace

#0 /var/www/html/lib/autoloader.php(165): OC\Autoloader->isValidPath('/var/www/html/a...')
#1 [internal function]: OC\Autoloader->load('OCA\\WorkflowEng...')
#2 [internal function]: spl_autoload_call('OCA\\WorkflowEng...')
#3 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(99): ReflectionClass->__construct('OCA\\WorkflowEng...')
#4 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(116): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\WorkflowEng...')
#5 /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php(414): OC\AppFramework\Utility\SimpleContainer->query('OCA\\WorkflowEng...')
#6 /var/www/html/lib/private/ServerContainer.php(133): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\WorkflowEng...')
#7 /var/www/html/apps/workflowengine/lib/Manager.php(676): OC\ServerContainer->query('OCA\\WorkflowEng...')
#8 /var/www/html/apps/workflowengine/lib/Manager.php(635): OCA\WorkflowEngine\Manager->getBuildInEntities()
#9 /var/www/html/apps/workflowengine/lib/Settings/ASettings.php(94): OCA\WorkflowEngine\Manager->getEntitiesList()
#10 /var/www/html/apps/settings/lib/Controller/CommonSettingsTrait.php(141): OCA\WorkflowEngine\Settings\ASettings->getForm()
#11 /var/www/html/apps/settings/lib/Controller/AdminSettingsController.php(83): OCA\Settings\Controller\AdminSettingsController->formatSettings(Array)
#12 /var/www/html/apps/settings/lib/Controller/CommonSettingsTrait.php(152): OCA\Settings\Controller\AdminSettingsController->getSettings('workflow')
#13 /var/www/html/apps/settings/lib/Controller/AdminSettingsController.php(68): OCA\Settings\Controller\AdminSettingsController->getIndexResponse('admin', 'workflow')
#14 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(170): OCA\Settings\Controller\AdminSettingsController->index('workflow')
#15 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(100): OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\Settings\Controller\AdminSettingsController), 'index')
#16 /var/www/html/lib/private/AppFramework/App.php(137): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Settings\Controller\AdminSettingsController), 'index')
#17 /var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php(47): OC\AppFramework\App::main('OCA\\Settings\\Co...', 'index', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#18 [internal function]: OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
#19 /var/www/html/lib/private/Route/Router.php(297): call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
#20 /var/www/html/lib/base.php(1007): OC\Route\Router->match('/settings/admin...')
#21 /var/www/html/index.php(37): OC::handleRequest()
#22 {main}

Now I perfectly understand the Exception and I tried debugging this. However if I inspect $validRoots in autoloader.php I can’t find any path for the workflow engine. I expected to find apps/workflowengine/ in there, because the existing File class in this folder apparently works. So my two questions are:

1.) How is the existing File entity from the workflowengine loaded?
2.) How do I get my new User class to be loaded, too?

I’d appreciate any help! Thanks!

@juliushaertl could you help with this? :slight_smile:

The autoloader will pick up the composer autoloader.php from the workflowengine app if available. You might need to update that to make it aware of your new class by running

composer dumpautoload in apps/workflowengine/composer/

1 Like

@juliushaertl Thank you! This worked perfectly.

Glad to hear. Let me know if any further questions arise.