IDEMPIERE-5628 Record ID Check Issue - implement setCrossTenantSafe (#1724)

* IDEMPIERE-5628 Record ID Check Issue - implement setCrossTenantSafe

* - remove table exceptions
This commit is contained in:
Carlos Ruiz 2023-03-13 14:38:00 +01:00 committed by GitHub
parent 106cbc7e14
commit e4b7c9e17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 8 deletions

View File

@ -228,7 +228,12 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
ri.setAD_Role_ID(AD_Role_ID);
ri.setAD_Window_ID(AD_Window_ID);
ri.setAD_Tab_ID(AD_Tab_ID);
try {
PO.setCrossTenantSafe();
ri.saveEx();
} finally {
PO.clearCrossTenantSafe();
}
} else {
if ( ric.getAD_Role_ID() != AD_Role_ID
|| ric.getAD_Window_ID() != AD_Window_ID
@ -237,7 +242,12 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
ri.setAD_Role_ID(AD_Role_ID);
ri.setAD_Window_ID(AD_Window_ID);
ri.setAD_Tab_ID(AD_Tab_ID);
try {
PO.setCrossTenantSafe();
ri.saveEx();
} finally {
PO.clearCrossTenantSafe();
}
} else {
DB.executeUpdateEx("UPDATE AD_RecentItem SET Updated=getDate() WHERE AD_RecentItem_ID=?", new Object[] {ric.getAD_RecentItem_ID()}, null);
}

View File

@ -351,6 +351,7 @@ public class MSession extends X_AD_Session implements ImmutablePOSupport
+ ": " + OldValue + " -> " + NewValue);
try
{
PO.setCrossTenantSafe();
MChangeLog cl = new MChangeLog(getCtx(),
AD_ChangeLog_ID, TrxName, getAD_Session_ID(),
AD_Table_ID, AD_Column_ID, Record_ID, AD_Client_ID, AD_Org_ID,
@ -365,6 +366,10 @@ public class MSession extends X_AD_Session implements ImmutablePOSupport
+ ", AD_Table_ID=" + AD_Table_ID + ", AD_Column_ID=" + AD_Column_ID, e);
return null;
}
finally
{
PO.clearCrossTenantSafe();
}
log.log(Level.SEVERE, "AD_ChangeLog_ID=" + AD_ChangeLog_ID
+ ", AD_Session_ID=" + getAD_Session_ID()
+ ", AD_Table_ID=" + AD_Table_ID + ", AD_Column_ID=" + AD_Column_ID);

View File

@ -107,8 +107,12 @@ public class MShippingTransaction extends X_M_ShippingTransaction
msg.append(getErrorMessage());
msg.append("\nAction: " + getAction());
history.setTextMsg(msg.toString());
try {
PO.setCrossTenantSafe();
history.saveEx();
} finally {
PO.clearCrossTenantSafe();
}
setProcessed(processed);
return processed;

View File

@ -5520,9 +5520,7 @@ public abstract class PO
* @return true if all the foreign keys are valid
*/
private void checkRecordIDCrossTenant() {
// exclude read-only high-traffic tables
if ( MChangeLog.Table_Name.equals(get_TableName())
|| MRecentItem.Table_Name.equals(get_TableName()))
if (isSafeCrossTenant.get())
return;
int idxRecordId = p_info.getColumnIndex("Record_ID");
if (idxRecordId < 0)