diff --git a/core/install.php b/core/install.php index b9cdde00..423a4481 100644 --- a/core/install.php +++ b/core/install.php @@ -281,14 +281,18 @@ function create_tables(Database $db) $db->execute("CREATE INDEX images_tags_tag_id_idx ON image_tags(tag_id)", []); $db->execute("INSERT INTO config(name, value) VALUES('db_version', 11)"); - $db->commit(); + + // mysql auto-commits when creating a table, so the transaction + // is closed; other databases need to commit + if($db->is_transaction_open()) { + $db->commit(); + } } catch (PDOException $e) { throw new InstallerException( "PDO Error:", "

An error occurred while trying to create the database tables necessary for Shimmie.

Please check and ensure that the database configuration options are all correct.

{$e->getMessage()}

- ", 3 ); diff --git a/index.php b/index.php index 301cc879..51733ebc 100644 --- a/index.php +++ b/index.php @@ -83,7 +83,7 @@ try { $page->display(); } - if ($database->transaction===true) { + if ($database->is_transaction_open()) { $database->commit(); } @@ -92,7 +92,7 @@ try { fastcgi_finish_request(); } } catch (Exception $e) { - if ($database && $database->transaction===true) { + if ($database && $database->is_transaction_open()) { $database->rollback(); } _fatal_error($e);