* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
- * @since 1.20
+ * @since 1.21
*
* @file
* @ingroup Site
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
* @author Daniel Werner
*/
* Holds the local ids for this site.
* You can obtain them via @see getLocalIds
*
- * @since 1.20
+ * @since 1.21
*
* @var array|false
*/
/**
* @see Site::getGlobalId
*
- * @since 1.20
+ * @since 1.21
*
* @return string
*/
/**
* @see Site::setGlobalId
*
- * @since 1.20
+ * @since 1.21
*
* @param string $globalId
*/
/**
* @see Site::getType
*
- * @since 1.20
+ * @since 1.21
*
* @return string
*/
/**
* @see Site::setType
*
- * @since 1.20
+ * @since 1.21
*
* @param string $type
*/
/**
* @see Site::getGroup
*
- * @since 1.20
+ * @since 1.21
*
* @return string
*/
/**
* @see Site::setGroup
*
- * @since 1.20
+ * @since 1.21
*
* @param string $group
*/
/**
* @see Site::getSource
*
- * @since 1.20
+ * @since 1.21
*
* @return string
*/
/**
* @see Site::setSource
*
- * @since 1.20
+ * @since 1.21
*
* @param string $source
*/
/**
* @see Site::getDomain
*
- * @since 1.20
+ * @since 1.21
*
* @return string|false
*/
/**
* @see Site::getProtocol
*
- * @since 1.20
+ * @since 1.21
*
* @return string|false
*/
$path = $this->getLinkPath();
if ( $path === false ) {
- return false;
+ return '';
}
- return parse_url( $path, PHP_URL_SCHEME );
+ $protocol = parse_url( $path, PHP_URL_SCHEME );
+
+ // Malformed URL
+ if ( $protocol === false ) {
+ throw new MWException( "failed to parse URL $path" );
+ }
+
+ // No schema
+ if ( $protocol === null ) {
+ // Used for protocol relative URLs
+ $protocol = '';
+ }
+
+ return $protocol;
}
/**
*
* @param string $fullUrl
*
- * @since 1.20
+ * @since 1.21
*
* @throws MWException
*/
* This default implementation returns SiteObject::PATH_LINK as the default path type. Subclasses can override this
* to define a different default path type, or return false to disable site links.
*
- * @since 1.20
+ * @since 1.21
*
* @return string|false
*/
*
* This implementation returns a URL constructed using the path returned by getLinkPath().
*
- * @since 1.20
+ * @since 1.21
*
* @param bool|String $pageName
*
*
* @see Site::normalizePageName
*
- * @since 1.20
+ * @since 1.21
*
* @param string $pageName
*
* Returns the value of a type specific field, or the value
* of the $default parameter in case it's not set.
*
- * @since 1.20
+ * @since 1.21
*
* @param string $fieldName
* @param mixed $default
/**
* Sets the value of a type specific field.
- * @since 1.20
+ * @since 1.21
*
* @param string $fieldName
* @param mixed $value
/**
* @see Site::getLanguageCode
*
- * @since 1.20
+ * @since 1.21
*
* @return string|false
*/
/**
* @see Site::setLanguageCode
*
- * @since 1.20
+ * @since 1.21
*
* @param string $languageCode
*/
/**
* Returns the local identifiers of this site.
*
- * @since 1.20
+ * @since 1.21
*
* @param string $type
*
/**
* Loads the local ids for the site.
*
- * @since 1.20
+ * @since 1.21
*/
protected function loadLocalIds() {
$dbr = wfGetDB( $this->getTable()->getReadDb() );
/**
* Adds a local identifier.
*
- * @since 1.20
+ * @since 1.21
*
* @param string $type
* @param string $identifier
/**
* @see Site::addInterwikiId
*
- * @since 1.20
+ * @since 1.21
*
* @param string $identifier
*/
/**
* @see Site::addNavigationId
*
- * @since 1.20
+ * @since 1.21
*
* @param string $identifier
*/
/**
* @see Site::getInterwikiIds
*
- * @since 1.20
+ * @since 1.21
*
* @return array of string
*/
/**
* @see Site::getNavigationIds
*
- * @since 1.20
+ * @since 1.21
*
* @return array of string
*/
/**
* @see Site::getInternalId
*
- * @since 1.20
+ * @since 1.21
*
* @return integer
*/
}
/**
- * @see ORMRow::save
+ * @see IORMRow::save
* @see Site::save
*
- * @since 1.20
+ * @since 1.21
*
* @param string|null $functionName
*
* @return boolean Success indicator
*/
public function save( $functionName = null ) {
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $this->table->getWriteDbConnection();
$trx = $dbw->trxLevel();
return $success;
}
+ /**
+ * @since 1.21
+ *
+ * @see ORMRow::onRemoved
+ */
+ protected function onRemoved() {
+ $dbw = $this->table->getWriteDbConnection();
+
+ $dbw->delete(
+ 'site_identifiers',
+ array(
+ 'si_site' => $this->getId()
+ ),
+ __METHOD__
+ );
+
+ parent::onRemoved();
+ }
+
/**
* @see Site::setPath
*
- * @since 1.20
+ * @since 1.21
*
* @param string $pathType
* @param string $fullUrl
/**
* @see Sitres::getPath
*
- * @since 1.20
+ * @since 1.21
*
* @param string $pathType
*
/**
* @see Sitres::getAll
*
- * @since 1.20
+ * @since 1.21
*
* @return array of string
*/
/**
* @see Sitres::removePath
*
- * @since 1.20
+ * @since 1.21
*
* @param string $pathType
*/