Timeline for $node->save() fails when run in post_update
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 15, 2022 at 8:22 | history | edited | 4uk4 | CC BY-SA 4.0 |
add code example for rendering a view in isolation
|
Mar 14, 2022 at 21:31 | comment | added | 4uk4 | OK, but this doesn't solve the problem with leaking metadata into an unknown render context. Running render() or code containing render() should only bubble up metadata if you can make sure the render context belongs to the rendered content. Most times this is the page render context when theming page elements. | |
Mar 14, 2022 at 19:51 | comment | added | liquidcms | thanks for the tip.. good to know. Although a lot of work to simply copy a field to a new field as a 1 time ting. For now i simply set a static var in the update script and then use that to ignore my save/presave functions as they don't need to be run when this update is being run. | |
Mar 14, 2022 at 16:11 | comment | added | 4uk4 | If the render() function is not in your control, like here in a View, you can enclose the code in your own RenderContext and discard the bubbled up metadata. Drupal does this for example when rendering mails. See drupal.stackexchange.com/questions/245715/… | |
Mar 14, 2022 at 16:03 | comment | added | liquidcms | Turns out it is my custom code causing the issue. I have code which runs on node save/presave which is trying to get values from a View and is using advancedRender() which i assume is causing this issue. Disappointing that my code works as it should when nodes are normally being saved but in post_update i am blocked from doing this. Easy enough to work around as these functions dont need to be run during this update - but odd I would need to do this hack. | |
Mar 12, 2022 at 11:10 | history | answered | 4uk4 | CC BY-SA 4.0 |