Jump to content

Package Option Groups


nereliz

Recommended Posts

Hi,

 

I have an issue then I'm trying to install my plugin. On installation process I have to create some package option groups and the problem is that plugin installation method opens a transaction which is fine, but PackageGroupOption add method opens a transaction as well. And that leads to an exception that transaction is already opened. So as adding package group option is smaller action and might by a part of the bigger process probably removing transaction creation in that level would be a not a bad idea. While you can always start your transaction manually.

 

Kind Regards,
Nerijus Barauskas

Link to comment
Share on other sites

I wouldn't consider this issue a bug. It just requires that you revise your approach to work around the fact that adding a package option group starts a new transaction. Removing the transaction from the model would entail all areas of the system that call this method should create a transaction instead. This widens the scope and complexity of managing transactions.

 

Ideally, every model would impose its own transaction to be self-contained, and if you intend to chain multiple model methods together in a broader transaction, you would create a broader transaction, and the lower level model calls would use the broader transaction without imposing their own (nesting). That may be something we add in the future, but for now, I would suggest updating you plugin to record the package option groups itself without calling PackageOptionGroups::add.

Link to comment
Share on other sites

Hi,

 

Thanks for quick response. In that case you logic fails as the Package::add, PackageGroup::add doesn't have transactions inside. So it has a lack of consistency. Ok I will look for work around thanks anyway.

 

Regards,

Nerijus Barauskas

Link to comment
Share on other sites

Packages::add and PackageGroups::add are wrapped in a transaction at a higher level, in a controller. This is not ideal for the reasons I mentioned above, and is not a practice we would like to continue throughout the rest of the system.

 

You can work around the transaction by using the Record component to insert values into the table directly.

Link to comment
Share on other sites

I found a work around that's fine. Just a suggestion then, it might be a good thing to have function in Record component just to say if transaction is open then it would be easier to debug your own plugin actions as they might be wraped in a bigger method.

 

Anyway thanks for your time :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...