Web service step that calls function requiring login falls when triggered by external service

Aperta
#194 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Start with classes/steps/actions/webservice_action_step.php, where the traceback shows the external function call, and trace how the step handles calls triggered from scheduled tasks. Compare the front end and LDAP or external database workflows described in the issue. Done means the web service step succeeds for both user creation paths; no test file is named in the payload.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Using a workflow with a webservices step fails if the event is triggered by an external service. Consider a workflow like this:

  • When a new user is created, look up the user, then do a WS step calling enrol_manual_enrol_users to enroll the user in an orientation course.

It works fine if the user is creation is initiated from the front end. However if the user is created by an authentication plugin/scheduled task the WS call fails as below. I can replicate this with LDAP and external database, on Moodle 3.10 and tool_trigger 2021030406

Replication steps:

  • Import the attached workflow
  • Make sure you have a course with ID=2 (or modify workflow for a course on your site)
  • Manually create a user and confirm they are enrolled in the course
  • Create a user via LDAP or external database and confirm an error similar to below
Workflow ID: 13
Trigger Number: 373
Event description:
'User created'
'The user with id \'2\' created the user with id \'1003\'.'
[Enroll_New_User_in_Orientation_20220815_1824.zip](https://github.com/catalyst/moodle-tool_trigger/files/9339800/Enroll_New_User_in_Orientation_20220815_1824.zip)


Step ID: 851
Step results:
'{
    "message": "Web service is not available. (The session has been logged out or has expired.)",
    "errorcode": "servicerequireslogin",
    "backtrace": "* line 228 of \\/lib\\/externallib.php: moodle_exception thrown\\n* line 116 of \\/admin\\/tool\\/trigger\\/classes\\/steps\\/actions\\/webservice_action_step.php: call to external_api::call_external_function()\\n* line 142 of \\/admin\\/tool\\/trigger\\/classes\\/steps\\/actions\\/webservice_action_step.php: call to tool_trigger\\\\steps\\\\actions\\\\webservice_action_step->run_function()\\n* line 74 of \\/admin\\/tool\\/trigger\\/classes\\/helper\\/processor_helper.php: call to tool_trigger\\\\steps\\\\actions\\\\webservice_action_step->execute()\\n* line 217 of \\/admin\\/tool\\/trigger\\/classes\\/event_processor.php: call to tool_trigger\\\\event_processor->execute_step()\\n* line 197 of \\/admin\\/tool\\/trigger\\/classes\\/event_processor.php: call to tool_trigger\\\\event_processor->process_realtime_workflow()\\n* line 109 of \\/admin\\/tool\\/trigger\\/classes\\/event_processor.php: call to tool_trigger\\\\event_processor->process_realtime_workflows()\\n* line 70 of \\/admin\\/tool\\/trigger\\/classes\\/event_processor.php: call to tool_trigger\\\\event_processor->write()\\n* line ? of unknownfile: call to tool_trigger\\\\event_processor::process_event()\\n* line 155 of \\/lib\\/classes\\/event\\/manager.php: call to call_user_func()\\n* line 75 of \\/lib\\/classes\\/event\\/manager.php: call to core\\\\event\\\\manager::process_buffers()\\n* line 834 of \\/lib\\/classes\\/event\\/base.php: call to core\\\\event\\\\manager::dispatch()\\n* line 483 of \\/auth\\/db\\/auth.php: call to core\\\\event\\\\base->trigger()\\n* line 60 of \\/auth\\/db\\/classes\\/task\\/sync_users.php: call to auth_plugin_db->sync_users()\\n* line 253 of \\/lib\\/cronlib.php: call to auth_db\\\\task\\\\sync_users->execute()\\n* line 167 of \\/admin\\/cli\\/scheduled_task.php: call to cron_run_inner_scheduled_task()\\n",
    "link": "http:\\/\\/localhost\\/moodle310\\/",
    "moreinfourl": "https:\\/\\/docs.moodle.org\\/310\\/en\\/error\\/webservice\\/servicerequireslogin",
    "debuginfo": "\\nError code: servicerequireslogin"

```}'
Lingua principale
PHP
Stelle
46
Fork
29
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di catalyst/moodle-tool_trigger

Tutte le issue di catalyst/moodle-tool_trigger

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.