Skip to content
Snippets Groups Projects
Unverified Commit 205cedb4 authored by Manuel Leduc's avatar Manuel Leduc Committed by GitHub
Browse files

XWIKI-19614: The locale is ignored when indexing documents (#1816)

- Use getDocumentReferenceWithLocale instead of getDocumentReference when:
  - passing the DocumentReference to the task consumers.
  - resolving the previous version of a documentation during mentions analysis
- Reindex the links and attachments they are missing for localized pages
parent 5e8c522e
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 16 deletions
...@@ -138,7 +138,18 @@ ...@@ -138,7 +138,18 @@
--> -->
<!-- Difference related to the Security refactoring. Start a new <revapi.differences> entry for other <!-- Difference related to the Security refactoring. Start a new <revapi.differences> entry for other
differences --> differences -->
<revapi.differences>
<differences>
<item>
<ignore>true</ignore>
<code>java.class.removed</code>
<old>class org.xwiki.index.migration.R140200001XWIKI19352DataMigration</old>
<justification>R140200001XWIKI19352DataMigration replaced by R140300000XWIKI19614DataMigration because a link reindexing is required by XWIKI-19614, making an additional reindexing for migrations from version lower than 14.2RC1 useless.</justification>
<criticality>allowed</criticality>
</item>
</differences>
</revapi.differences>
</analysisConfiguration> </analysisConfiguration>
</configuration> </configuration>
</plugin> </plugin>
......
...@@ -98,6 +98,6 @@ private void internalExecute(TaskData task) throws XWikiException, IndexExceptio ...@@ -98,6 +98,6 @@ private void internalExecute(TaskData task) throws XWikiException, IndexExceptio
doc = this.documentRevisionProvider.getRevision(document, task.getVersion()); doc = this.documentRevisionProvider.getRevision(document, task.getVersion());
} }
this.componentManager.get().<TaskConsumer>getInstance(TaskConsumer.class, task.getType()) this.componentManager.get().<TaskConsumer>getInstance(TaskConsumer.class, task.getType())
.consume(doc.getDocumentReference(), doc.getVersion()); .consume(doc.getDocumentReferenceWithLocale(), doc.getVersion());
} }
} }
...@@ -48,13 +48,13 @@ ...@@ -48,13 +48,13 @@
// TODO: Implement DataMigration once XWIKI-19399 is fixed. // TODO: Implement DataMigration once XWIKI-19399 is fixed.
@Component @Component
@Singleton @Singleton
@Named(R140200001XWIKI19352DataMigration.HINT) @Named(R140300000XWIKI19614DataMigration.HINT)
public class R140200001XWIKI19352DataMigration implements HibernateDataMigration public class R140300000XWIKI19614DataMigration implements HibernateDataMigration
{ {
/** /**
* The hint for this component. * The hint for this component.
*/ */
public static final String HINT = "140200001XWIKI19352"; public static final String HINT = "R140300000XWIKI19614";
@Inject @Inject
private QueryManager queryManager; private QueryManager queryManager;
...@@ -80,7 +80,7 @@ public String getDescription() ...@@ -80,7 +80,7 @@ public String getDescription()
@Override @Override
public XWikiDBVersion getVersion() public XWikiDBVersion getVersion()
{ {
return new XWikiDBVersion(140200001); return new XWikiDBVersion(140300000);
} }
@Override @Override
......
...@@ -4,5 +4,5 @@ org.xwiki.index.internal.TaskExecutor ...@@ -4,5 +4,5 @@ org.xwiki.index.internal.TaskExecutor
org.xwiki.index.internal.TaskApplicationReadyListener org.xwiki.index.internal.TaskApplicationReadyListener
org.xwiki.index.internal.DefaultLinksTaskConsumer org.xwiki.index.internal.DefaultLinksTaskConsumer
org.xwiki.index.internal.listener.LinksUpdateListener org.xwiki.index.internal.listener.LinksUpdateListener
org.xwiki.index.migration.R140200001XWIKI19352DataMigration org.xwiki.index.migration.R140300000XWIKI19614DataMigration
org.xwiki.index.TaskConsumerScriptService org.xwiki.index.TaskConsumerScriptService
...@@ -111,7 +111,7 @@ void execute() throws Exception ...@@ -111,7 +111,7 @@ void execute() throws Exception
when(this.tasksStore.getDocument("wikiId", 42)).thenReturn(this.xwikiDocument); when(this.tasksStore.getDocument("wikiId", 42)).thenReturn(this.xwikiDocument);
when(this.documentRevisionProvider.getRevision(this.xwikiDocument, "1.5")).thenReturn(this.xwikiDocument); when(this.documentRevisionProvider.getRevision(this.xwikiDocument, "1.5")).thenReturn(this.xwikiDocument);
when(this.xwikiDocument.getDocumentReference()).thenReturn(DOCUMENT_REFERENCE); when(this.xwikiDocument.getDocumentReferenceWithLocale()).thenReturn(DOCUMENT_REFERENCE);
when(this.xwikiDocument.getVersion()).thenReturn("1.5"); when(this.xwikiDocument.getVersion()).thenReturn("1.5");
this.taskExecutor.execute(task); this.taskExecutor.execute(task);
......
...@@ -47,16 +47,16 @@ ...@@ -47,16 +47,16 @@
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
/** /**
* Test of {@link R140200001XWIKI19352DataMigration}. * Test of {@link R140300000XWIKI19614DataMigration}.
* *
* @version $Id$ * @version $Id$
* @since 14.2RC1 * @since 14.2RC1
*/ */
@ComponentTest @ComponentTest
class R140200001XWIKI19352DataMigrationTest class R140300000XWIKI19614DataMigrationTest
{ {
@InjectMockComponents(role = HibernateDataMigration.class) @InjectMockComponents(role = HibernateDataMigration.class)
private R140200001XWIKI19352DataMigration migration; private R140300000XWIKI19614DataMigration migration;
@MockComponent @MockComponent
private QueryManager queryManager; private QueryManager queryManager;
......
...@@ -93,7 +93,8 @@ public void consume(DocumentReference documentReference, String version) throws ...@@ -93,7 +93,8 @@ public void consume(DocumentReference documentReference, String version) throws
} else { } else {
// UPDATE // UPDATE
XWikiDocument oldDoc = XWikiDocument oldDoc =
this.documentRevisionProvider.getRevision(doc.getDocumentReference(), doc.getPreviousVersion()); this.documentRevisionProvider.getRevision(doc.getDocumentReferenceWithLocale(),
doc.getPreviousVersion());
mentionNotificationParameters = this.updatedDocumentMentionsAnalyzer mentionNotificationParameters = this.updatedDocumentMentionsAnalyzer
.analyze(oldDoc, doc, documentReference, doc.getVersion(), authorReference); .analyze(oldDoc, doc, documentReference, doc.getVersion(), authorReference);
} }
......
...@@ -110,7 +110,7 @@ void consumeCreatedDocumentNoMentions() throws Exception ...@@ -110,7 +110,7 @@ void consumeCreatedDocumentNoMentions() throws Exception
{ {
when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc); when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc);
when(this.doc.getPreviousVersion()).thenReturn(null); when(this.doc.getPreviousVersion()).thenReturn(null);
when(this.doc.getDocumentReference()).thenReturn(DOCUMENT_REFERENCE); when(this.doc.getDocumentReferenceWithLocale()).thenReturn(DOCUMENT_REFERENCE);
when(this.createdDocumentMentionsAnalyzer.analyze(this.doc, DOCUMENT_REFERENCE, "1.1", AUTHOR_REFERENCE)) when(this.createdDocumentMentionsAnalyzer.analyze(this.doc, DOCUMENT_REFERENCE, "1.1", AUTHOR_REFERENCE))
.thenReturn(emptyList()); .thenReturn(emptyList());
...@@ -126,7 +126,7 @@ void consumeCreatedDocumentNewMentions() throws Exception ...@@ -126,7 +126,7 @@ void consumeCreatedDocumentNewMentions() throws Exception
{ {
when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc); when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc);
when(this.doc.getPreviousVersion()).thenReturn(null); when(this.doc.getPreviousVersion()).thenReturn(null);
when(this.doc.getDocumentReference()).thenReturn(DOCUMENT_REFERENCE); when(this.doc.getDocumentReferenceWithLocale()).thenReturn(DOCUMENT_REFERENCE);
MentionNotificationParameters mentionNotificationParameters = MentionNotificationParameters mentionNotificationParameters =
new MentionNotificationParameters(AUTHOR_REFERENCE, DOCUMENT_REFERENCE, MentionLocation.DOCUMENT, new MentionNotificationParameters(AUTHOR_REFERENCE, DOCUMENT_REFERENCE, MentionLocation.DOCUMENT,
"1.1") "1.1")
...@@ -153,7 +153,7 @@ void consumeUpdatedDocumentNoMentions() throws Exception ...@@ -153,7 +153,7 @@ void consumeUpdatedDocumentNoMentions() throws Exception
when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc); when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc);
when(this.doc.getPreviousVersion()).thenReturn("1.0"); when(this.doc.getPreviousVersion()).thenReturn("1.0");
when(this.doc.getDocumentReference()).thenReturn(DOCUMENT_REFERENCE); when(this.doc.getDocumentReferenceWithLocale()).thenReturn(DOCUMENT_REFERENCE);
when( when(
this.updatedDocumentMentionsAnalyzer.analyze(oldDoc, this.doc, DOCUMENT_REFERENCE, "1.1", AUTHOR_REFERENCE)) this.updatedDocumentMentionsAnalyzer.analyze(oldDoc, this.doc, DOCUMENT_REFERENCE, "1.1", AUTHOR_REFERENCE))
.thenReturn(emptyList()); .thenReturn(emptyList());
...@@ -173,7 +173,7 @@ void consumeUpdatedDocumentNewMentions() throws Exception ...@@ -173,7 +173,7 @@ void consumeUpdatedDocumentNewMentions() throws Exception
when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.0")).thenReturn(oldDoc); when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.0")).thenReturn(oldDoc);
when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc); when(this.documentRevisionProvider.getRevision(DOCUMENT_REFERENCE, "1.1")).thenReturn(this.doc);
when(this.doc.getPreviousVersion()).thenReturn("1.0"); when(this.doc.getPreviousVersion()).thenReturn("1.0");
when(this.doc.getDocumentReference()).thenReturn(DOCUMENT_REFERENCE); when(this.doc.getDocumentReferenceWithLocale()).thenReturn(DOCUMENT_REFERENCE);
MentionNotificationParameters mentionNotificationParameters = MentionNotificationParameters mentionNotificationParameters =
new MentionNotificationParameters(AUTHOR_REFERENCE, DOCUMENT_REFERENCE, MentionLocation.DOCUMENT, new MentionNotificationParameters(AUTHOR_REFERENCE, DOCUMENT_REFERENCE, MentionLocation.DOCUMENT,
"1.1") "1.1")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment