Throws an exception when the installer has not yet been executed.

This commit is contained in:
Fernando Ontiveros
2025-06-17 16:02:14 -04:00
parent aa91c83867
commit eeb4064a9c
5 changed files with 150 additions and 147 deletions

View File

@@ -0,0 +1,20 @@
<?php
namespace ProcessMaker\Exception;
use G;
/**
* Class ExecuteInstallerException
* @package ProcessMaker\Exception
*/
class ExecuteInstallerException extends \Exception
{
/**
* @param string $message
*/
public function __construct()
{
parent::__construct("");
}
}

View File

@@ -4,6 +4,7 @@ use Maveriks\Http\Response;
use Maveriks\Pattern\Mvc\PhtmlView;
use ProcessMaker\Core\AppEvent;
use ProcessMaker\Exception\RBACException;
use ProcessMaker\Exception\ExecuteInstallerException;
// Because laravel has a __ helper function, it's important we include the class.g file to ensure our __ is used.
require_once __DIR__ . '/../../gulliver/system/class.g.php';
@@ -57,6 +58,13 @@ try {
}
} catch (RBACException $e) {
G::header('location: ' . $e->getPath());
} catch (ExecuteInstallerException $e) {
$view = new PhtmlView($rootDir . "framework/src/templates/error.phtml");
$view->set("title", "Installation Required");
$view->set("message", "Please run lurana-installer to use the software. \n\nIf you've already run it, there might be an issue. \nPlease contact support.");
$view->set("exception", $e);
$response = new Response($view->getOutput(), 403);
$response->send();
} catch (Exception $e) {
$view = new PhtmlView($rootDir . "framework/src/templates/Exception.phtml");
$view->set("message", $e->getMessage());

View File

@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Log;
use ProcessMaker\Core\AppEvent;
use ProcessMaker\Core\JobsManager;
use ProcessMaker\ChangeLog\ChangeLog;
use ProcessMaker\Exception\ExecuteInstallerException;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Validation\ValidationUploadedFiles;
@@ -344,37 +345,8 @@ $oHeadPublisher = headPublisher::getSingleton();
// Installer, redirect to install if we don't have a valid shared data folder
if (!defined('PATH_DB') || !file_exists(PATH_DB)) {
// new installer, extjs based
//important to start laravel classes
app()->useStoragePath(realpath(PATH_DATA));
app()->make(Kernel::class)->bootstrap();
restore_error_handler();
$pathFile = PATH_CONTROLLERS . 'InstallerModule.php';
require_once ($pathFile);
$controller = InstallerModule::class;
// if the method name is empty set default to index method
if (strpos(SYS_TARGET, '/') !== false) {
list($controller, $controllerAction) = explode('/', SYS_TARGET);
} else {
$controllerAction = SYS_TARGET;
}
$controllerAction = ($controllerAction != '' && $controllerAction != 'login') ? $controllerAction : 'index';
// create the installer controller and call its method
if (method_exists(InstallerModule::class, $controllerAction)) {
$installer = new $controller();
$installer->setHttpRequestData($_REQUEST);
$installer->call($controllerAction);
} else {
$_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI'];
header("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
}
exit();
// installer was removed from core. Display an error message
throw new ExecuteInstallerException();
}
app()->useStoragePath(realpath(PATH_DATA));