[MAGNOLIA-4452] Node versions are not stored with the correct user Created: 21/Jun/12  Updated: 31/Jul/12  Resolved: 23/Jul/12

Status: Closed
Project: Magnolia
Component/s: core, security
Affects Version/s: 4.5
Fix Version/s: 4.5.4

Type: Bug Priority: Critical
Reporter: Zdenek Skodik Assignee: Milan Divilek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

All node versions created since (???) are marked as created by superuser, because of (???). This is due to BaseVersionManager#createVersion(Node node, Rule rule) defaulting to MgnlContext.getUser().getName() when no explicit user name is passed.



 Comments   
Comment by Jan Haderka [ 19/Jul/12 ]

Why do you create version with empty user name? You should always attempt to retrieve the username before giving up and leaving it empty.

-        return createVersion(node.getJCRNode(), rule);
+        return createVersion(node.getJCRNode(), rule, "");
Comment by Jan Haderka [ 23/Jul/12 ]
-        return createVersion(node.getJCRNode(), rule, "");
+        return createVersion(node.getJCRNode(), rule, MgnlContext.getUser().getName());

you can't just use the user, there is no guarantee that it's set. For example if you don't pass user as a param in SimpleContext it would return null so you need to check if getUser() doesn't return null first.

Generated at Mon Feb 12 03:55:55 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.