1 | <?php |
||
17 | class DatabaseTermIdsResolver implements TermIdsResolver { |
||
18 | |||
19 | /** @var TypeIdsResolver */ |
||
20 | private $typeIdsResolver; |
||
21 | |||
22 | /** @var ILoadBalancer */ |
||
23 | private $lb; |
||
24 | |||
25 | /** @var bool */ |
||
26 | private $allowMasterFallback; |
||
27 | |||
28 | /** @var IDatabase */ |
||
29 | private $dbr = null; |
||
30 | |||
31 | /** @var IDatabase */ |
||
32 | private $dbw = null; |
||
33 | |||
34 | /** @var string[] stash of data returned from the {@link TypeIdsResolver} */ |
||
35 | private $typeNames = []; |
||
36 | |||
37 | /** |
||
38 | * @param TypeIdsResolver $typeIdsResolver |
||
39 | * @param ILoadBalancer $lb |
||
40 | * @param bool $allowMasterFallback Whether to fall back to the master database if the data from |
||
41 | * the replica database is detected to be stale. |
||
42 | */ |
||
43 | public function __construct( |
||
52 | |||
53 | /* |
||
54 | * Term data is first read from the replica; if that returns less rows than we asked for, then |
||
55 | * there are some new rows in the master that were not yet replicated, and we fall back to the |
||
56 | * master if allowed. As the internal relations of the term store never change (for example, a |
||
57 | * term_in_lang row will never suddenly point to a different text_in_lang), a master fallback |
||
58 | * should never be necessary in any other case. However, callers need to consider where they |
||
59 | * got the list of term IDs they pass into this method from: if it’s from a replica, they may |
||
60 | * still see outdated data overall. |
||
61 | */ |
||
62 | public function resolveTermIds( array $termIds ): array { |
||
85 | |||
86 | private function selectTerms( IDatabase $db, array $termIds ): IResultWrapper { |
||
99 | |||
100 | private function preloadTypes( IResultWrapper $result ) { |
||
110 | |||
111 | private function addResultTerms( array &$terms, stdClass $row ) { |
||
117 | |||
118 | private function lookupType( $typeId ) { |
||
126 | |||
127 | private function getDbr() { |
||
134 | |||
135 | private function getDbw() { |
||
146 | |||
147 | } |
||
148 |