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
This commit is contained in:
Nabeel S
2020-02-28 18:56:01 -05:00
committed by GitHub
parent 2f40f4737c
commit b0f122a301
11 changed files with 103 additions and 122 deletions
+6 -1
View File
@@ -46,7 +46,12 @@ abstract class Enum
final public static function label($value) final public static function label($value)
{ {
if (isset(static::$labels[$value])) { if (isset(static::$labels[$value])) {
return trans(static::$labels[$value]); $val = static::$labels[$value];
if (strpos($val, '.') !== false) {
return trans($val);
}
return $val;
} }
} }
+23 -19
View File
@@ -12,13 +12,14 @@ return [
'username' => env('DB_USERNAME', ''), 'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''), 'password' => env('DB_PASSWORD', ''),
//'unix_socket' => env('DB_SOCKET', ''), //'unix_socket' => env('DB_SOCKET', ''),
'prefix' => env('DB_PREFIX', ''), 'prefix' => env('DB_PREFIX', ''),
'timezone' => '+00:00', 'prefix_indexes' => true,
'charset' => 'utf8', 'timezone' => '+00:00',
'collation' => 'utf8_unicode_ci', 'charset' => 'utf8',
'strict' => false, 'collation' => 'utf8_unicode_ci',
'engine' => null, 'strict' => false,
'options' => [ 'engine' => null,
'options' => [
PDO::ATTR_EMULATE_PREPARES => env('DB_EMULATE_PREPARES', false), PDO::ATTR_EMULATE_PREPARES => env('DB_EMULATE_PREPARES', false),
//PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, //PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
], ],
@@ -27,22 +28,25 @@ return [
], ],
], ],
'sqlite' => [ 'sqlite' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => storage_path('db.sqlite'), 'database' => storage_path('db.sqlite'),
'timezone' => '+00:00', 'timezone' => '+00:00',
'prefix' => '', 'prefix' => '',
'prefix_indexes' => true,
], ],
'testing' => [ 'testing' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => storage_path('testing.sqlite'), 'database' => storage_path('testing.sqlite'),
'timezone' => '+00:00', 'timezone' => '+00:00',
'prefix' => '', 'prefix' => '',
'prefix_indexes' => true,
], ],
'memory' => [ 'memory' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => ':memory:', 'database' => ':memory:',
'timezone' => '+00:00', 'timezone' => '+00:00',
'prefix' => '', 'prefix' => '',
'prefix_indexes' => true,
], ],
], ],
@@ -36,6 +36,18 @@ class ImporterController extends Controller
return view('importer::step1-configure'); 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 * Check the database connection
* *
@@ -49,14 +61,7 @@ class ImporterController extends Controller
$message = 'Database connection looks good!'; $message = 'Database connection looks good!';
try { try {
$this->dbSvc->checkDbConnection( $this->testDb($request);
$request->post('db_conn'),
$request->post('db_host'),
$request->post('db_port'),
$request->post('db_name'),
$request->post('db_user'),
$request->post('db_pass')
);
} catch (\Exception $e) { } catch (\Exception $e) {
$status = 'danger'; $status = 'danger';
$message = 'Failed! '.$e->getMessage(); $message = 'Failed! '.$e->getMessage();
@@ -78,6 +83,8 @@ class ImporterController extends Controller
public function config(Request $request) public function config(Request $request)
{ {
try { try {
$this->testDb($request);
// Save the credentials to use later // Save the credentials to use later
$this->importerSvc->saveCredentialsFromRequest($request); $this->importerSvc->saveCredentialsFromRequest($request);
+21 -27
View File
@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title') - importer</title> <title>@yield('title') - installer</title>
<link rel="shortcut icon" type="image/png" href="{{ public_asset('/assets/img/favicon.png') }}"/> <link rel="shortcut icon" type="image/png" href="{{ public_asset('/assets/img/favicon.png') }}"/>
@@ -35,35 +35,29 @@
</style> </style>
</head> </head>
<body> <body class="login-page" style="background: #067ec1;">
<!-- Navbar --> <div class="page-header clear-filter">
<nav class="navbar navbar-toggleable-md" style="background: #067ec1;"> <div class="content">
<div class="container" style="width: 85%!important;"> <div class="container">
<div class="navbar-translate"> <div class="row">
<p class="navbar-brand text-white" data-placement="bottom" target="_blank"> <div class="col-md-8 ml-auto mr-auto content-center">
<a href="{{ url('/') }}"> <div class="p-10" style="padding: 10px 0;">
<img src="{{ public_asset('/assets/img/logo_blue_bg.svg') }}" width="135px" style=""/> <img src="{{ public_asset('/assets/img/logo_blue_bg.svg') }}" width="135px" style="" alt=""/>
</a> </div>
</p> <div class="card card-login card-plain" style="background: #FFF">
</div> <div class="card-header text-center">
<div class="justify-content-center" id="navigation" style="margin-left: 50px; color: white; font-size: 20px;"> <h3 class="card-title title">@yield('title')</h3>
@yield('title') </div>
</div> <div class="card-body">
</div> <hr />
</nav> @include('importer::flash.message')
<!-- End Navbar --> @yield('content')
{{--<div class="clearfix" style="height: 25px;"></div>--}} </div>
<div class="wrapper"> </div>
<div class="clear"></div> </div>
<div class="container" style="width: 50%">
<div class="row">
<div class="col-12">
@include('importer::flash.message')
@yield('content')
</div> </div>
</div> </div>
</div> </div>
<div class="clearfix" style="height: 200px;"></div>
</div> </div>
{{--<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>--}} {{--<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>--}}
@@ -4,8 +4,7 @@
@section('content') @section('content')
<div style="align-content: center;"> <div style="align-content: center;">
{{ Form::open(['route' => 'importer.config', 'method' => 'POST']) }} {{ Form::open(['route' => 'importer.config', 'method' => 'POST']) }}
<table class="table" width="25%"> <table class="table">
<tr> <tr>
<td colspan="2"> <td colspan="2">
<h4>IMPORTANT NOTES</h4> <h4>IMPORTANT NOTES</h4>
@@ -24,25 +23,12 @@
</tr> </tr>
<tr> <tr>
<td colspan="2"><h4>Site Config</h4> <td colspan="2">
<p>Enter the database information for your legacy (v2 or v5) database</p> <h4>Database Config</h4>
<p>Enter the database information for your legacy phpVMS installation</p>
</td> </td>
</tr> </tr>
<tr>
<td>Admin Email</td>
<td style="text-align:center;">
<div class="form-group">
{{ Form::input('text', 'email', '', ['class' => 'form-control']) }}
<p>The admin's email address, the password for this will be reset</p>
</div>
</td>
</tr>
<tr>
<td colspan="2"><h4>Database Config</h4></td>
</tr>
<tbody id="mysql_settings"> <tbody id="mysql_settings">
<tr> <tr>
<td>Database Host</td> <td>Database Host</td>
@@ -62,7 +62,6 @@ class ImporterService extends Service
public function saveCredentialsFromRequest(Request $request) public function saveCredentialsFromRequest(Request $request)
{ {
$creds = [ $creds = [
'admin_email' => $request->post('email'),
'host' => $request->post('db_host'), 'host' => $request->post('db_host'),
'port' => $request->post('db_port'), 'port' => $request->post('db_port'),
'name' => $request->post('db_name'), 'name' => $request->post('db_name'),
@@ -64,18 +64,6 @@
<div class="card card-login card-plain" style="background: #FFF"> <div class="card card-login card-plain" style="background: #FFF">
<div class="card-header text-center"> <div class="card-header text-center">
<h3 class="card-title title">@yield('title')</h3> <h3 class="card-title title">@yield('title')</h3>
{{--<div class="text-large">
<a href="#" onclick="return false;" class="btn btn-neutral btn-facebook btn-icon btn-round">
<i class="now-ui-icons design_bullet-list-02"></i>
</a>
<a href="#" onclick="return false;" class="btn btn-neutral btn-twitter btn-icon btn-lg btn-round">
<i class="now-ui-icons users_single-02"></i>
</a>
<a href="#" onclick="return false;" class="btn btn-neutral btn-google btn-icon btn-round">
<i class="now-ui-icons users_single-02"></i>
</a>
</div>--}}
</div> </div>
<div class="card-body"> <div class="card-body">
<hr /> <hr />
@@ -20,7 +20,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="2"><h4>php extensions</h4></td> <td colspan="2"><h4>PHP Extensions</h4></td>
</tr> </tr>
@foreach($extensions as $ext) @foreach($extensions as $ext)
<tr> <tr>
@@ -37,7 +37,7 @@
<tr> <tr>
<td colspan="2"> <td colspan="2">
<h4>directory permissions</h4> <h4>Directory Permissions</h4>
<p>Make sure these directories have read and write permissions</p> <p>Make sure these directories have read and write permissions</p>
</td> </td>
</tr> </tr>
@@ -28,7 +28,10 @@
</tr> </tr>
<tr> <tr>
<td colspan="2"><h4>Database Config</h4></td> <td colspan="2">
<h4>Database Config</h4>
<p>Enter the target database information</p>
</td>
</tr> </tr>
<tr> <tr>
+21 -27
View File
@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title') - updater</title> <title>@yield('title') - installer</title>
<link rel="shortcut icon" type="image/png" href="{{ public_asset('/assets/img/favicon.png') }}"/> <link rel="shortcut icon" type="image/png" href="{{ public_asset('/assets/img/favicon.png') }}"/>
@@ -35,35 +35,29 @@
</style> </style>
</head> </head>
<body> <body class="login-page" style="background: #067ec1;">
<!-- Navbar --> <div class="page-header clear-filter">
<nav class="navbar navbar-toggleable-md" style="background: #067ec1;"> <div class="content">
<div class="container" style="width: 85%!important;"> <div class="container">
<div class="navbar-translate"> <div class="row">
<p class="navbar-brand text-white" data-placement="bottom" target="_blank"> <div class="col-md-8 ml-auto mr-auto content-center">
<a href="{{ url('/') }}"> <div class="p-10" style="padding: 10px 0;">
<img src="{{ public_asset('/assets/img/logo_blue_bg.svg') }}" width="135px" style=""/> <img src="{{ public_asset('/assets/img/logo_blue_bg.svg') }}" width="135px" style="" alt=""/>
</a> </div>
</p> <div class="card card-login card-plain" style="background: #FFF">
</div> <div class="card-header text-center">
<div class="justify-content-center" id="navigation" style="margin-left: 50px; color: white; font-size: 20px;"> <h3 class="card-title title">@yield('title')</h3>
@yield('title') </div>
</div> <div class="card-body">
</div> <hr />
</nav> @include('updater::flash.message')
<!-- End Navbar --> @yield('content')
{{--<div class="clearfix" style="height: 25px;"></div>--}} </div>
<div class="wrapper"> </div>
<div class="clear"></div> </div>
<div class="container" style="width: 50%">
<div class="row">
<div class="col-12">
@include('installer::flash.message')
@yield('content')
</div> </div>
</div> </div>
</div> </div>
<div class="clearfix" style="height: 200px;"></div>
</div> </div>
{{--<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>--}} {{--<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>--}}
+7 -6
View File
@@ -64,12 +64,13 @@ return [
'default' => env('DB_CONNECTION', '$DB_CONN$'), 'default' => env('DB_CONNECTION', '$DB_CONN$'),
'connections' => [ 'connections' => [
'mysql' => [ 'mysql' => [
'host' => env('DB_HOST', '$DB_HOST$'), 'host' => env('DB_HOST', '$DB_HOST$'),
'port' => $DB_PORT$, 'port' => $DB_PORT$,
'database' => '$DB_NAME$', 'database' => '$DB_NAME$',
'username' => '$DB_USER$', 'username' => '$DB_USER$',
'password' => '$DB_PASS$', 'password' => '$DB_PASS$',
'prefix' => '$DB_PREFIX$', 'prefix' => '$DB_PREFIX$',
'prefix_indexes' => true,
], ],
], ],
], ],