Incorrect logic for corn on the config page

Created on 4 December 2023, 12 months ago
Updated 2 May 2024, 7 months ago

Problem/Motivation

The code to set the default value of corn on the config page

<?php
'#default_value' => $definition['refresh_once'] ?? $this->configuration['cron']
?>

Looks to be incorrect as it is using the Null Coalescing Ternary operator.
So the only time the default value will be set to configuration['cron'] is when $definition['refresh_once'] is set to NULL

It is possible I do not understand the usage of the refresh_once and its existence if that is the case please explain.

🐛 Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom guy_schneerson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @guy_schneerson
  • Status changed to Needs review 12 months ago
  • 🇬🇧United Kingdom guy_schneerson

    A patch updating the logic if refresh_once is true set to 1 otherwise use the corn configuration.

  • 🇭🇷Croatia valic Osijek

    The logic is correct. The refresh_once is used for specific services that only publish once a day new exchange rates.

    So you can at the plugin level specify (force) that it's only running once a day.

    An example is ECB plugin \Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider\EuropeanCentralBankExchanger

    which in definition have set this property to TRUE

    
    /**
     * Provides EuropeanCentralBank.
     *
     * @CommerceExchangerProvider(
     *   id = "ecb",
     *   label = "European Central Bank",
     *   display_label = "European Central Bank",
     *   base_currency = "EUR",
     *   refresh_once = TRUE,
     * )
     */
    

    So for ECB, you can't run import more than once a day.

    By default this value is FALSE - which means if the plugin does not specify it, you are allowed to set on the configuration page how often cron runs are needed

  • Status changed to Closed: works as designed 7 months ago
  • 🇭🇷Croatia valic Osijek
Production build 0.71.5 2024