23use InvalidArgumentException;
54 $storedPathsByEntity = [];
55 foreach ( $depsBlobByEntity as $entity => $depsBlob ) {
56 $storedPathsByEntity[$entity] = json_decode( $depsBlob,
true );
60 foreach ( $entities as $entity ) {
61 $paths = $storedPathsByEntity[$entity] ?? [];
78 foreach ( $dataByEntity as $entity => $data ) {
80 if ( !is_array( $data[self::KEY_PATHS] ) ) {
81 throw new InvalidArgumentException(
"Invalid entry for '$entity'" );
85 $paths = array_values( array_unique( $data[self::KEY_PATHS] ) );
86 sort( $paths, SORT_STRING );
87 $blob = json_encode( $paths, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
89 $existingBlob = $depsBlobByEntity[$entity] ??
null;
90 if (
$blob !== $existingBlob ) {
92 'md_module' => $module,
93 'md_skin' => $variant,
101 foreach ( $rows as $row ) {
105 [ [
'md_module',
'md_skin' ] ],
107 'md_deps' => $row[
'md_deps'],
117 public function remove(
$type, $entities ) {
121 $disjunctionConds = [];
122 foreach ( (array)$entities as $entity ) {
124 $disjunctionConds[] = $dbw->makeList(
125 [
'md_skin' => $variant,
'md_module' => $module ],
130 if ( $disjunctionConds ) {
133 $dbw->makeList( $disjunctionConds, $dbw::LIST_OR ),
152 $modulesByVariant = [];
153 foreach ( $entities as $entity ) {
155 $modulesByVariant[$variant][] = $module;
158 $disjunctionConds = [];
159 foreach ( $modulesByVariant as $variant =>
$modules ) {
160 $disjunctionConds[] = $db->
makeList(
161 [
'md_skin' => $variant,
'md_module' =>
$modules ],
166 $depsBlobByEntity = [];
168 if ( $disjunctionConds ) {
171 [
'md_module',
'md_skin',
'md_deps' ],
172 $db->
makeList( $disjunctionConds, $db::LIST_OR ),
176 foreach (
$res as $row ) {
177 $entity =
"{$row->md_module}|{$row->md_skin}";
178 $depsBlobByEntity[$entity] = $row->md_deps;
182 return $depsBlobByEntity;
190 ->getConnectionRef(
DB_REPLICA, [],
false, ( $this->lb )::CONN_TRX_AUTOCOMMIT );
198 ->getConnectionRef(
DB_MASTER, [],
false, ( $this->lb )::CONN_TRX_AUTOCOMMIT );
206 $parts = explode(
'|', $entity, 2 );
207 if ( count( $parts ) !== 2 ) {
208 throw new InvalidArgumentException(
"Invalid module entity '$entity'" );