Various updates as follows
* commit 5cec54d508fd4a34de509b3ac28d6277b6abc090 (HEAD -> master, all/master, all/development, all/NewFeatures) | log size 644 | Author: Clemens Schwaighofer <clemens.schwaighofer@egplusww.com> | Date: 2024-09-20 13:33:19 +0900 | | Add "Success" to message logging levels, fixes for PHP 8.4, other preg_match fixes | | The Logger/MessageLevel gets "success" as level 110 to something a bit | heigher than "ok" which is the general "OK" for anything ending without | an error. The "success" is currently only used in file uploads with the | java script ajax file uploader | | Fix any "type $var = null" with correctly "?type $var = null" for PHP 8.4 (phphan) | | Fix preg match no return catches for DB IO compare version and for language | look up. | | 4dev/tests/Logging/CoreLibsLoggingErrorMessagesTest.php | 5 +++++ | www/admin/class_test.html.php | 1 + | www/admin/class_test.php | 2 +- | www/admin/layout/javascript/edit.jq.js | 2 +- | www/lib/CoreLibs/Admin/Backend.php | 6 +++--- | www/lib/CoreLibs/Basic.php | 2 +- | www/lib/CoreLibs/Convert/Extends/SetVarTypeMain.php | 6 +++--- | www/lib/CoreLibs/Convert/SetVarTypeNull.php | 6 +++--- | www/lib/CoreLibs/DB/IO.php | 24 ++++++++++++++++++------ | www/lib/CoreLibs/Language/GetLocale.php | 4 ++-- | www/lib/CoreLibs/Logging/Logger/MessageLevel.php | 2 ++ | www/lib/CoreLibs/Output/Form/Elements.php | 12 ++++++------ | www/lib/CoreLibs/Template/HtmlBuilder/Element.php | 4 ++-- | 13 files changed, 48 insertions(+), 28 deletions(-) | * commit 8e60c992f109993b40d9e5ec9354ffb7d7db9f79 | log size 123 | Author: Clemens Schwaighofer <clemens.schwaighofer@egplusww.com> | Date: 2024-09-03 12:06:01 +0900 | | Fixes phan/phpstan | | phpstan.neon | 6 +++--- | www/lib/CoreLibs/Get/System.php | 2 +- | www/lib/CoreLibs/Template/HtmlBuilder/Block.php | 4 ---- | 3 files changed, 4 insertions(+), 8 deletions(-) | * commit 1b5437b675f6ceda4318f19522d47a08f28f95a8 | log size 147 | Author: Clemens Schwaighofer <clemens.schwaighofer@egplusww.com> | Date: 2024-09-03 11:58:36 +0900 | | Add testing for new added bom utf8 replace | | 4dev/tests/Convert/CoreLibsConvertStringsTest.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ | 4dev/tests/Convert/data/UTF8.csv | 1 + | 4dev/tests/Convert/data/UTF8BOM.csv | 1 + | 4dev/tests/Get/CoreLibsGetSystemTest.php | 23 +++++++++++++++++++++++ | www/admin/class_test.system.php | 4 +++- | 5 files changed, 76 insertions(+), 1 deletion(-) | * commit ef80cba5610b8acae8fc11d3f0a441c1f5a03735 | log size 659 | Author: Clemens Schwaighofer <clemens.schwaighofer@egplusww.com> | Date: 2024-09-03 09:49:01 +0900 | | Add new functions: get IPs, strip UTF8 BOM from text, text updates | | Add the following new static methods | | Convert\Strings::stripUTF8BomBytes: removes the UTF8 BOM bytes from the beginning of a line | Used for CSV files created in Excel for the first header entry (line 0/row 0) | | Get\Systen::getIpAddresses: gets all IP addresses for the the current access user | and returns an array | | Moved the frontend folder detection from the first load config to the config.path.php | | Cleaned up the translations JS scripts | | 4dev/bin/create_mo.sh | 9 +++++---- | 4dev/bin/mo_to_js.sh | 63 +++++++++++++++++++++++++++++++++++---------------------------- | www/configs/config.path.php | 16 +++++++++++++++- | www/configs/config.php | 15 +-------------- | www/lib/CoreLibs/Convert/Strings.php | 12 ++++++++++++ | www/lib/CoreLibs/DB/IO.php | 2 +- | www/lib/CoreLibs/Get/System.php | 23 +++++++++++++++++++++++ | www/lib/CoreLibs/Template/HtmlBuilder/Block.php | 37 ++++++++++++++++++++++++++----------- | 8 files changed, 118 insertions(+), 59 deletions(-) | * commit 2d71e760e8fb7b4b0a5552a2f62bedffad928f4f | log size 120 | Author: Clemens Schwaighofer <clemens.schwaighofer@egplusww.com> | Date: 2024-08-21 11:45:17 +0900 | | Composer update | | www/composer.lock | 12 ++++++------ | www/lib/CoreLibs/Template/SmartyExtend.php | 3 ++- | www/vendor/composer/installed.json | 14 +++++++------- | www/vendor/composer/installed.php | 6 +++--- | www/vendor/gullevek/dotenv/Readme.md | 23 +++++++++++++++++++++++ | www/vendor/gullevek/dotenv/src/DotEnv.php | 13 ++++++++++--- | 6 files changed, 51 insertions(+), 20 deletions(-) | * commit a8d07634ffaf961a37557437aac1f202ae18fa6e | log size 182 | Author: Clemens Schwaighofer <clemens.schwaighofer@egplusww.com> | Date: 2024-08-07 13:41:09 +0900 | | Add soba.egplusww.jp as local development host, jshint esversion update to 11 | | www/admin/layout/javascript/edit.jq.js | 2 +- | www/configs/config.host.php | 28 +++++++++++----------------- | 2 files changed, 12 insertions(+), 18 deletions(-) |
This commit is contained in:
@@ -504,9 +504,9 @@ class Backend
|
||||
string $data,
|
||||
string $key_name,
|
||||
string $key_value,
|
||||
string $associate = null,
|
||||
string $file = null,
|
||||
string $db_schema = null,
|
||||
?string $associate = null,
|
||||
?string $file = null,
|
||||
?string $db_schema = null,
|
||||
): void {
|
||||
/** @var string $DB_SCHEMA check schema */
|
||||
$DB_SCHEMA = 'public';
|
||||
|
||||
@@ -90,7 +90,7 @@ class Basic
|
||||
* @deprecated DO NOT USE Class\Basic anymore. Use dedicated logger and sub classes
|
||||
*/
|
||||
public function __construct(
|
||||
\CoreLibs\Logging\Logging $log = null,
|
||||
?\CoreLibs\Logging\Logging $log = null,
|
||||
?string $session_name = null
|
||||
) {
|
||||
trigger_error('Class \CoreLibs\Basic is deprected', E_USER_DEPRECATED);
|
||||
|
||||
@@ -52,7 +52,7 @@ class SetVarTypeMain
|
||||
*/
|
||||
protected static function makeStrMain(
|
||||
mixed $val,
|
||||
string $default = null,
|
||||
?string $default = null,
|
||||
bool $to_null = false
|
||||
): ?string {
|
||||
// int/float/string/bool/null, everything else is ignored
|
||||
@@ -113,7 +113,7 @@ class SetVarTypeMain
|
||||
*/
|
||||
protected static function makeIntMain(
|
||||
mixed $val,
|
||||
int $default = null,
|
||||
?int $default = null,
|
||||
bool $to_null = false
|
||||
): ?int {
|
||||
// if we can filter it to a valid int, we can convert it
|
||||
@@ -167,7 +167,7 @@ class SetVarTypeMain
|
||||
*/
|
||||
protected static function makeFloatMain(
|
||||
mixed $val,
|
||||
float $default = null,
|
||||
?float $default = null,
|
||||
bool $to_null = false
|
||||
): ?float {
|
||||
if (
|
||||
|
||||
@@ -35,7 +35,7 @@ class SetVarTypeNull extends Extends\SetVarTypeMain
|
||||
* @param string|null $default Default override value
|
||||
* @return string|null Input value as string or default as string/null
|
||||
*/
|
||||
public static function makeStr(mixed $val, string $default = null): ?string
|
||||
public static function makeStr(mixed $val, ?string $default = null): ?string
|
||||
{
|
||||
return SetVarTypeMain::makeStrMain($val, $default, true);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class SetVarTypeNull extends Extends\SetVarTypeMain
|
||||
* @param int|null $default Default override value
|
||||
* @return int|null Input value as int or default as int/null
|
||||
*/
|
||||
public static function makeInt(mixed $val, int $default = null): ?int
|
||||
public static function makeInt(mixed $val, ?int $default = null): ?int
|
||||
{
|
||||
return SetVarTypeMain::makeIntMain($val, $default, true);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class SetVarTypeNull extends Extends\SetVarTypeMain
|
||||
* @param float|null $default Default override value
|
||||
* @return float|null Input value as float or default as float/null
|
||||
*/
|
||||
public static function makeFloat(mixed $val, float $default = null): ?float
|
||||
public static function makeFloat(mixed $val, ?float $default = null): ?float
|
||||
{
|
||||
return SetVarTypeMain::makeFloatMain($val, $default, true);
|
||||
}
|
||||
|
||||
@@ -1896,7 +1896,12 @@ class IO
|
||||
$matches = [];
|
||||
// compare has =, >, < prefix, and gets stripped
|
||||
// if the rest is not X.Y format then error
|
||||
preg_match("/^([<>=]{1,})(\d{1,})\.(\d{1,})/", $compare, $matches);
|
||||
if (!preg_match("/^([<>=]{1,})(\d{1,})\.(\d{1,})/", $compare, $matches)) {
|
||||
$this->log->error('Could not regex match compare version string', [
|
||||
"compare" => $compare
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
$compare = $matches[1];
|
||||
$to_master = $matches[2];
|
||||
$to_minor = $matches[3];
|
||||
@@ -1908,11 +1913,18 @@ class IO
|
||||
}
|
||||
// db_version can return X.Y.Z
|
||||
// we only compare the first two
|
||||
preg_match(
|
||||
"/^(\d{1,})\.(\d{1,})\.?(\d{1,})?/",
|
||||
$this->dbVersion(),
|
||||
$matches
|
||||
);
|
||||
if (
|
||||
!preg_match(
|
||||
"/^(\d{1,})\.(\d{1,})\.?(\d{1,})?/",
|
||||
$this->dbVersion(),
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
$this->log->error('Could not regex match dbVersion string', [
|
||||
"dbVersion" => $this->dbVersion()
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
$master = $matches[1];
|
||||
$minor = $matches[2];
|
||||
$version = $master . ($minor < 10 ? '0' : '') . $minor;
|
||||
|
||||
@@ -128,7 +128,7 @@ class GetLocale
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
$lang = ($matches['lang'] ?? 'en')
|
||||
$lang = $matches['lang']
|
||||
// add country only if set
|
||||
. (!empty($matches['country']) ? '_' . $matches['country'] : '');
|
||||
} else {
|
||||
@@ -235,7 +235,7 @@ class GetLocale
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
$lang = ($matches['lang'] ?? 'en')
|
||||
$lang = $matches['lang']
|
||||
// add country only if set
|
||||
. (!empty($matches['country']) ? '_' . $matches['country'] : '');
|
||||
} else {
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace CoreLibs\Logging\Logger;
|
||||
enum MessageLevel: int
|
||||
{
|
||||
case ok = 100;
|
||||
case success = 110; // special for file uploads
|
||||
case info = 200;
|
||||
case notice = 250;
|
||||
case warn = 300;
|
||||
@@ -30,6 +31,7 @@ enum MessageLevel: int
|
||||
{
|
||||
return match (strtolower($name)) {
|
||||
'ok' => self::ok,
|
||||
'success' => self::success,
|
||||
'info' => self::info,
|
||||
'notice' => self::notice,
|
||||
'warn', 'warning' => self::warn,
|
||||
|
||||
@@ -194,13 +194,13 @@ class Elements
|
||||
"/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/",
|
||||
function ($matches) {
|
||||
return self::createEmail(
|
||||
$matches[1] ?? '',
|
||||
$matches[2] ?? '',
|
||||
$matches[3] ?? '',
|
||||
$matches[4] ?? '',
|
||||
$matches[5] ?? '',
|
||||
$matches[1],
|
||||
$matches[2],
|
||||
$matches[3],
|
||||
$matches[4],
|
||||
$matches[5],
|
||||
$matches[7] ?? '',
|
||||
$matches[9] ?? ''
|
||||
$matches[9] ?? '',
|
||||
);
|
||||
},
|
||||
$output
|
||||
|
||||
@@ -401,7 +401,7 @@ class Element
|
||||
* @param bool $add_nl [default=false] Optional output string line breaks
|
||||
* @return string HTML as string
|
||||
*/
|
||||
public function buildHtml(Element $tree = null, bool $add_nl = false): string
|
||||
public function buildHtml(?Element $tree = null, bool $add_nl = false): string
|
||||
{
|
||||
// print "D01: " . microtime(true) . "<br>";
|
||||
if ($tree === null) {
|
||||
@@ -533,7 +533,7 @@ class Element
|
||||
* @return string build html as string
|
||||
* @deprecated Do not use, use Element->buildHtml() instead
|
||||
*/
|
||||
public static function printHtmlFromObject(Element $tree = null, bool $add_nl = false): string
|
||||
public static function printHtmlFromObject(?Element $tree = null, bool $add_nl = false): string
|
||||
{
|
||||
// nothing ->bad
|
||||
if ($tree === null) {
|
||||
|
||||
@@ -39,6 +39,11 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
||||
'str' => 'OK',
|
||||
'expected' => 'ok',
|
||||
],
|
||||
'success' => [
|
||||
'level' => 'success',
|
||||
'str' => 'SUCCESS',
|
||||
'expected' => 'success',
|
||||
],
|
||||
'info' => [
|
||||
'level' => 'info',
|
||||
'str' => 'INFO',
|
||||
|
||||
Reference in New Issue
Block a user