From b0f122a3019c770028b4dab9d0c3a5d8f4e329d6 Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Fri, 28 Feb 2020 18:56:01 -0500 Subject: [PATCH] Table prefixes not being added to indexes (#597) * Enabled prefixes on any created indexes (multi-site install in single db) * Formatting * Check if enum label is looking for a translation * Return value * Fix view namespace across modules --- app/Contracts/Enum.php | 7 ++- config/database.php | 42 ++++++++-------- .../Http/Controllers/ImporterController.php | 23 +++++---- .../Importer/Resources/views/app.blade.php | 48 ++++++++----------- .../Resources/views/step1-configure.blade.php | 22 ++------- modules/Importer/Services/ImporterService.php | 1 - .../Installer/Resources/views/app.blade.php | 12 ----- .../steps/step1-requirements.blade.php | 4 +- .../views/install/steps/step2-db.blade.php | 5 +- modules/Updater/Resources/views/app.blade.php | 48 ++++++++----------- resources/stubs/installer/config.stub | 13 ++--- 11 files changed, 103 insertions(+), 122 deletions(-) diff --git a/app/Contracts/Enum.php b/app/Contracts/Enum.php index 49873aca..5d3c93cb 100644 --- a/app/Contracts/Enum.php +++ b/app/Contracts/Enum.php @@ -46,7 +46,12 @@ abstract class Enum final public static function label($value) { if (isset(static::$labels[$value])) { - return trans(static::$labels[$value]); + $val = static::$labels[$value]; + if (strpos($val, '.') !== false) { + return trans($val); + } + + return $val; } } diff --git a/config/database.php b/config/database.php index 6cea9cea..0ff7d1cb 100755 --- a/config/database.php +++ b/config/database.php @@ -12,13 +12,14 @@ return [ 'username' => env('DB_USERNAME', ''), 'password' => env('DB_PASSWORD', ''), //'unix_socket' => env('DB_SOCKET', ''), - 'prefix' => env('DB_PREFIX', ''), - 'timezone' => '+00:00', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'strict' => false, - 'engine' => null, - 'options' => [ + 'prefix' => env('DB_PREFIX', ''), + 'prefix_indexes' => true, + 'timezone' => '+00:00', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'strict' => false, + 'engine' => null, + 'options' => [ PDO::ATTR_EMULATE_PREPARES => env('DB_EMULATE_PREPARES', false), //PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ], @@ -27,22 +28,25 @@ return [ ], ], 'sqlite' => [ - 'driver' => 'sqlite', - 'database' => storage_path('db.sqlite'), - 'timezone' => '+00:00', - 'prefix' => '', + 'driver' => 'sqlite', + 'database' => storage_path('db.sqlite'), + 'timezone' => '+00:00', + 'prefix' => '', + 'prefix_indexes' => true, ], 'testing' => [ - 'driver' => 'sqlite', - 'database' => storage_path('testing.sqlite'), - 'timezone' => '+00:00', - 'prefix' => '', + 'driver' => 'sqlite', + 'database' => storage_path('testing.sqlite'), + 'timezone' => '+00:00', + 'prefix' => '', + 'prefix_indexes' => true, ], 'memory' => [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'timezone' => '+00:00', - 'prefix' => '', + 'driver' => 'sqlite', + 'database' => ':memory:', + 'timezone' => '+00:00', + 'prefix' => '', + 'prefix_indexes' => true, ], ], diff --git a/modules/Importer/Http/Controllers/ImporterController.php b/modules/Importer/Http/Controllers/ImporterController.php index 921f63c8..b499c645 100644 --- a/modules/Importer/Http/Controllers/ImporterController.php +++ b/modules/Importer/Http/Controllers/ImporterController.php @@ -36,6 +36,18 @@ class ImporterController extends Controller return view('importer::step1-configure'); } + protected function testDb(Request $request) + { + $this->dbSvc->checkDbConnection( + $request->post('db_conn'), + $request->post('db_host'), + $request->post('db_port'), + $request->post('db_name'), + $request->post('db_user'), + $request->post('db_pass') + ); + } + /** * Check the database connection * @@ -49,14 +61,7 @@ class ImporterController extends Controller $message = 'Database connection looks good!'; try { - $this->dbSvc->checkDbConnection( - $request->post('db_conn'), - $request->post('db_host'), - $request->post('db_port'), - $request->post('db_name'), - $request->post('db_user'), - $request->post('db_pass') - ); + $this->testDb($request); } catch (\Exception $e) { $status = 'danger'; $message = 'Failed! '.$e->getMessage(); @@ -78,6 +83,8 @@ class ImporterController extends Controller public function config(Request $request) { try { + $this->testDb($request); + // Save the credentials to use later $this->importerSvc->saveCredentialsFromRequest($request); diff --git a/modules/Importer/Resources/views/app.blade.php b/modules/Importer/Resources/views/app.blade.php index ed036daf..e89bdbc7 100644 --- a/modules/Importer/Resources/views/app.blade.php +++ b/modules/Importer/Resources/views/app.blade.php @@ -6,7 +6,7 @@ - @yield('title') - importer + @yield('title') - installer @@ -35,35 +35,29 @@ - - - - -{{--
--}} -
-
-
-
-
- @include('importer::flash.message') - @yield('content') + + {{----}} diff --git a/modules/Importer/Resources/views/step1-configure.blade.php b/modules/Importer/Resources/views/step1-configure.blade.php index 226fda1d..6b0772dc 100644 --- a/modules/Importer/Resources/views/step1-configure.blade.php +++ b/modules/Importer/Resources/views/step1-configure.blade.php @@ -4,8 +4,7 @@ @section('content')
{{ Form::open(['route' => 'importer.config', 'method' => 'POST']) }} - - +
- - - - - - - - - - diff --git a/modules/Importer/Services/ImporterService.php b/modules/Importer/Services/ImporterService.php index 82571156..8a7dd770 100644 --- a/modules/Importer/Services/ImporterService.php +++ b/modules/Importer/Services/ImporterService.php @@ -62,7 +62,6 @@ class ImporterService extends Service public function saveCredentialsFromRequest(Request $request) { $creds = [ - 'admin_email' => $request->post('email'), 'host' => $request->post('db_host'), 'port' => $request->post('db_port'), 'name' => $request->post('db_name'), diff --git a/modules/Installer/Resources/views/app.blade.php b/modules/Installer/Resources/views/app.blade.php index 709b62eb..638e13f0 100644 --- a/modules/Installer/Resources/views/app.blade.php +++ b/modules/Installer/Resources/views/app.blade.php @@ -64,18 +64,6 @@ - + @foreach($extensions as $ext) @@ -37,7 +37,7 @@ diff --git a/modules/Installer/Resources/views/install/steps/step2-db.blade.php b/modules/Installer/Resources/views/install/steps/step2-db.blade.php index ea7bf08c..f3956101 100644 --- a/modules/Installer/Resources/views/install/steps/step2-db.blade.php +++ b/modules/Installer/Resources/views/install/steps/step2-db.blade.php @@ -28,7 +28,10 @@ - + diff --git a/modules/Updater/Resources/views/app.blade.php b/modules/Updater/Resources/views/app.blade.php index dfdd534e..2ebde692 100644 --- a/modules/Updater/Resources/views/app.blade.php +++ b/modules/Updater/Resources/views/app.blade.php @@ -6,7 +6,7 @@ - @yield('title') - updater + @yield('title') - installer @@ -35,35 +35,29 @@ - - - - -{{--
--}} -
-
-
-
-
- @include('installer::flash.message') - @yield('content') + + {{----}} diff --git a/resources/stubs/installer/config.stub b/resources/stubs/installer/config.stub index acd89527..1d947ea0 100644 --- a/resources/stubs/installer/config.stub +++ b/resources/stubs/installer/config.stub @@ -64,12 +64,13 @@ return [ 'default' => env('DB_CONNECTION', '$DB_CONN$'), 'connections' => [ 'mysql' => [ - 'host' => env('DB_HOST', '$DB_HOST$'), - 'port' => $DB_PORT$, - 'database' => '$DB_NAME$', - 'username' => '$DB_USER$', - 'password' => '$DB_PASS$', - 'prefix' => '$DB_PREFIX$', + 'host' => env('DB_HOST', '$DB_HOST$'), + 'port' => $DB_PORT$, + 'database' => '$DB_NAME$', + 'username' => '$DB_USER$', + 'password' => '$DB_PASS$', + 'prefix' => '$DB_PREFIX$', + 'prefix_indexes' => true, ], ], ],

IMPORTANT NOTES

@@ -24,25 +23,12 @@

Site Config

-

Enter the database information for your legacy (v2 or v5) database

+
+

Database Config

+

Enter the database information for your legacy phpVMS installation

Admin Email -
- {{ Form::input('text', 'email', '', ['class' => 'form-control']) }} -

The admin's email address, the password for this will be reset

-
-

Database Config

Database Host

php extensions

PHP Extensions

-

directory permissions

+

Directory Permissions

Make sure these directories have read and write permissions

Database Config

+

Database Config

+

Enter the target database information

+