* @file
* @ingroup Site
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
* @author Daniel Werner
*/
$path = $this->getLinkPath();
if ( $path === false ) {
- return false;
+ return '';
+ }
+
+ $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 parse_url( $path, PHP_URL_SCHEME );
+ return $protocol;
}
/**
}
/**
- * @see ORMRow::save
+ * @see IORMRow::save
* @see Site::save
*
* @since 1.21
* @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
*