summaryrefslogtreecommitdiff
path: root/includes/site/SiteSQLStore.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/site/SiteSQLStore.php')
-rw-r--r--includes/site/SiteSQLStore.php52
1 files changed, 34 insertions, 18 deletions
diff --git a/includes/site/SiteSQLStore.php b/includes/site/SiteSQLStore.php
index 41238055..11141e07 100644
--- a/includes/site/SiteSQLStore.php
+++ b/includes/site/SiteSQLStore.php
@@ -189,6 +189,39 @@ class SiteSQLStore implements SiteStore {
}
/**
+ * Get a new ORMRow from a Site object
+ *
+ * @since 1.22
+ *
+ * @param Site
+ *
+ * @return ORMRow
+ */
+ protected function getRowFromSite( Site $site ) {
+ $fields = array(
+ // Site data
+ 'global_key' => $site->getGlobalId(), // TODO: check not null
+ 'type' => $site->getType(),
+ 'group' => $site->getGroup(),
+ 'source' => $site->getSource(),
+ 'language' => $site->getLanguageCode() === null ? '' : $site->getLanguageCode(),
+ 'protocol' => $site->getProtocol(),
+ 'domain' => strrev( $site->getDomain() ) . '.',
+ 'data' => $site->getExtraData(),
+
+ // Site config
+ 'forward' => $site->shouldForward(),
+ 'config' => $site->getExtraConfig(),
+ );
+
+ if ( $site->getInternalId() !== null ) {
+ $fields['id'] = $site->getInternalId();
+ }
+
+ return new ORMRow( $this->sitesTable, $fields );
+ }
+
+ /**
* Fetches the site from the database and loads them into the sites field.
*
* @since 1.21
@@ -291,28 +324,11 @@ class SiteSQLStore implements SiteStore {
$localIds = array();
foreach ( $sites as $site ) {
- $fields = array(
- // Site data
- 'global_key' => $site->getGlobalId(), // TODO: check not null
- 'type' => $site->getType(),
- 'group' => $site->getGroup(),
- 'source' => $site->getSource(),
- 'language' => $site->getLanguageCode() === null ? '' : $site->getLanguageCode(),
- 'protocol' => $site->getProtocol(),
- 'domain' => strrev( $site->getDomain() ) . '.',
- 'data' => $site->getExtraData(),
-
- // Site config
- 'forward' => $site->shouldForward(),
- 'config' => $site->getExtraConfig(),
- );
-
if ( $site->getInternalId() !== null ) {
- $fields['id'] = $site->getInternalId();
$internalIds[] = $site->getInternalId();
}
- $siteRow = new ORMRow( $this->sitesTable, $fields );
+ $siteRow = $this->getRowFromSite( $site );
$success = $siteRow->save( __METHOD__ ) && $success;
foreach ( $site->getLocalIds() as $idType => $ids ) {