Lucas_Werkmeister_WMDE added a comment.

  Ok, some of this is just that other parameter types need to be changed from 
`IDatabase` to `IReadableDatabase`, no big deal.
  
  But `EntityUsageTable` and `SqlUsageTracker` is nasty. `EntityUsageTable` has 
both an `IDatabase $writeConnection` and a `ClientDomainDb` (the latter not 
injected yet, ew). If you use a “write” method like `removeUsages()`, it uses 
the injected write connection. If you use a “read” method like 
`getPagesUsing()`, it gets a “read” connection from the `ClientDomainDb`. But 
you still need a connection to create an `EntityUsageTable` instance (it’s a 
required constructor argument) – and some `SqlUsageTracker` methods create an 
`EntityUsageTable` from a read connection! The only reason this doesn’t blow up 
is that those methods never call any of the “write” `EntityUsageTable` methods 
that would try to use the injected connection (which is actually a “read” 
connection!) like a “write” connection.
  
  I think the only reason `EntityUsageTable` gets the connection injected is 
that `SqlUsageTracker` gets that connection from a 
//SessionConsistent//ConnectionManager, so the “read” connection may sometimes 
in fact be a “write” connection. I think for now I’ll just `EntityUsageTable`’s 
injected connection nullable, and have the “write” methods throw an error if 
they’re called when no such connection was injected. That’s still a 
runtime-only error for a condition that we would ideally prevent at Phan 
type-checking time (split the “read” and “write” parts of `EntityUsageTable`?), 
but it’s better than mixing up “read” and “write” connections like it’s done at 
the moment.

TASK DETAIL
  https://phabricator.wikimedia.org/T337717

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, Astuthiodit_1, karapayneWMDE, Invadibot, 
maantietaja, ItamarWMDE, Akuckartz, Nandana, Lahi, Gq86, GoranSMilovanovic, 
QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, 
Jdforrester-WMF, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to