mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +00:00
Bug fixes
This commit is contained in:
parent
8c3392253f
commit
9945dbc373
|
|
@ -269,9 +269,9 @@ abstract class GrammarAbstract
|
|||
*/
|
||||
protected function compileSystem(string $system, string $prefix = '') : string
|
||||
{
|
||||
// todo: this is a bad way to handle select \count(*) which doesn't need a prefix. Maybe remove prefixes in total?
|
||||
$identifier = $this->systemIdentifier;
|
||||
|
||||
// todo: this is a bad way to handle select \count(*) which doesn't need a prefix. Maybe remove prefixes in total?
|
||||
foreach ($this->specialKeywords as $keyword) {
|
||||
if (\strrpos($system, $keyword, -\strlen($system)) !== false) {
|
||||
$prefix = '';
|
||||
|
|
@ -279,7 +279,6 @@ abstract class GrammarAbstract
|
|||
}
|
||||
}
|
||||
|
||||
// todo: move remaining * test also here not just if .* but also if * (should be done in else?)
|
||||
if (\count($split = \explode('.', $system)) > 1) {
|
||||
$fullSystem = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class HttpSession implements SessionInterface
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static $isLocked = false;
|
||||
private $isLocked = false;
|
||||
|
||||
/**
|
||||
* Raw session data.
|
||||
|
|
@ -76,7 +76,7 @@ class HttpSession implements SessionInterface
|
|||
*/
|
||||
public function __construct(int $liftetime = 3600, $sid = false, int $inactivityInterval = 0)
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
if ($this->isLocked) {
|
||||
throw new LockException('HttpSession');
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ class HttpSession implements SessionInterface
|
|||
*/
|
||||
public function lock() : void
|
||||
{
|
||||
self::$isLocked = true;
|
||||
$this->isLocked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,9 +163,9 @@ class HttpSession implements SessionInterface
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function isLocked() : bool
|
||||
public function isLocked() : bool
|
||||
{
|
||||
return self::$isLocked;
|
||||
return $this->isLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -173,7 +173,7 @@ class HttpSession implements SessionInterface
|
|||
*/
|
||||
public function save() : void
|
||||
{
|
||||
if (!self::$isLocked) {
|
||||
if (!$this->isLocked) {
|
||||
$_SESSION = $this->sessionData;
|
||||
\session_write_close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,15 +42,6 @@ final class EventManager
|
|||
*/
|
||||
private $callbacks = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach new event
|
||||
*
|
||||
|
|
@ -96,7 +87,6 @@ final class EventManager
|
|||
}
|
||||
|
||||
if (!$this->hasOutstanding($group)) {
|
||||
// todo if it is route then call dispatcher?
|
||||
$this->callbacks[$group]['func']($data);
|
||||
|
||||
if ($this->callbacks[$group]['remove']) {
|
||||
|
|
|
|||
|
|
@ -98,11 +98,11 @@ final class FileLogger implements LoggerInterface
|
|||
*/
|
||||
public function __construct(string $lpath, bool $verbose = false)
|
||||
{
|
||||
$path = \realpath($lpath);
|
||||
$path = \realpath(empty($lpath) ? __DIR__ . '/../../' : $lpath);
|
||||
$this->verbose = $verbose;
|
||||
|
||||
if (\is_dir($lpath) || \strpos($lpath, '.') === false) {
|
||||
$path = $lpath . '/' . \date('Y-m-d') . '.log';
|
||||
$path = \rtrim($lpath, '/') . '/' . \date('Y-m-d') . '.log';
|
||||
} else {
|
||||
$path = $lpath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ use phpOMS\Message\ResponseAbstract;
|
|||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Views\View;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Log\FileLogger;
|
||||
use phpOMS\Log\LogLevel;
|
||||
|
||||
/**
|
||||
* Response class.
|
||||
|
|
@ -164,8 +166,15 @@ final class Response extends ResponseAbstract implements RenderableInterface
|
|||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// todo: handle exception
|
||||
// need to to try catch for logging. otherwise the json_encode in the logger will have a problem with this
|
||||
FileLogger::getInstance('', false)
|
||||
->error(
|
||||
FileLogger::MSG_FULL, [
|
||||
'message' => $e->getMessage(),
|
||||
'line' => __LINE__,
|
||||
'file' => Response::class,
|
||||
]
|
||||
);
|
||||
|
||||
$result = [];
|
||||
} finally {
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ abstract class HeaderAbstract
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $isLocked = false;
|
||||
protected $isLocked = false;
|
||||
|
||||
/**
|
||||
* Localization.
|
||||
|
|
@ -75,10 +75,9 @@ abstract class HeaderAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function lock() : void
|
||||
public function lock() : void
|
||||
{
|
||||
// todo: maybe pass session as member and make lock not static
|
||||
self::$isLocked = true;
|
||||
$this->isLocked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,9 +87,9 @@ abstract class HeaderAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function isLocked() : bool
|
||||
public function isLocked() : bool
|
||||
{
|
||||
return self::$isLocked;
|
||||
return $this->isLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ final class Header extends HeaderAbstract
|
|||
*/
|
||||
public function set(string $key, string $header, bool $overwrite = false) : bool
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
if ($this->isLocked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ final class Header extends HeaderAbstract
|
|||
*/
|
||||
public function remove($key) : bool
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
if ($this->isLocked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ final class Header extends HeaderAbstract
|
|||
*/
|
||||
public function push() : void
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
if ($this->isLocked) {
|
||||
throw new \Exception('Already locked');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use phpOMS\Localization\Localization;
|
|||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Views\View;
|
||||
use phpOMS\Log\FileLogger;
|
||||
|
||||
/**
|
||||
* Response class.
|
||||
|
|
@ -184,8 +185,15 @@ final class Response extends ResponseAbstract implements RenderableInterface
|
|||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// todo: handle exception
|
||||
// need to to try catch for logging. otherwise the json_encode in the logger will have a problem with this
|
||||
FileLogger::getInstance('', false)
|
||||
->error(
|
||||
FileLogger::MSG_FULL, [
|
||||
'message' => $e->getMessage(),
|
||||
'line' => __LINE__,
|
||||
'file' => Response::class,
|
||||
]
|
||||
);
|
||||
|
||||
$result = [];
|
||||
} finally {
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class MultiMap implements \Countable
|
|||
}
|
||||
|
||||
// todo: is this really required???? - i don't think so!
|
||||
$this->garbageCollect();
|
||||
//$this->garbageCollect();
|
||||
|
||||
return $inserted;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ final class StringCompare
|
|||
}
|
||||
|
||||
foreach ($words1 as $word1) {
|
||||
// todo: is this correct?
|
||||
$best = \strlen($s2);
|
||||
|
||||
foreach ($words2 as $word2) {
|
||||
|
|
@ -122,8 +121,7 @@ final class StringCompare
|
|||
}
|
||||
}
|
||||
|
||||
// todo: is this correct?
|
||||
$total += $total + $best;
|
||||
$total += $best;
|
||||
}
|
||||
|
||||
return $total;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class HttpSessionTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$session = new HttpSession();
|
||||
self::assertEquals(null, $session->get('key'));
|
||||
self::assertFalse(HttpSession::isLocked());
|
||||
self::assertFalse($session->isLocked());
|
||||
}
|
||||
|
||||
public function testGetSet()
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ class HeaderTest extends \PHPUnit\Framework\TestCase
|
|||
public function testLockedHeaderSet()
|
||||
{
|
||||
$header = new Header();
|
||||
Header::lock();
|
||||
self::assertTrue(Header::isLocked());
|
||||
$header->lock();
|
||||
self::assertTrue($header->isLocked());
|
||||
self::assertFalse($header->set('key', 'value'));
|
||||
|
||||
TestUtils::setMember('phpOMS\Message\Http\Header', 'isLocked', false);
|
||||
|
|
@ -80,8 +80,8 @@ class HeaderTest extends \PHPUnit\Framework\TestCase
|
|||
public function testLockedHeaderRemove()
|
||||
{
|
||||
$header = new Header();
|
||||
Header::lock();
|
||||
self::assertTrue(Header::isLocked());
|
||||
$header->lock();
|
||||
self::assertTrue($header->isLocked());
|
||||
self::assertFalse($header->remove('key'));
|
||||
|
||||
TestUtils::setMember('phpOMS\Message\Http\Header', 'isLocked', false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user