Page MenuHomePhabricator

Investigate where wb_entity_per_page table is used and needed
Closed, ResolvedPublic

Description

Research and document, where or by what tools the wb_entity_per_page table

  • is currently used
  • will still be needed

Event Timeline

I have grepped for wb_entity_per_page in our code base, here is the result: https://phabricator.wikimedia.org/P3511

Here is a summary of places where we reference the wb_entity_per_page table, and what should be doen about them:

extensions/Wikibase/lib/includes/Store/Sql/SqlEntityInfoBuilder.php

SqlEntityInfoBuilder uses wb_entity_per_page to find the page ID and redirect information for a list of EntityIds. This can be done based on the page and redirect tables instead.

extensions/Wikibase/repo/includes/Store/Sql/PropertyInfoTableBuilder.php

PropertyInfoTableBuilder uses wb_entity_per_page to list all properties. This can be done using the page table instead, based on the namespace.

extensions/Wikibase/repo/includes/Store/Sql/EntityPerPageTable.php

This is the big one. We will continue to need some of the me methods defined by the EntityPerPage interfaces, but not others:

  • listEntities() will still be needed, can be implemented on top of the page table. Can perhaps be moved into EntityPerPageIdPager (which can then be renamed to SqlEntityIdPager).
  • getEntitiesWithoutTerm() should be moved elsewhere and changed to use the page table.
  • getItemsWithoutSitelinks() should be moved elsewhere and changed to use the page table.

The rest can really go:

  • addEntityPage() can be dropped, we rely on the page table via WikiPage storage
  • addRedirectPage() can be dropped, we rely on the redirect table via WikiPage storage
  • deleteEntityPage() can be dropped from this interface, callers should be migrated to use WikiPage.
  • deleteEntity() can be dropped from this interface, callers should be migrated to use EntityStore.
  • clear() can be dropped.

The remaining of the occurrences of wb_entity_per_page are pointless once the changes above are implemented:

extensions/Wikibase/repo/includes/Store/Sql/EntityPerPageBuilder.php

No longer needed once no code relies on the information from wb_entity_per_page anymore.

extensions/Wikibase/repo/includes/Store/Sql/DatabaseSchemaUpdater.php
extensions/Wikibase/repo/sql/Wikibase.sql
extensions/Wikibase/repo/sql/AddEntityPerPage.sql
extensions/Wikibase/repo/sql/AddEppRedirectTarget.sqlite.sql
extensions/Wikibase/repo/sql/AddEppRedirectTarget.sql

When we no longer need the table, it can be removed from Wikibase.sql and DatabaseSchemaUpdater.php. AddEntityPerPage.sql and AddEppRedirectTarget.sqlite.sql can be dropped entirely.

extensions/Wikibase/repo/tests/phpunit/includes/Store/Sql/EntityPerPageTableTest.php
extensions/Wikibase/repo/tests/phpunit/includes/Store/Sql/PropertyInfoTableBuilderTest.php
extensions/Wikibase/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityStoreTest.php
extensions/Wikibase/repo/tests/phpunit/includes/Store/Sql/EntityPerPageBuilderTest.php
extensions/Wikibase/lib/tests/phpunit/Store/Sql/SqlEntityInfoBuilderTest.php

When the code doesn't use the table any more, the tests should obviously also stop using it.

So, we need to change three classes that still need the information from wb_entity_per_page: SqlEntityInfoBuilder, PropertyInfoTableBuilder, and EntityPerPage(Table). Then we can drop references to the table from all other parts of the code, and finally the table itself.

Investigation complete. I suggest to keep this open until we have created tasks for the steps needed to get rid of wb_entity_per_page.

Thanks @daniel! Do the tasks about removing the reference to the table need further discussion? Otherwise I suggest to create the tasks right away and make them blockers of T95685.

Thanks @daniel! Do the tasks about removing the reference to the table need further discussion? Otherwise I suggest to create the tasks right away and make them blockers of T95685.

No discussion needed, I was just done for the day ;) I'll create the tickets now.