Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-21884: Uploading files during page creation step will mark XWikiGuest as creator #2885

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.xwiki.rest.internal.Utils;
import org.xwiki.rest.model.jaxb.Attachment;
import org.xwiki.rest.model.jaxb.Attachments;
import org.xwiki.user.UserReferenceResolver;

import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.XWikiContext;
Expand Down Expand Up @@ -127,6 +128,10 @@ public boolean isAlreadyExisting()
@Named("context")
private Provider<ComponentManager> componentManagerProvider;

@Inject
@Named("document")
private UserReferenceResolver<DocumentReference> documentReferenceUserReferenceResolver;

/**
* @param scope where to retrieve the attachments from; it should be a reference to a wiki, space or document
* @param filters the filters used to restrict the set of attachments (you can filter by space name, document
Expand Down Expand Up @@ -411,7 +416,11 @@ protected XWikiAttachment createOrUpdateAttachment(AttachmentReference attachmen
String.format("Failed to instantiate a [%s] component.", AttachmentValidator.class.getName()), e);
}

// Set the document author.
// Set the document creator / author.
if (document.isNew()) {
document.getAuthors()
.setCreator(this.documentReferenceUserReferenceResolver.resolve(xcontext.getUserReference()));
}
document.setAuthorReference(xcontext.getUserReference());

// Calculate and store the attachment media type.
Expand Down