Remove \Basic class from all other Class extensions
If not created Logger class will be auto created in \DB\IO Recommended to run a CoreLibs\Debug\Logging([...]); and use this class for all ACL\Login, Admin\Backend, DB\IO, Output\Form\Generate calls. Last parameter after DB CONFIG is the log parameter Session create has been moved to a new Create\Session class from the \Basic class and MUST be started before using ACL\Login. Currently ACL\Login will fallback and start it if no session is yet started. See the Readme.md file for which classes use _SESSION data In future the _SESSION settings should be moved to some wrapper class for this so we can unit test sessions Only Output\Form\Generate class call has the new changed with the second parameter no longer beeing the table width setting but the class setting. But as this is a semi retired class and only used for edit_base this is not 100% breaking. All other classes can be used as is and have internal fallback to run as before. Deprecation messages will be added later.
This commit is contained in:
@@ -77,21 +77,19 @@ class Basic
|
||||
/** @var array<mixed> */
|
||||
public $data_path = [];
|
||||
|
||||
// session name
|
||||
/** @var string */
|
||||
private $session_name = '';
|
||||
/** @var string */
|
||||
private $session_id = ''; /** @phpstan-ignore-line */
|
||||
|
||||
// ajax flag
|
||||
/** @var bool */
|
||||
protected $ajax_page_flag = false;
|
||||
|
||||
/**
|
||||
* main Basic constructor to init and check base settings
|
||||
* @param \CoreLibs\Debug\Logging|null $log Logging class
|
||||
* @param string|null $session_name Set session name
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct(
|
||||
\CoreLibs\Debug\Logging $log = null,
|
||||
?string $session_name = null
|
||||
) {
|
||||
// TODO make check dynamic for entries we MUST have depending on load type
|
||||
// before we start any work, we should check that all MUST constants are defined
|
||||
$abort = false;
|
||||
@@ -117,6 +115,9 @@ class Basic
|
||||
die('Core Constant missing. Check config file.');
|
||||
}
|
||||
|
||||
// logging interface moved here (->debug is now ->log->debug)
|
||||
$this->log = $log ?? new \CoreLibs\Debug\Logging();
|
||||
|
||||
// set ajax page flag based on the AJAX_PAGE varaibles
|
||||
// convert to true/false so if AJAX_PAGE is 0 or false it is
|
||||
// always boolean false
|
||||
@@ -136,8 +137,6 @@ class Basic
|
||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||
// set host name
|
||||
list($this->host_name , $this->host_port) = \CoreLibs\Get\System::getHostName();
|
||||
// logging interface moved here (->debug is now ->log->debug)
|
||||
$this->log = new \CoreLibs\Debug\Logging();
|
||||
|
||||
// set the regex for checking emails
|
||||
/** @deprecated */
|
||||
@@ -147,25 +146,7 @@ class Basic
|
||||
$this->email_regex_check = \CoreLibs\Check\Email::getEmailRegexCheck();
|
||||
|
||||
// initial the session if there is no session running already
|
||||
if (!session_id()) {
|
||||
// check if we have an external session name given, else skip this step
|
||||
if (defined('SET_SESSION_NAME')) {
|
||||
// set the session name for possible later check
|
||||
$this->session_name = SET_SESSION_NAME;
|
||||
}
|
||||
// override with global if set
|
||||
if (isset($GLOBALS['SET_SESSION_NAME'])) {
|
||||
$this->session_name = $GLOBALS['SET_SESSION_NAME'];
|
||||
}
|
||||
// if set, set special session name
|
||||
if ($this->session_name) {
|
||||
session_name($this->session_name);
|
||||
}
|
||||
// start session
|
||||
session_start();
|
||||
// set internal session id, we can use that later for protection check
|
||||
$this->session_id = (string)session_id();
|
||||
}
|
||||
\CoreLibs\Create\Session::startSession($session_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user