Skip to content

Upgrade to Laravel 7.x #4482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2c5d963
Apply code style
laravel-shift Aug 23, 2022
1c3290a
Adopt short array syntax
laravel-shift Aug 23, 2022
3386bed
Add laravel/ui dependency
laravel-shift Aug 23, 2022
349fa5d
Convert factory types to states
laravel-shift Aug 23, 2022
532d694
Shift config files
laravel-shift Aug 23, 2022
7672638
Default config files
laravel-shift Aug 23, 2022
2772efa
Bump Laravel dependencies
laravel-shift Aug 23, 2022
ff2b75a
Shift cleanup
laravel-shift Aug 23, 2022
f2c1f28
Shift test config and references
laravel-shift Aug 23, 2022
efd5ac2
Update error handler to use Throwable
nolanpro Aug 1, 2022
c747ac0
Remove unused traits in controllers
nolanpro Aug 1, 2022
0f6256e
Update namespaces for medialibrary
nolanpro Aug 1, 2022
47d568b
Use guzzle 7.4
nolanpro Aug 1, 2022
07713ca
Remove unused package
nolanpro Aug 1, 2022
973516f
Update argument compatibility
nolanpro Aug 1, 2022
2d25ec0
Update additional MediaLibrary namespaces
nolanpro Aug 9, 2022
cb15244
Fix Laravel echo server error
nolanpro Aug 9, 2022
6c84a28
Upgrade Spatie MediaLibrary to v9
nolanpro Aug 9, 2022
f6cb45a
Remove script
nolanpro Aug 10, 2022
f8689bf
Remove .phpunit.result.cache
nolanpro Aug 10, 2022
7308ed3
Add .phpunit.result.cache to git ignore
nolanpro Aug 10, 2022
da50ad1
Change getOriginal to getRawOriginal in test
nolanpro Aug 15, 2022
f8d25ea
Fix custom MediaPathGenerator
nolanpro Aug 15, 2022
e7f7c98
Upgrade php swagger
nolanpro Aug 16, 2022
dc78e37
Add bearer auth to swagger ui
nolanpro Aug 16, 2022
1bd9ab6
Fix phpunit tests
nolanpro Aug 16, 2022
492d58e
Fix additional tests
nolanpro Aug 16, 2022
cb7cd53
Add helper function to register OpenAPI annotations
nolanpro Aug 17, 2022
7b0b6e2
Use original mail settings for now
nolanpro Aug 18, 2022
8b8b3f0
Set pmql to dev-develop until a new release is available
nolanpro Aug 23, 2022
7e0626d
Run composer update
nolanpro Aug 23, 2022
ae645ab
Remove config files from packages
nolanpro Aug 26, 2022
e07b67c
Update horizon assets
nolanpro Aug 26, 2022
5b033bf
Merge branch 'develop' into shift-69390
nolanpro Oct 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ coverage
cypress/screenshots
cypress/videos
cypress/downloads
.phpunit.result.cache
.php-cs-fixer.cache
.phpunit.result.cache
2 changes: 1 addition & 1 deletion ProcessMaker/Console/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Database\Query\Grammars\SqlServerGrammar;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
Expand Down
18 changes: 10 additions & 8 deletions ProcessMaker/Exception/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace ProcessMaker\Exception;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
Expand All @@ -12,6 +11,7 @@
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Route as RouteFacade;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;

/**
* Our general exception handler
Expand All @@ -34,10 +34,12 @@ class Handler extends ExceptionHandler

/**
* Report our exception. If in testing with verbosity, it will also dump exception information to the console
* @param Exception $exception
* @throws Exception
*
* @param Throwable $exception
*
* @throws Throwable
*/
public function report(Exception $exception)
public function report(Throwable $exception)
{
if (App::environment() == 'testing' && env('TESTING_VERBOSE')) {
// If we're verbose, we should print ALL Exceptions to the screen
Expand All @@ -52,10 +54,10 @@ public function report(Exception $exception)
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Throwable $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
public function render($request, Throwable $exception)
{
$prefix = '';
$route = $request->route();
Expand Down Expand Up @@ -118,10 +120,10 @@ protected function unauthenticated($request, AuthenticationException $exception)
* Convert the given exception to an array.
* @note This is overridding Laravel's default exception handler in order to handle binary data in message
*
* @param \Exception $e
* @param \Throwable $e
* @return array
*/
protected function convertExceptionToArray(Exception $e)
protected function convertExceptionToArray(Throwable $e)
{
return config('app.debug') ? [
'message' => utf8_encode($e->getMessage()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

namespace ProcessMaker\Http\Controllers\Api;

/**
* @OA\OpenApi(
* @OA\Info(
Expand Down Expand Up @@ -89,10 +92,8 @@
* )
* ),
* ),
* security={
* {"pm_api_auth_code": {}},
* {"pm_api_bearer": {}},
* {"pm_api_key": {}}
* },
* )
*/
class OpenApiSpec
{
}
14 changes: 7 additions & 7 deletions ProcessMaker/Http/Controllers/Api/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
use ProcessMaker\Nayra\Exceptions\ElementNotFoundException;
use ProcessMaker\Nayra\Storage\BpmnDocument;
use ProcessMaker\Nayra\Storage\BpmnElement;
use ProcessMaker\Rules\BPMNValidation;
use ProcessMaker\Providers\WorkflowServiceProvider;
use ProcessMaker\Package\WebEntry\Models\WebentryRoute;
use ProcessMaker\Providers\WorkflowServiceProvider;
use ProcessMaker\Rules\BPMNValidation;
use Throwable;

class ProcessController extends Controller
Expand Down Expand Up @@ -1176,21 +1176,21 @@ private function validateImportedFile($content)
return $isDecoded && $validType && $validVersion;
}

private function checkForExistingRoute($processId, $route)
{
$existingRoute = WebentryRoute::where('first_segment', $route)->where('process_id','!=', $processId)->first();
private function checkForExistingRoute($processId, $route)
{
$existingRoute = WebentryRoute::where('first_segment', $route)->where('process_id', '!=', $processId)->first();
if ($existingRoute) {
throw new \Exception('Segment should be unique. Used in process ' . $existingRoute->process_id . 'node ID: "' . $existingRoute->node_id . '"');
}
}

private function updateRoute($node, $route)
private function updateRoute($node, $route)
{
$config = json_decode($node->getAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'config'), true);
if ($config['web_entry']['webentryRouteConfig']['firstUrlSegment'] !== $route) {
// update firstUrlSegment to new route
$config['web_entry']['webentryRouteConfig']['firstUrlSegment'] = $route;

// update entryUrl to new route
$path = parse_url($config['web_entry']['webentryRouteConfig']['entryUrl'], PHP_URL_PATH);
$newEntryUrl = str_replace($config['web_entry']['webentryRouteConfig']['firstUrlSegment'], $route, $path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use ProcessMaker\Http\Resources\ApiResource;
use ProcessMaker\Models\Media;
use ProcessMaker\Models\ProcessRequest;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;

class ProcessRequestFileController extends Controller
{
Expand All @@ -36,8 +34,6 @@ class ProcessRequestFileController extends Controller
'responsive_images',
];

use HasMediaTrait;

/**
* Display a listing of the resource.
*
Expand Down
5 changes: 1 addition & 4 deletions ProcessMaker/Http/Controllers/RequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
use ProcessMaker\Package\PackageComments\PackageServiceProvider;
use ProcessMaker\Traits\HasControllerAddons;
use ProcessMaker\Traits\SearchAutocompleteTrait;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\Models\Media;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

class RequestController extends Controller
{
use HasMediaTrait;
use SearchAutocompleteTrait;
use HasControllerAddons;

Expand Down
15 changes: 15 additions & 0 deletions ProcessMaker/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ class Kernel extends HttpKernel
'external.connection' => \ProcessMaker\Http\Middleware\ValidateExternalConnection::class,
'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
];

/**
* The auth:anon middleware must run after a session is set up to
* check if there is a user logged in before implying the user is
* anonymous.
*
* The auth:anon middleware is only used for the laravel echo
* server route: broadcasting/auth
*
* @var array
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\AuthenticateSession::class,
\ProcessMaker\Http\Middleware\ProcessMakerAuthenticate::class,
];
}
8 changes: 4 additions & 4 deletions ProcessMaker/Http/Middleware/AuthenticateSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace ProcessMaker\Http\Middleware;

use Closure;
use BadMethodCallException;
use Closure;
use Illuminate\Session\Middleware\AuthenticateSession as BaseAuthenticateSession;

class AuthenticateSession extends BaseAuthenticateSession
Expand All @@ -19,7 +19,7 @@ class AuthenticateSession extends BaseAuthenticateSession
*/
public function handle($request, Closure $next)
{
if (! $request->hasSession() || ! $request->user()) {
if (!$request->hasSession() || !$request->user()) {
return $next($request);
}

Expand All @@ -30,15 +30,15 @@ public function handle($request, Closure $next)
if ($this->auth->viaRemember()) {
$passwordHash = explode('|', $request->cookies->get($this->auth->getRecallerName()))[2] ?? null;

if (! $passwordHash || $passwordHash != $request->user()->getAuthPassword()) {
if (!$passwordHash || $passwordHash != $request->user()->getAuthPassword()) {
$this->logout($request);
}
}
} catch (BadMethodCallException $exception) {
return $next($request);
}

if (! $request->session()->has('password_hash')) {
if (!$request->session()->has('password_hash')) {
$this->storePasswordHashInSession($request);
}

Expand Down
21 changes: 12 additions & 9 deletions ProcessMaker/ImportExport/MigrationHelper.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

namespace ProcessMaker\ImportExport;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;

class MigrationHelper {

public function addUuidsToTables($tables) {
class MigrationHelper
{
public function addUuidsToTables($tables)
{
foreach ($tables as $table) {
if (!Schema::hasColumn($table, 'uuid')) {
Schema::table($table, function (Blueprint $table) {
Expand All @@ -16,8 +18,9 @@ public function addUuidsToTables($tables) {
}
}
}

public function removeUuidsFromTables($tables) {

public function removeUuidsFromTables($tables)
{
foreach ($tables as $table) {
if (Schema::hasColumn($table, 'uuid')) {
Schema::table($table, function (Blueprint $table) {
Expand All @@ -29,17 +32,17 @@ public function removeUuidsFromTables($tables) {

public function populateUuids($tables)
{
foreach($tables as $table) {
foreach ($tables as $table) {
\DB::table($table)
->select('id')
->where('uuid', '=', null)
->orderBy('id')->chunkById(1000, function($rows) use ($table) {
->orderBy('id')->chunkById(1000, function ($rows) use ($table) {
$count = count($rows);
foreach ($rows as $row) {
$uuid = (string) Str::orderedUuid();
\DB::statement("update `$table` set `uuid` = ? where `id` = ?", [$uuid, $row->id]);
}
});
}
}
}
}
}
12 changes: 6 additions & 6 deletions ProcessMaker/Jobs/GenerateUuidsForTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class GenerateUuidsForTable implements ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

private $table;

private $field;

private $primary;

/**
Expand All @@ -41,16 +41,16 @@ public function handle()
{
$query = DB::table($this->table)
->select($this->primary, $this->field)
->orderBy($this->primary)->chunk(1000, function($records) {
->orderBy($this->primary)->chunk(1000, function ($records) {
// Assign UUIDs if needed
foreach ($records as &$record) {
if (! $record->{$this->field} || trim($record->{$this->field}) === '') {
if (!$record->{$this->field} || trim($record->{$this->field}) === '') {
$record->{$this->field} = (string) Str::orderedUuid();
}
}

// Set UUIDs in transaction for performance reasons
DB::transaction(function() use($records) {
DB::transaction(function () use ($records) {
foreach ($records as &$record) {
DB::table($this->table)
->where($this->primary, $record->{$this->primary})
Expand Down
2 changes: 1 addition & 1 deletion ProcessMaker/Jobs/ImportProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private function parseWebEntryCustomRoutes()
foreach ($tasks as $task) {
$config = json_decode($task->getAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'config'), true);
if (isset($config['web_entry']) && isset($config['web_entry']['webentryRouteConfig'])) {
$webEntryRouteConfig= $config['web_entry']['webentryRouteConfig'];
$webEntryRouteConfig = $config['web_entry']['webentryRouteConfig'];
if ($webEntryRouteConfig['firstUrlSegment'] != '') {
$error = null;
$existingRoute = WebentryRoute::where('first_segment', $webEntryRouteConfig['firstUrlSegment'])->where('process_id', '!=', $importedProcessId)->first();
Expand Down
1 change: 0 additions & 1 deletion ProcessMaker/Jobs/SanitizeUsernames.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function __construct(Collection $users)
public function handle()
{
foreach ($this->users as $index => $user) {

// Store the pre-update username for comparison
$pre_update_username = $user->username;
$updated_username = static::filterAndValidateUsername($user->username, $user->id);
Expand Down
5 changes: 2 additions & 3 deletions ProcessMaker/Jobs/TerminateHorizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace ProcessMaker\Jobs;

use Illuminate\Support\Facades\Log;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;

class TerminateHorizon implements ShouldQueue
{
Expand Down Expand Up @@ -42,4 +42,3 @@ public function handle(): void
]);
}
}

2 changes: 1 addition & 1 deletion ProcessMaker/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Support\Facades\Storage;
use Spatie\MediaLibrary\FileManipulator;
use Spatie\MediaLibrary\Filesystem\Filesystem;
use Spatie\MediaLibrary\Models\Media as BaseMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia;

class Media extends BaseMedia
{
Expand Down
2 changes: 1 addition & 1 deletion ProcessMaker/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Validation\ValidationException;
use ProcessMaker\Models\ProcessRequest;
use Spatie\MediaLibrary\Models\Media as Model;
use Spatie\MediaLibrary\MediaCollections\Models\Media as Model;

/**
* Represents media files stored in the database
Expand Down
4 changes: 2 additions & 2 deletions ProcessMaker/Models/MediaPathGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace ProcessMaker\Models;

use Spatie\MediaLibrary\Models\Media;
use Spatie\MediaLibrary\PathGenerator\PathGenerator;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;

class MediaPathGenerator implements PathGenerator
{
Expand Down
Loading