Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64293


Change subject: Throw a TableCreationFailedException when table creation fails 
rather then returning false
......................................................................

Throw a TableCreationFailedException when table creation fails rather then 
returning false

Change-Id: Idf0e573df2a1349bcdcdd97096335ba1c7008c83
---
M Database/includes/MediaWikiQueryInterface.php
M Database/includes/TableBuilder.php
M QueryEngine/includes/SQLStore/Setup.php
3 files changed, 15 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/93/64293/1

diff --git a/Database/includes/MediaWikiQueryInterface.php 
b/Database/includes/MediaWikiQueryInterface.php
index b404cd0..0c02e71 100644
--- a/Database/includes/MediaWikiQueryInterface.php
+++ b/Database/includes/MediaWikiQueryInterface.php
@@ -82,10 +82,14 @@
         *
         * @param TableDefinition $table
         *
-        * @return boolean Success indicator
+        * @throws TableCreationFailedException
         */
        public function createTable( TableDefinition $table ) {
-               return $this->extendedAbstraction->createTable( $table );
+               $success = $this->extendedAbstraction->createTable( $table );
+
+               if ( $success !== true ) {
+                       throw new TableCreationFailedException( $table );
+               }
        }
 
        /**
diff --git a/Database/includes/TableBuilder.php 
b/Database/includes/TableBuilder.php
index d0876cc..db35afc 100644
--- a/Database/includes/TableBuilder.php
+++ b/Database/includes/TableBuilder.php
@@ -72,8 +72,6 @@
         * @since 0.1
         *
         * @param TableDefinition $table
-        *
-        * @return boolean Success indicator
         */
        public function createTable( TableDefinition $table ) {
                if ( $this->db->tableExists( $table->getName() ) ) {
@@ -83,7 +81,7 @@
 
                $this->report( 'Table "' . $table->getName() . '" not found, 
creating.' );
 
-               return $this->db->createTable( $table );
+               $this->db->createTable( $table );
        }
 
 }
\ No newline at end of file
diff --git a/QueryEngine/includes/SQLStore/Setup.php 
b/QueryEngine/includes/SQLStore/Setup.php
index c4ccd86..a48a39c 100644
--- a/QueryEngine/includes/SQLStore/Setup.php
+++ b/QueryEngine/includes/SQLStore/Setup.php
@@ -5,6 +5,7 @@
 use MessageReporter;
 use Wikibase\Database\FieldDefinition;
 use Wikibase\Database\QueryInterface;
+use Wikibase\Database\QueryInterfaceException;
 use Wikibase\Database\TableBuilder;
 use Wikibase\Database\TableDefinition;
 
@@ -104,36 +105,31 @@
         * Install the store.
         *
         * @since 0.1
-        *
-        * @return boolean Success indicator
         */
        public function install() {
                $this->report( 'Starting install of ' . 
$this->config->getStoreName() );
 
-               $success = $this->setupTables();
+               try {
+                       $this->setupTables();
+               }
+               catch ( QueryInterfaceException $exception ) {
+                       // TODO: throw exception of proper type
+               }
 
                // TODO: initialize basic content
 
                $this->report( 'Finished install of ' . 
$this->config->getStoreName() );
-
-               return $success;
        }
 
        /**
         * Sets up the tables of the store.
         *
         * @since 0.1
-        *
-        * @return boolean Success indicator
         */
        private function setupTables() {
-               $success = true;
-
                foreach ( $this->storeSchema->getTables() as $table ) {
-                       $success = $this->tableBuilder->createTable( $table ) 
&& $success;
+                       $this->tableBuilder->createTable( $table );
                }
-
-               return $success;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/64293
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf0e573df2a1349bcdcdd97096335ba1c7008c83
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to