95 [
'ORDER BY' =>
'site_global_key' ]
100 $site->setGlobalId( $row->site_global_key );
101 $site->setInternalId( (
int)$row->site_id );
102 $site->setForward( (
bool)$row->site_forward );
103 $site->setGroup( $row->site_group );
104 $site->setLanguageCode( $row->site_language ===
''
106 : $row->site_language
108 $site->setSource( $row->site_source );
109 $site->setExtraData(
unserialize( $row->site_data ) );
110 $site->setExtraConfig(
unserialize( $row->site_config ) );
111 $this->sites[] = $site;
126 foreach ( $ids
as $id ) {
127 if ( $this->sites->hasInternalId( $id->si_site ) ) {
128 $site = $this->sites->getSiteByInternalId( $id->si_site );
129 $site->addLocalId( $id->si_type, $id->si_key );
130 $this->sites->setSite( $site );
179 $dbw = $this->dbLoadBalancer->getConnection(
DB_MASTER );
181 $dbw->startAtomic( __METHOD__ );
189 if ( $site->getInternalId() !==
null ) {
190 $internalIds[] = $site->getInternalId();
195 'site_global_key' => $site->getGlobalId(),
196 'site_type' => $site->getType(),
197 'site_group' => $site->getGroup(),
198 'site_source' => $site->getSource(),
199 'site_language' => $site->getLanguageCode() ===
null ?
'' : $site->getLanguageCode(),
200 'site_protocol' => $site->getProtocol(),
201 'site_domain' => strrev( $site->getDomain() ) .
'.',
202 'site_data' =>
serialize( $site->getExtraData() ),
205 'site_forward' => $site->shouldForward() ? 1 : 0,
206 'site_config' =>
serialize( $site->getExtraConfig() ),
209 $rowId = $site->getInternalId();
210 if ( $rowId !==
null ) {
212 'sites', $fields, [
'site_id' => $rowId ], __METHOD__
215 $rowId = $dbw->nextSequenceValue(
'sites_site_id_seq' );
216 $fields[
'site_id'] = $rowId;
218 $rowId = $dbw->insertId();
221 foreach ( $site->getLocalIds()
as $idType => $ids ) {
222 foreach ( $ids
as $id ) {
223 $localIds[] = [ $rowId, $idType, $id ];
228 if ( $internalIds !== [] ) {
231 [
'si_site' => $internalIds ],
236 foreach ( $localIds
as $localId ) {
240 'si_site' => $localId[0],
241 'si_type' => $localId[1],
242 'si_key' => $localId[2],
248 $dbw->endAtomic( __METHOD__ );