Page MenuHomePhabricator

Refactor SqlUsageTracker to reduce code duplication
Closed, InvalidPublic

Description

This class in wikibase has lots of code duplication, making it almost impossible to solve T169336 properly. This needs to cleaned up so we can inject connections and close them easily.

Event Timeline

thiemowmde triaged this task as Lowest priority.Jul 3 2017, 11:57 AM
thiemowmde subscribed.

Please describe in much more detail what you mean. I had a quick look at the SqlUsageTracker class, but could not find any obvious code duplication. The class is quite short and does have a bunch of methods that might look similar from a distance, but are all very much distinct.

There are three comments like this:

		// NOTE: while logically we'd like the below to be atomic, we don't wrap it in a
		// transaction to prevent long lock retention during big updates.

The structure below those comments are duplicated several times making it hard to inject proper connections to newUsageTable method.

Change 363097 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] Replace self-made finally logic with actual "finally" sections

https://gerrit.wikimedia.org/r/363097

Change 363097 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Replace self-made finally logic with actual "finally" sections

https://gerrit.wikimedia.org/r/363097

This was created as a blocker for T169336, but since this is resolved it appears the proposed refactoring was not needed.