diff --git a/composer.json b/composer.json index 318dbb3a6..3c372da63 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "socialiteproviders/okta": "^1.0", "socialiteproviders/gitlab": "^3.0", "socialiteproviders/twitch": "^3.0", - "socialiteproviders/discord": "^2.0" + "socialiteproviders/discord": "^2.0", + "doctrine/dbal": "^2.5" }, "require-dev": { "filp/whoops": "~2.0", diff --git a/composer.lock b/composer.lock index 51fde846a..6a92409dd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "b98be6702f1293174f785f99895e798b", + "content-hash": "eae00f50d183bb224c934683b06e8f9c", "packages": [ { "name": "aws/aws-sdk-php", @@ -254,6 +254,355 @@ ], "time": "2014-05-19T10:25:02+00:00" }, + { + "name": "doctrine/annotations", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-02-24T16:22:25+00:00" + }, + { + "name": "doctrine/cache", + "version": "v1.6.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", + "shasum": "" + }, + "require": { + "php": "~5.5|~7.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2017-07-22T12:49:21+00:00" + }, + { + "name": "doctrine/collections", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/1a4fb7e902202c33cce8c55989b945612943c2ba", + "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/coding-standard": "~0.1@dev", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2017-01-03T10:49:41+00:00" + }, + { + "name": "doctrine/common", + "version": "v2.7.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/4acb8f89626baafede6ee5475bc5844096eba8a9", + "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~5.6|~7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2017-07-22T08:35:12+00:00" + }, + { + "name": "doctrine/dbal", + "version": "v2.5.13", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "729340d8d1eec8f01bff708e12e449a3415af873" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/729340d8d1eec8f01bff708e12e449a3415af873", + "reference": "729340d8d1eec8f01bff708e12e449a3415af873", + "shasum": "" + }, + "require": { + "doctrine/common": ">=2.4,<2.8-dev", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "symfony/console": "2.*||^3.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ], + "time": "2017-07-22T20:44:48+00:00" + }, { "name": "doctrine/inflector", "version": "v1.2.0", @@ -5464,7 +5813,8 @@ "prefer-lowest": false, "platform": { "php": ">=7.0.0", - "ext-tidy": "*" + "ext-tidy": "*", + "ext-dom": "*" }, "platform-dev": [], "platform-overrides": { diff --git a/database/migrations/2015_07_12_114933_create_books_table.php b/database/migrations/2015_07_12_114933_create_books_table.php index 4220809d5..51fb55c48 100644 --- a/database/migrations/2015_07_12_114933_create_books_table.php +++ b/database/migrations/2015_07_12_114933_create_books_table.php @@ -12,13 +12,7 @@ class CreateBooksTable extends Migration */ public function up() { - $pdo = \DB::connection()->getPdo(); - $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION); - $requiresISAM = strpos($mysqlVersion, '5.5') === 0; - - Schema::create('books', function (Blueprint $table) use ($requiresISAM) { - if($requiresISAM) $table->engine = 'MyISAM'; - + Schema::create('books', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('slug')->indexed(); diff --git a/database/migrations/2015_07_12_190027_create_pages_table.php b/database/migrations/2015_07_12_190027_create_pages_table.php index 0a29d1087..7a1dcec0e 100644 --- a/database/migrations/2015_07_12_190027_create_pages_table.php +++ b/database/migrations/2015_07_12_190027_create_pages_table.php @@ -12,13 +12,9 @@ class CreatePagesTable extends Migration */ public function up() { - $pdo = \DB::connection()->getPdo(); - $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION); - $requiresISAM = strpos($mysqlVersion, '5.5') === 0; - Schema::create('pages', function (Blueprint $table) use ($requiresISAM) { - if($requiresISAM) $table->engine = 'MyISAM'; - + + Schema::create('pages', function (Blueprint $table) { $table->increments('id'); $table->integer('book_id'); $table->integer('chapter_id'); diff --git a/database/migrations/2015_07_27_172342_create_chapters_table.php b/database/migrations/2015_07_27_172342_create_chapters_table.php index 3ec414480..7974759f2 100644 --- a/database/migrations/2015_07_27_172342_create_chapters_table.php +++ b/database/migrations/2015_07_27_172342_create_chapters_table.php @@ -12,12 +12,7 @@ class CreateChaptersTable extends Migration */ public function up() { - $pdo = \DB::connection()->getPdo(); - $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION); - $requiresISAM = strpos($mysqlVersion, '5.5') === 0; - - Schema::create('chapters', function (Blueprint $table) use ($requiresISAM) { - if($requiresISAM) $table->engine = 'MyISAM'; + Schema::create('chapters', function (Blueprint $table) { $table->increments('id'); $table->integer('book_id'); $table->string('slug')->indexed(); diff --git a/database/migrations/2015_08_31_175240_add_search_indexes.php b/database/migrations/2015_08_31_175240_add_search_indexes.php index 127f69d28..497f88add 100644 --- a/database/migrations/2015_08_31_175240_add_search_indexes.php +++ b/database/migrations/2015_08_31_175240_add_search_indexes.php @@ -12,10 +12,13 @@ class AddSearchIndexes extends Migration */ public function up() { - $prefix = DB::getTablePrefix(); - DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)"); - DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)"); - DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)"); + // This was removed for v0.24 since these indexes are removed anyway + // and will cause issues for db engines that don't support such indexes. + +// $prefix = DB::getTablePrefix(); +// DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)"); +// DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)"); +// DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)"); } /** @@ -25,14 +28,28 @@ class AddSearchIndexes extends Migration */ public function down() { - Schema::table('pages', function(Blueprint $table) { - $table->dropIndex('search'); - }); - Schema::table('books', function(Blueprint $table) { - $table->dropIndex('search'); - }); - Schema::table('chapters', function(Blueprint $table) { - $table->dropIndex('search'); - }); + $sm = Schema::getConnection()->getDoctrineSchemaManager(); + $pages = $sm->listTableDetails('pages'); + $books = $sm->listTableDetails('books'); + $chapters = $sm->listTableDetails('chapters'); + + if ($pages->hasIndex('search')) { + Schema::table('pages', function(Blueprint $table) { + $table->dropIndex('search'); + }); + } + + if ($books->hasIndex('search')) { + Schema::table('books', function(Blueprint $table) { + $table->dropIndex('search'); + }); + } + + if ($chapters->hasIndex('search')) { + Schema::table('chapters', function(Blueprint $table) { + $table->dropIndex('search'); + }); + } + } } diff --git a/database/migrations/2015_12_05_145049_fulltext_weighting.php b/database/migrations/2015_12_05_145049_fulltext_weighting.php index 998131387..2e884b55c 100644 --- a/database/migrations/2015_12_05_145049_fulltext_weighting.php +++ b/database/migrations/2015_12_05_145049_fulltext_weighting.php @@ -12,10 +12,13 @@ class FulltextWeighting extends Migration */ public function up() { - $prefix = DB::getTablePrefix(); - DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)"); - DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)"); - DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)"); + // This was removed for v0.24 since these indexes are removed anyway + // and will cause issues for db engines that don't support such indexes. + +// $prefix = DB::getTablePrefix(); +// DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)"); +// DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)"); +// DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)"); } /** @@ -25,14 +28,27 @@ class FulltextWeighting extends Migration */ public function down() { - Schema::table('pages', function(Blueprint $table) { - $table->dropIndex('name_search'); - }); - Schema::table('books', function(Blueprint $table) { - $table->dropIndex('name_search'); - }); - Schema::table('chapters', function(Blueprint $table) { - $table->dropIndex('name_search'); - }); + $sm = Schema::getConnection()->getDoctrineSchemaManager(); + $pages = $sm->listTableDetails('pages'); + $books = $sm->listTableDetails('books'); + $chapters = $sm->listTableDetails('chapters'); + + if ($pages->hasIndex('name_search')) { + Schema::table('pages', function(Blueprint $table) { + $table->dropIndex('name_search'); + }); + } + + if ($books->hasIndex('name_search')) { + Schema::table('books', function(Blueprint $table) { + $table->dropIndex('name_search'); + }); + } + + if ($chapters->hasIndex('name_search')) { + Schema::table('chapters', function(Blueprint $table) { + $table->dropIndex('name_search'); + }); + } } } diff --git a/database/migrations/2017_03_19_091553_create_search_index_table.php b/database/migrations/2017_03_19_091553_create_search_index_table.php index 32c6a09e1..edffb445c 100644 --- a/database/migrations/2017_03_19_091553_create_search_index_table.php +++ b/database/migrations/2017_03_19_091553_create_search_index_table.php @@ -26,19 +26,31 @@ class CreateSearchIndexTable extends Migration $table->index('score'); }); - // Drop search indexes - Schema::table('pages', function(Blueprint $table) { - $table->dropIndex('search'); - $table->dropIndex('name_search'); - }); - Schema::table('books', function(Blueprint $table) { - $table->dropIndex('search'); - $table->dropIndex('name_search'); - }); - Schema::table('chapters', function(Blueprint $table) { - $table->dropIndex('search'); - $table->dropIndex('name_search'); - }); + $sm = Schema::getConnection()->getDoctrineSchemaManager(); + $pages = $sm->listTableDetails('pages'); + $books = $sm->listTableDetails('books'); + $chapters = $sm->listTableDetails('chapters'); + + if ($pages->hasIndex('search')) { + Schema::table('pages', function(Blueprint $table) { + $table->dropIndex('search'); + $table->dropIndex('name_search'); + }); + } + + if ($books->hasIndex('search')) { + Schema::table('books', function(Blueprint $table) { + $table->dropIndex('search'); + $table->dropIndex('name_search'); + }); + } + + if ($chapters->hasIndex('search')) { + Schema::table('chapters', function(Blueprint $table) { + $table->dropIndex('search'); + $table->dropIndex('name_search'); + }); + } app(\BookStack\Services\SearchService::class)->indexAllEntities(); } @@ -50,14 +62,17 @@ class CreateSearchIndexTable extends Migration */ public function down() { - $prefix = DB::getTablePrefix(); - DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)"); - DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)"); - DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)"); - DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)"); - DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)"); - DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)"); + // This was removed for v0.24 since these indexes are removed anyway + // and will cause issues for db engines that don't support such indexes. +// $prefix = DB::getTablePrefix(); +// DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)"); +// DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)"); +// DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)"); +// DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)"); +// DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)"); +// DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)"); + Schema::dropIfExists('search_terms'); } }