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 cached version #11

Closed psntr closed 2 years ago

psntr commented 2 years ago

Hi there,

Been enjoying a lot of your productions. I was wondering if there is a way to do the same with BoostID when it comes to re-index the ID or force that specific page cache to be purged?

I tried to execute this: $cachedYesOrNoAsBoolean = $page->boost(); In the page frontend but it's still keep the cache and doesn't re-index the missing ID on the translated pages.

Indeed, sometimes I face a strange issue where translated pages don't get an ID… Still need to figure out what steps lead to that issue. But often case, it would nice to have a button in the panel to do that, mainly for the translated page I guess, because that's where that issue occurs.

bnomei commented 2 years ago

glad you like my plugins.

the boost id MUST be a non translated field. so there should be no value for the boostid in the translated content files but only in the one of the default language.

a job to reindex boost would need to call this.

kirby()->impersonate('kirby');
$success = site()->boost() > 0;
psntr commented 2 years ago

Yes. This is what I have in the blueprint.

boostid:
        type: boostid
        translate: false

I'm still not sure why the translated page didn't show the ID although the original version have it. So to fix it, I first tried to delete the .txt files. of course this didn't help since the cached version was still shown when I change language in the Panel. So I put it back and used the plugin from flokosiol to copy the original data into the translated page, it then copied the ID and with the ID now in the translated pages the pages where this was "related" worked. Now I manually erase the boostID from the translated .txt.

It's truly pain when this happen, will try to keep you updated on how to reproduce the problem. Meanwhile, I will also try to use your code with a custom Job with janitor.

psntr commented 2 years ago

It's strange now that the translate: false set for the boostID. The page where the boostID page is linked returns the ID not the title of post anymore.

Screenshot 2022-06-03 at 00 19 43

The page where I use the relation has the following blueprint:

type: multiselect
options: query
search:
  min: 3
  display: 4
query:
  fetch: kirby.collection('boostidevents')
  text: "{{ page.title }}"
  value: "{{ page.BOOSTID }}"
psntr commented 2 years ago

This seems to be an issue with the cached version, because by activating the debug: true in config.php, the boostID is back to normal… I really don't get it. Now I created the button to re-index boostID while keeping the debug move alive. After it did the jobs, I switch back to debug: false.

By switch the debug mode, does it clear the cache or simply not use it? I think what I'm after is a way (maybe with Janitor) to clear the current cache. Is there any method to do that?

psntr commented 2 years ago

Steps to reproduce the issue:

  1. Disable debug mode in config.php
  2. Create a page with a boostID
  3. Translate the page (main difference between debug true/false, the boostID is not shown anymore)
  4. Stay in second language
  5. Try to create a new relation with the newly created page (using multiselect with option: query, full query in post above)
  6. The newly created page do not return any ID hence, the relationship breaks in other languages than original one.

In summary: When debug is set to false, translated relationship breaks in the panel therefore you can not use relationship other than with the default language?

Temporary fix: Would then have to force the option:query to save the default language ID instead of the translated one:

type: multiselect
options: query
search:
  min: 3
  display: 4
query:
  fetch: kirby.collection('boostidevents')
  text: "{{ page.title }}"
  value: "{{ page.content('fr').BOOSTID }}"
bnomei commented 2 years ago

i will take a look at that asap

francois-gm commented 2 years ago

Hello,

I've been experimenting a weird behaviour likely related to this and #6

Basically, fields with the translate: false option stop displaying values in the translated page. This is an issue in the website as well as in the panel, where the fields with the translate: false options appear empty. Since these fields are also required, this basically blocks editors from saving pages in the translated versions...

When I set to debug: false;, the problem dissappear. Also, when I set 'bnomei.boost.cache' => false, the problem also stops. So I guess it must be from the cache?

Of course, not using the translate: false option could solve the issue, as well as making a page model that would overwrite the field values that should not be translated (since they would then be hard-coded within the content files). So far I set off the boost cache, but I'm unsure this should be the best long-term solution as I do see very pleasant performance gains by using the (sqlite) cache!

I've seen a wontfix tag on #6 and was curious about the issue, is there a lot of complexity into making this work with translate: false? I guess it's another layer of complexity on top?

bnomei commented 2 years ago

thanks @psntr for your detailed description. as @francois-gm pointed out this might be an issue with how kirby resolved non translatable fields and thus affects not only the boostid field (which was removed in plugin v2) but more general to all non translatable content. i will continue this in #16.

thanks for you patience on this one as i am currently quiet busy and only have limited time to spend on my plugins. 🙇