Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/CarbonIntensity.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ public function save(string $zone_name, string $source_name, array $data): int
);
$stmt = $DB->prepare($query);

$in_transaction = $DB->inTransaction() || $DB->beginTransaction();

foreach ($data as $intensity) {
try {
$stmt->bind_param(
Expand All @@ -387,9 +385,6 @@ public function save(string $zone_name, string $source_name, array $data): int
continue;
}
}
if ($in_transaction) {
$DB->commit();
}
$stmt->close();

return $count;
Expand Down
15 changes: 11 additions & 4 deletions templates/components/form/fields_macros.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@

{% macro timeField(name, value, label = '', options = {}) %}
{% import 'components/form/fields_macros.html.twig' as fields %}
{% set options = {'rand': random()}|merge(options) %}
{% set options = {
'rand': random(),
'disabled': false
}|merge(options)
%}

{% if options.disabled %}
{% set options = options|merge({specific_tags: {'disabled': 'disabled'}}) %}
{% endif %}
{% if options.fields_template.isMandatoryField(name) %}
{% if options.fields_template.isMandatoryField(name)|default(false) %}
{% set options = {'specific_tags': {'required': true}}|merge(options) %}
{% endif %}

Expand All @@ -63,12 +67,15 @@
{# Multiple values will be set, input need to be an array #}
{% set name = "#{name}[]" %}
{% endif %}
{% set options = {'rand': random()}|merge(options) %}
{% set options = {
'rand': random(),
'disabled': false}|merge(options)
%}
{% if options.fields_template.isMandatoryField(name)|default(false) %}
{% set options = {'specific_tags': {'required': true}}|merge(options) %}
{% endif %}

{% if options.disabled|default(false) %}
{% if options.disabled %}
{% set options = options|merge({specific_tags: {'disabled': 'disabled'}}) %}
{% endif %}

Expand Down
10 changes: 8 additions & 2 deletions tests/src/CommonTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ protected function login($name, $password, $noauto = false)
return $result;
}

protected function logout()
{
Session::destroy();
Session::start();
}

/**
* Get a unique random string
*/
Expand All @@ -169,11 +175,11 @@ protected function getItem(string $itemtype, array $input = []): CommonDBTM
{
global $DB;

$this->handleDeprecations($itemtype, $input);

/** @var CommonDBTM */
$item = new $itemtype();

$this->handleDeprecations($itemtype, $input);

// set random name if not already set
if (!isset($item->fields['name']) && $DB->fieldExists($item->getTable(), 'name')) {
if (!isset($input['name'])) {
Expand Down
2 changes: 1 addition & 1 deletion tests/units/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testGetTabNameForItem()
$profile = new Profile();
$item = new GlpiProfile();
$tabName = $profile->getTabNameForItem($item);
$this->assertEquals(__('Environmental impact', 'carbon'), $tabName);
$this->assertStringContainsString(__('Environmental impact', 'carbon'), $tabName);
}

/**
Expand Down