Release of v5.0.1-alpha4

Change the extendsinterfaces field to allow null, #1139. Update the Schema class to also update null mismatching if needed.
This commit is contained in:
Robot 2024-06-07 23:21:05 +02:00
parent 0c9a098335
commit fc6b04cb5c
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
11 changed files with 157 additions and 37 deletions

View File

@ -1,12 +1,14 @@
# v5.0.1-alpha3
# v5.0.1-alpha4
- Add in JCB gitea push feature to help maintain JCB core features.
- Add extending options to interfaces.
- Change the extendsinterfaces field to allow null, #1139
- Update the Schema class to also update null mismatching if needed
# v5.0.1-alpha
- Fix auto build from SQL in Joomla 5.
- Fix permission issue for admin views.
- Add in JCB gitea push feature to help maintain JCB core features.
- Add extending options to interfaces.
# v5.0.0

View File

@ -3210,7 +3210,7 @@ class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 5.0.1-alpha3 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 5.0.1-alpha4 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Add/Update component in the action logs extensions table.
$this->setActionLogsExtensions();

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha4) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 5th June, 2024
+ *Version*: 5.0.1-alpha3
+ *Last Build*: 7th June, 2024
+ *Version*: 5.0.1-alpha4
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **750039**
+ *Line count*: **750452**
+ *Field count*: **2106**
+ *File count*: **5314**
+ *File count*: **5319**
+ *Folder count*: **540**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.1-alpha4) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 5th June, 2024
+ *Version*: 5.0.1-alpha3
+ *Last Build*: 7th June, 2024
+ *Version*: 5.0.1-alpha4
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **750039**
+ *Line count*: **750452**
+ *Field count*: **2106**
+ *File count*: **5314**
+ *File count*: **5319**
+ *Folder count*: **540**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -367,9 +367,9 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_power` (
`approved_paths` TEXT NULL,
`composer` TEXT NULL,
`description` TEXT NULL,
`extends` VARCHAR(36) NOT NULL DEFAULT '',
`extends` VARCHAR(36) NULL DEFAULT '',
`extends_custom` VARCHAR(64) NULL DEFAULT '',
`extendsinterfaces` TEXT NOT NULL,
`extendsinterfaces` TEXT NULL,
`extendsinterfaces_custom` TEXT NULL,
`guid` VARCHAR(36) NOT NULL DEFAULT '',
`head` TEXT NULL,

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="5.0" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>5th June, 2024</creationDate>
<creationDate>7th June, 2024</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>5.0.1-alpha3</version>
<version>5.0.1-alpha4</version>
<description><![CDATA[
<h1>Component Builder (v.5.0.1-alpha3)</h1>
<h1>Component Builder (v.5.0.1-alpha4)</h1>
<div style="clear: both;"></div>
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.

View File

@ -62,7 +62,7 @@
<version>5.0.1-alpha</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha3.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha4.zip</downloadurl>
</downloads>
<tags>
<tag>alpha</tag>
@ -77,10 +77,10 @@
<element>pkg_component_builder</element>
<type>package</type>
<client>site</client>
<version>5.0.1-alpha3</version>
<version>5.0.1-alpha4</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha3.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.1-alpha4.zip</downloadurl>
</downloads>
<tags>
<tag>alpha</tag>

View File

@ -343,9 +343,17 @@ abstract class Schema implements SchemaInterface
'expected' => $expected['type']
];
}
// check if update of default values is needed
if ($this->checkDefault($table, $column) && !isset($requireUpdate[$column]))
elseif ($this->checkDefault($table, $column))
{
$requireUpdate[$column] = [
'column' => $column,
'current' => $current->Type,
'expected' => $expected['type']
];
}
// check if update of null is needed
elseif ($this->checkNull($table, $column))
{
$requireUpdate[$column] = [
'column' => $column,
@ -391,13 +399,21 @@ abstract class Schema implements SchemaInterface
$default = $this->getDefaultValue($type, $db_default);
// Prepare the null switch, and auto increment statement
$null_switch = !empty($db['null_switch']) ? " " . $db['null_switch'] : '';
$null_switch = !empty($db['null_switch']) ? ' ' . $db['null_switch'] : '';
// Prepare the auto increment statement
$auto_increment = !empty($db['auto_increment']) ? " AUTO_INCREMENT" : '';
// If there's a default value, the column should not be nullable
if ($default !== '')
{
$null_switch = '';
}
$this->setKeys($db);
// Assemble the SQL snippet for the column definition
return "{$column_name} {$type}{$null_switch}{$default}{$auto_increment}";
return "{$column_name} {$type}{$null_switch}{$auto_increment}{$default}";
} catch (\Exception $e) {
throw new \Exception("Error: failed to generate column definition for ($table.$field). " . $e->getMessage());
}
@ -448,6 +464,61 @@ abstract class Schema implements SchemaInterface
return false;
}
/**
* Check and Update the null value if needed, including existing data adjustments
*
* @param string $table The table to update.
* @param string $column The column/field to check.
*
* @return bool
* @since 3.2.2
*/
protected function checkNull(string $table, string $column): bool
{
// Retrieve the expected column configuration
$expected = $this->table->get($table, $column, 'db');
// Skip updates if the null_switch is not set
if (!isset($expected['null_switch']))
{
return false;
}
// Retrieve the current column configuration
$current = $this->columns[$column];
// Skip updates if the Null is not set
if (!isset($current->Null))
{
return false;
}
// set the expected NULL
$expected_null = 'NO';
if ($expected['null_switch'] === "NULL")
{
$expected_null = 'YES';
}
// set the current NULL
$current_null = $current->Null;
// Prepare the type and default value SQL statement
$type = $expected['type'] ?? 'TEXT';
$db_default = isset($expected['default']) ? $expected['default'] : null;
$default = $this->getDefaultValue($type, $db_default, true);
// check the null values if they match
if ($current_null !== $expected_null && $current_null === 'NO' && empty($default))
{
$this->success[] = "Success: updated the ($column) null state in $table table.";
return true;
}
return false;
}
/**
* Update the data type of the given fields.
*
@ -679,8 +750,8 @@ abstract class Schema implements SchemaInterface
* Adjusts the default value SQL fragment for a database field based on its type and specific rules.
*
* If the field is of type DATETIME and the Joomla version is not 3, it sets the default to CURRENT_TIMESTAMP
* if not explicitly specified otherwise. For all other types, or when a 'EMPTY' default is specified, it handles
* defaults by either leaving them unset or applying the provided default, properly quoted for SQL safety.
* if not explicitly specified otherwise. For all other types it handles defaults by either leaving them unset or applying
* the provided default, properly quoted for SQL safety. When a 'EMPTY' default is specified, it returns no default at all. (:)
*
* @param string $type The type of the database field (e.g., 'DATETIME').
* @param string|null $defaultValue Optional default value for the field, null if not provided.
@ -691,7 +762,7 @@ abstract class Schema implements SchemaInterface
*/
protected function getDefaultValue(string $type, ?string $defaultValue, bool $pure = false): string
{
if ($defaultValue === null)
if ($defaultValue === null || strtoupper($defaultValue) === 'EMPTY')
{
return '';
}
@ -722,11 +793,7 @@ abstract class Schema implements SchemaInterface
return 'NULL';
}
if (is_string($value) && strtoupper($value) === 'EMPTY')
{
return "''";
}
elseif (is_numeric($value))
if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Languages Builder Class
*
* @since 3.2.2
*/
final class Languages extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.2
*/
use IsArray;
}

View File

@ -14,6 +14,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData;
@ -86,6 +87,9 @@ class BuilderLZ implements ServiceProviderInterface
*/
public function register(Container $container)
{
$container->alias(Languages::class, 'Compiler.Builder.Languages')
->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true);
$container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages')
->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true);
@ -246,6 +250,19 @@ class BuilderLZ implements ServiceProviderInterface
->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true);
}
/**
* Get The Languages Class.
*
* @param Container $container The DI container.
*
* @return Languages
* @since 3.2.0
*/
public function getLanguages(Container $container): Languages
{
return new Languages();
}
/**
* Get The LanguageMessages Class.
*

View File

@ -3262,7 +3262,7 @@ class Table extends BaseTable implements Tableinterface
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
'null_switch' => 'NOT NULL',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
@ -3342,7 +3342,7 @@ class Table extends BaseTable implements Tableinterface
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
'null_switch' => 'NOT NULL',
'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],