bnomei / kirby3-boost

Boost the speed of Kirby by having content files of pages cached and a fast lookup based on uuids
https://sakila-with-boost.bnomei.com/
MIT License
51 stars 0 forks source link

Issue with multi-languages and date #6

Closed psntr closed 2 years ago

psntr commented 2 years ago

Hi,

I'm still exploring the plugin and I think there is an issue with how boostID is handling date in a multi-languages website.

I noticed that when playing with translation. In my case it was from FR to EN (where I have 'date.handler' => 'strftime' enabled in config.php).

This is the config of a clean installation with the minimal requirements to run boostID on my local machine: Kirby: v.3.6.1.1 PHP: 8.0 Debug: off Plugins: bnomei/boost & bnomei/sqlite-cachedriver

config.php:

<?php
return [
  'debug' => false,
  'languages' => true,
  'smartypants' => true,
  'date.handler' => 'strftime',
  'bnomei.boost.cache' => [
    'type'     => 'sqlite'
  ],
];

models/default.php:

<?php
class DefaultPage extends \Kirby\Cms\Page
{
    use \Bnomei\PageHasBoost;
}

blueprints/default.yml:

preset: page
fields:
  text:
    label: Text
    type: textarea
    size: large
  dateStart:
        label:
          fr: Date de début
          en: Start date
          de: Startdatum
        type: date
        width: 1/2
        default: today
        display: DD.MM.YYYY
        translate: false
  dateEnd:
    label:
      fr: Date de fin
      en: End date
      de: Enddatum
    type: date
    width: 1/2
    default: today + 1day
    display: DD.MM.YYYY
    translate: false
  boostid:
    type: boostid

How to reproduce the issue:

  1. Create a post in the default language (my case it was FR) that have a boostID field.
  2. Enter some content
  3. Save
  4. Change language (to EN)
  5. Edit the content
  6. Save
  7. Go back to the default language
  8. Switch back to EN, the date is not showing anymore.

But if you disable the boost function by commenting out the models/default.php, it works. Dates are shown.

Do you know why it doesn't work? Particularly with English, I tried with other languages like German, dates are shown.

bnomei commented 2 years ago

@psntr thanks for your detailed issue. i will try to take a look asap.

boost itself does not alter any fields but there might be some hidden issue related to the caching layer it introduces and the translate: false option.

psntr commented 2 years ago

@bnomei thank you as usual for the prompt reply. You were right, it's an issue with the translate: false option. By commenting out the translate option, it returns the proper value even after changing any other content.