Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0045341
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformmajoralways2020-10-30 09:542020-11-09 12:30
ReportergorkaionView Statuspublic 
Assigned Tocberner 
PriorityhighResolutionfixedFixed in VersionPR21Q1
StatusclosedFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned To
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0045341: OBInterceptors consider an udpate new records created manually setting the createdBy

DescriptionIn a flow where it is required to force a different createdBy field than the current user.

The OBInterceptor when it manages the audit fields it checkes the createdBy field to determine if it is a new record or an update[1].

As the createdBy field is manually set the interceptor executes the update method. Which only sets the updated and updatedby fields.

But in case that the preventUpdateChange is enabled no field is set throwing a error of null updatedby.


[1] https://gitlab.com/openbravo/product/openbravo/-/blob/master/src/org/openbravo/dal/core/OBInterceptor.java#L336 [^]
[2] https://gitlab.com/openbravo/product/openbravo/-/blob/master/src/org/openbravo/dal/core/OBInterceptor.java#L414 [^]
Steps To Reproduce1. Create a process that creates a new record and sets the createdBy field.
2. Before saving the new object enable the preventUpdateChange flag
OBInterceptor.setPreventUpdateInfoChange(true)
3. The database insert fails as the createdby column is null

Please note that the preventUpdateChange is set globally, so it is not requried that the same flow that creates the new objects setting the created by is the one setting the flag.
Proposed SolutionOBInterceptor should also check other audit columns to determine if the record is new.

When executing the onNew() to initialize the audit columns it should set only the ones that are empty at that time to allow forcing different values.
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0124181)
hgbot (developer)
2020-11-05 10:01

Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/216 [^]
(0124239)
hgbot (developer)
2020-11-09 12:30

Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: aa120022d76fae60a9a4f317479fee11ae5a7461
Author: Cristian Berner <cristian.berner@openbravo.com>
Date: 2020-11-09T12:26:25+01:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/aa120022d76fae60a9a4f317479fee11ae5a7461 [^]

Fixes ISSUE-45341: OBInterceptor considers an update if audit manually set on new record

New records were considered by OBInterceptor as an update if the
createdBy audit column was set manually and it also thrown out a
NullPointerException if OBInterceptor.setPreventUpdateInfoChange was set
to true previous to the .save.

This was happening because OBInterceptor assumed(wrongly) that createdBy
field was enough to check if an object was new. This has been modified
to check also the other 3 audit fields, if null, it will be considered
new and execution will happen onNew method, as expected.

Also, onNew method has been modified to update data only if it was not
already set previously manually, that means, when those audit
creationDate, createdBy, updated and updatedBy are null.

---
M modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/DalPersistanceEventTest.java
M src/org/openbravo/dal/core/OBInterceptor.java
---
(0124240)
hgbot (developer)
2020-11-09 12:30

Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/216 [^]

- Issue History
Date Modified Username Field Change
2020-10-30 09:54 gorkaion New Issue
2020-10-30 09:54 gorkaion Assigned To => platform
2020-10-30 09:54 gorkaion Modules => Core
2020-10-30 09:54 gorkaion Triggers an Emergency Pack => No
2020-11-04 17:13 cberner Assigned To platform => cberner
2020-11-05 10:01 hgbot Note Added: 0124181
2020-11-09 12:30 hgbot Resolution open => fixed
2020-11-09 12:30 hgbot Status new => closed
2020-11-09 12:30 hgbot Fixed in Version => PR21Q1
2020-11-09 12:30 hgbot Note Added: 0124239
2020-11-09 12:30 hgbot Note Added: 0124240


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker