View more context

 

blueskies

Hmmm... this is very odd, because I haven't yet found out what triggers it (so I can't really raise an issue in github about it 😞 ). But it's good to hear I'm not crazy and seeing things 🤪 I've seen it once happen on the live server... suddenly there were some SiteConfig things missing from /admin/settings and when we dug into the db, we saw there were multiple SiteConfigs (and one quite "fresh" one with some blank fields). This happened after we upgraded to 4.4.4 to fix the bug listed in https://github.com/tractorcow-farm/silverstripe-fluent/issues/570. So we assumed it was possibly left over from that nasty bug.

But then yesterday, in my local dev, I was adding some more fields to the Extended SiteConfig, I dev/build, and I filled them in. Then I couldn't decided on the variable names, so I changed them a few times, dev/build a few times, and suddenly there were 3 SiteConfig entries in my local db. So I'm not entirely sure what triggers it or what is happening.... Have you narrowed down when the extra Siteconfig records are created?

Show 1 attachment(s)
baukezwaan

We are experiencing an issue with the handling of deletes in the latest version(s) of Fluent. When the latest record of for instance a Page is deleted, the deteleBaseRecord is being called.
This function deletes the record from several tables, and does this based on ID. This goes wrong for the _Localised table. There the selection should be on RecordID instead.

How to reproduce:

• fresh install of SS4 + Fluent ^4 (tested on 4.4.1 and 4.4.3) • create some Locales • add some pages, and save them in multiple languages (to make the ID higher than the RecordID in the version table) • Now; add a new page via the CMS • Remember the ID (for instance id=16) • Check which record is in SiteTree_Localised on ID=16 • Delete the page via the CMS • See record ID=16 is gone in SiteTree_Localised (instead of RecordID=16)

The snippet below fixes the issue, but probably not in the most elegant way... :face_with_head_bandage:

    protected function deleteBaseRecord(DataObject $record)
    {

        //... (collapsed)

        foreach ($queriedTables as $table) {

            if (strpos(strtolower($table), '_localised') > 0 ) {
                $delete = SQLDelete::create("\"{$table}\"", array('"RecordID"' => $record->ID));
            } else {
                $delete = SQLDelete::create("\"{$table}\"", array('"ID"' => $record->ID));
            }
Hide attachment content
greg_808

yes i am running on Fluent 4.4.4. I wasn’t able to find out when the new siteconfigs are added.

blueskies

An issue was raised about the extra SiteConfig records here: https://github.com/tractorcow-farm/silverstripe-fluent/issues/495 Hopefully we'll get to the bottom of it. Do you have any extra info to post? Or can you confirm you see the issue with a plain custom SiteConfig?

Show 1 attachment(s)
derralf

Hi,
I've got a weird problem with Siteconfig.

SiteConfig has extension CustomSiteConfig
SiteConfig has fluent extension
(see config below)

Somehow:

• multiple SiteConfig-Rows are created in DB • for the multiple SiteConfig-Rows localised are created • the right translations are not found

See Example below.

In the Backend I see the translations (SiteConfig ID 1 gets translated, see below).
But no translation is shown in Frontend or accessible via PHP*. Seems like the CMS thinks the fields are NULL (see below)

* e.g.
$SiteConfig = SiteConfig::current_site_config();
var_dump($SiteConfig->MailTo);

mysite.yml

---
Name: myproject
---
...
SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - App\Extension\CustomSiteConfig

fluentconfig.yml

---
Name: myfluentconfig
After:
  - '#versionedfiles'
  - '#myproject'
---
...
...
SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - 'TractorCow\Fluent\Extension\FluentExtension'
  translate:
    - 'Title'
    - 'Tagline'
    - 'MailSubject'
    - 'MailThankYouMessage'
    - 'ContactMapInfoWindowTitle'
    - 'ContactMapInfoWindowAddress'
...
...

Table SiteConfig

The "NULL-Fields" are not shown in CMS, all fields seem to have been filled out.
The following returns NULL in it_IT and de_DE though "mailto:[email protected]|[email protected]" is shown in Backend in all Languages:

$SiteConfig = SiteConfig::current_site_config();
var_dump($SiteConfig->MailTo);

Table SiteConfig_Localised

Values from ID 2 and 4 are shown in Frontend.
Values from ID 3 and 5 shown in Backend.
So the shown/displayed values can not be edited. And the values that I can edit are not used/shown in Frontend/PHP.

Edit:
If I use class CustomSiteConfig extends FluentExtension
I get this Error:
[Emergency] Uncaught SilverStripe\ORM\Connect\DatabaseException: Couldn't run query: ALTER TABLE "SiteConfig_Localised" DROP INDEX "Fluent_Record", ADD unique "Fluent_Record" ("RecordID","Locale","RecordID","Locale") 42S21-1060: Duplicate column name 'RecordID'

Hide attachment content
blueo

FWIW I've had site config objects created in a test that then hang over into the main DB. Something to do with SiteConfig::create() vs SiteConfig::current_site_config()

Othmane

hello!

one quick question about \TractorCow\Fluent\Middleware\DetectLocaleMiddleware

in the class documentation block it says that the user will be redirected to the correct locale if needed,

  1. /**
  2.  * DetectLocaleMiddleware will detect if a locale has been requested (or is default) and is not the current
  3.  * locale, and will redirect the user to that locale if needed.
  4.  * Will cascade through different checks in order, see "configuration" docs for details.
  5.  * Additionally, detected locales will be set in session and cookies.
  6.  */
  7. class DetectLocaleMiddleware implements HTTPMiddleware

but in the class i can't find any reference to redirects

am i missing something?

Othmane

in the old fluent (3.x) the redirect was being performed in oldfluent/code/routing/FluentRootURLController.php

  1. public function handleRequest(SS_HTTPRequest $request, DataModel $model = null)
  2. {
  3. ...
  4.  
  5. // Check for existing routing parameters, redirecting to another locale automatically if necessary
  6. $locale = Fluent::get_request_locale();
  7. if (empty($locale)) {
  8.  
  9. // Determine if this user should be redirected
  10. $locale = $this->getRedirectLocale();
  11. $this->extend('updateRedirectLocale', $locale);
  12.  
  13. // Check if the user should be redirected
  14. $domainDefault = Fluent::default_locale(true);
  15. if (Fluent::is_locale($locale)) {
  16. $queryParams = $_GET;
  17. unset($queryParams['url']);
  18.  
  19. // Check new traffic with detected locale
  20. $url = Fluent::locale_baseurl($locale) . $request->getURL() . (!empty($queryParams) ? '?' . http_build_query($queryParams) : '');
  21. return $this->redirect($url);
  22. }
Othmane

i'd like to redirect users to their proper locale (if not set explicitly) using fluent 4