Issues
- ORM lambda invocations receive wrong `this` scopeLDEV-4067Michael Offner
- Closures mess up with the UDF functionLDEV-3647Pothys - MitrahSoft
- Hibernate dbcreate = update no longer worksLDEV-3175Michael Offner
- closures without a return throws confusing error messageLDEV-3169Michael Offner
- add support for breaking condition in closure functionsLDEV-2073
- Cannot default first argument in reduce()'s callback with full null supportLDEV-1296Michael Offner
- Closure scopeLDEV-591
- Variables scope inside a closure does not behave consistentlyLDEV-590Michael Offner
8 of 8
ORM lambda invocations receive wrong `this` scope
Description
Environment
None
Attachments
4
Details
Assignee
Michael OffnerMichael OffnerReporter
Michael Born @ OrtusMichael Born @ OrtusPriority
NewNew Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Michael Born @ Ortus
Michael Born @ OrtusPriority
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Created 7 July 2022 at 18:35
Updated 23 August 2022 at 05:29
Activity
Show:
Pothys - MitrahSoft23 August 2022 at 05:28Edited
Michael Born @ Ortus11 July 2022 at 12:51
Thanks for the test case @Pothys - MitrahSoft !
Pothys - MitrahSoft8 July 2022 at 14:45
I've checked this ticket with the above test file and confirmed the issue happened on the lucee latest version 5.3.10.27-SNAPSHOT. When calling a lambda/closure within an ORM entity, this/variables scope returns the wrong value. Seems ACF returns the this/variables scope value from lambda/closure.
I added a testcase to this ticket
Pull Request: https://github.com/lucee/Lucee/pull/1696
When calling a lambda within an ORM entity, the lambda’s
this
scope andvariables
scope refer to an unpopulated entity. i.e. it is impossible to reference entity properties within a closure, even after setting the property on the entity beforehand.Take this code:
// Person.cfc component accessors="true" persistent="true" table="persons"{ property name="id" type="string" persistent="true"; property name="name" type="string" persistent="true"; public component function init(){ return this; } this.memento = { mappers = { "theName" : () => variables.getName() } } } // index.cfm newPerson = new Person(); newPerson.setName( "Michael" ); writeDump( newPerson.memento.mappers[ "theName" ]() );
when run without ORM population involved, we get the name back:
"Michael"
.But when run as an ORM entity, the name is always
NULL
:newPerson = entityNew( "Person" ); newPerson.setName( "Michael" ); writeDump( newPerson.memento.mappers[ "theName" ]() );
See the attached .zip file test case, or screenshots comparing behavior between Lucee and ACF. (ACF outputs
"Michael"
property value in both the native component test and the ORM entity test.)