Izumi-kun / LTI-Tool-Provider-Library-PHP

LTI Tool Provider library for PHP
Apache License 2.0
21 stars 6 forks source link

Context is empty for resource link after the 1st link launch #18

Closed jozefbriss closed 5 years ago

jozefbriss commented 5 years ago

https://github.com/Izumi-kun/LTI-Tool-Provider-Library-PHP/blob/df420fea8f7b3ec651a0d382ad36696f70346153/src/ToolProvider/ToolProvider.php#L1005

In the 1st launch with the given context and resource link getRecordId() returns null because the context is not yet in the database. That is why lti2_resource_link.context_pk is null.

Following link launch fixes the situation.

Ideally, the context should be set to resource link after the context was saved to the database e.g.

on the line 1155 reset the context if (!empty($this->context)) { $this->resourceLink->setContextId($this->context->getRecordId()); }