This commit is contained in:
Roman 2023-01-09 15:59:53 +01:00
parent 6dcd7031bb
commit cee54a1946
7 changed files with 37 additions and 12 deletions

@ -14,7 +14,7 @@ namespace Core\API {
public function __construct(Context $context, bool $externalCall, array $params) { public function __construct(Context $context, bool $externalCall, array $params) {
parent::__construct($context, $externalCall, $params); parent::__construct($context, $externalCall, $params);
$this->routerCachePath = getClassPath(self::ROUTER_CACHE_CLASS); $this->routerCachePath = WEBROOT . DIRECTORY_SEPARATOR . getClassPath(self::ROUTER_CACHE_CLASS);
} }
protected function toggleRoute(int $id, bool $active): bool { protected function toggleRoute(int $id, bool $active): bool {

@ -419,9 +419,11 @@ class MySQL extends SQL {
$returns = $procedure->getReturns(); $returns = $procedure->getReturns();
$paramDefs = []; $paramDefs = [];
foreach ($procedure->getParameters() as $param) { foreach ($procedure->getParameters() as $parameter) {
if ($param instanceof Column) { if ($parameter instanceof Column) {
$paramDefs[] = $this->getParameterDefinition($param); $paramDefs[] = $this->getParameterDefinition($parameter);
} else if ($parameter instanceof CurrentTable) {
$paramDefs[] = $this->getParameterDefinition($parameter->toColumn());
} else { } else {
$this->lastError = $this->logger->error("PROCEDURE parameter type " . gettype($returns) . " is not implemented yet"); $this->lastError = $this->logger->error("PROCEDURE parameter type " . gettype($returns) . " is not implemented yet");
return null; return null;

@ -4,6 +4,7 @@
namespace Core\Driver\SQL\Query; namespace Core\Driver\SQL\Query;
use Core\Driver\SQL\Column\Column; use Core\Driver\SQL\Column\Column;
use Core\Driver\SQL\Expression\Expression;
use Core\Driver\SQL\SQL; use Core\Driver\SQL\SQL;
class CreateProcedure extends Query { class CreateProcedure extends Query {
@ -21,7 +22,7 @@ class CreateProcedure extends Query {
$this->returns = NULL; $this->returns = NULL;
} }
public function param(Column $parameter): CreateProcedure { public function param(Expression $parameter): CreateProcedure {
$this->parameters[] = $parameter; $this->parameters[] = $parameter;
return $this; return $this;
} }

@ -2,10 +2,13 @@
namespace Core\Driver\SQL\Type; namespace Core\Driver\SQL\Type;
use Core\Driver\SQL\Column\Column;
use Core\Driver\SQL\Column\StringColumn;
use Core\Driver\SQL\Expression\Expression; use Core\Driver\SQL\Expression\Expression;
use Core\Driver\SQL\MySQL; use Core\Driver\SQL\MySQL;
use Core\Driver\SQL\PostgreSQL; use Core\Driver\SQL\PostgreSQL;
use Core\Driver\SQL\SQL; use Core\Driver\SQL\SQL;
use Exception;
class CurrentTable extends Expression { class CurrentTable extends Expression {
@ -14,11 +17,15 @@ class CurrentTable extends Expression {
function getExpression(SQL $sql, array &$params): string { function getExpression(SQL $sql, array &$params): string {
if ($sql instanceof MySQL) { if ($sql instanceof MySQL) {
// CURRENT_TABLE return $sql->columnName("CURRENT_TABLE");
} else if ($sql instanceof PostgreSQL) { } else if ($sql instanceof PostgreSQL) {
return "TG_TABLE_NAME"; return "TG_TABLE_NAME";
} else { } else {
throw new Exception("CurrentTable Not implemented for driver type: " . get_class($sql));
} }
} }
public function toColumn(): Column {
return new StringColumn("CURRENT_TABLE");
}
} }

@ -461,7 +461,7 @@ class DatabaseEntityHandler implements Persistable {
$doInsert = false; $doInsert = false;
foreach ($nmRelation->getProperties($this) as $property) { foreach ($nmRelation->getProperties($this) as $property) {
if ($properties !== null || !in_array($property->getName(), $properties)) { if ($properties !== null && !in_array($property->getName(), $properties)) {
continue; continue;
} }

@ -124,6 +124,14 @@ class RouterCache extends Router {
} }
"; ";
$directory = dirname($file);
if (!is_dir($directory)) {
if (!mkdir($directory, 775, true)) {
$this->logger->severe("Could not create directory: $directory");
return false;
}
}
if (@file_put_contents($file, $code) === false) { if (@file_put_contents($file, $code) === false) {
$this->logger->severe("Could not write Router cache file: $file"); $this->logger->severe("Could not write Router cache file: $file");
return false; return false;

@ -7,11 +7,15 @@ RUN mkdir -p /application/core/Configuration /var/www/.gnupg && \
# YAML + dev dependencies # YAML + dev dependencies
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install -y libyaml-dev libzip-dev libgmp-dev libpng-dev gnupg2d nodejs npm && \ apt-get install -y libyaml-dev libzip-dev libgmp-dev libpng-dev gnupg2 && \
apt-get clean && \
pecl install yaml && docker-php-ext-enable yaml && \ pecl install yaml && docker-php-ext-enable yaml && \
docker-php-ext-install gd && \ docker-php-ext-install gd
npm install --global yarn && ln -s /usr/local/bin/yarn /usr/bin/yarn
# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get update && \
apt-get -y install nodejs && \
npm install --global yarn
# Runkit for unit testing (no stable release available) # Runkit for unit testing (no stable release available)
RUN pecl install runkit7-4.0.0a6 && docker-php-ext-enable runkit7 && \ RUN pecl install runkit7-4.0.0a6 && docker-php-ext-enable runkit7 && \
@ -20,5 +24,8 @@ RUN pecl install runkit7-4.0.0a6 && docker-php-ext-enable runkit7 && \
# mysqli, zip, gmp # mysqli, zip, gmp
RUN docker-php-ext-install mysqli zip gmp RUN docker-php-ext-install mysqli zip gmp
# clean cache
RUN apt-get clean
COPY --from=composer /usr/bin/composer /usr/bin/composer COPY --from=composer /usr/bin/composer /usr/bin/composer
USER www-data USER www-data