Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new page on a sitetree which isnt the default locale adds faulty DB records. #156

Closed
hubertusanton opened this issue Dec 14, 2013 · 7 comments

Comments

@hubertusanton
Copy link

The following bug occurs after updating Translatable to the latest version:
When creating a new page under another on a language (right click) which is not the default, the page is created in the DB under the right parentID but is using the default locale. This results in the page being gone after reloading the backend.

Think this is caused by the changing of Locale to locale in TranslatableCMSMainExtension.php
on line 156

function updateLinkPageAdd(&$link) {
    $locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
    if($locale) $link = Controller::join_links($link, '?locale=' . $locale);
}

with Locale (translation added in nl_NL ok)

http://localhost/trtest/admin/pages/add/AddForm/?locale=nl_NL&Locale=nl_NL&action_doAdd=1&ParentID=6&PageType=Page&SecurityID=0a45efd7b7a64ceb7ffd56415ac99ee56828b3b2

with locale (translation not added in nl_NL but record created with wrong (default) locale on en_US )

http://localhost/trtest/admin/pages/add/AddForm/?locale=nl_NL&action_doAdd=1&ParentID=6&PageType=Page&SecurityID=0a45efd7b7a64ceb7ffd56415ac99ee56828b3b2

missing Locale (uppercase) in url so this is obviously used somewhere.
and this is in SS cms/code/controllers/CMSPageAddController.php at line 155

if(class_exists('Translatable') && $record->hasExtension('Translatable') && isset($data['Locale'])) {
    $record->Locale = $data['Locale'];
}

solving this might be in the cms or in translatable/code/controller/TranslatableCMSMainExtension.php
line 102

function updatePageOptions(&$fields) {
    $fields->push(new HiddenField("Locale", 'Locale', Translatable::get_current_locale()));
}

Not sure the solution is to just leave the variable starting in uppercase in my project in TranslatableCMSMainExtension.php on line 156, this might break something else? Will look into another solution later, hope someone knows the solution to this.

@hubertusanton
Copy link
Author

fixed by 36c4125

@hubertusanton
Copy link
Author

This problem still exists, and breaks correct functioning of creation of pages in another anguage than the default one. A simple switch to an uppercase in TranslatableCMSMainExtension.php fixes it. Should i do a pull request?

@jyrkij
Copy link

jyrkij commented Feb 26, 2015

Hmm. I noticed this just now. I thought it had been working before but this issue suggests that it has been broken for a long time... What should be done?

@chillu
Copy link
Member

chillu commented Apr 27, 2015

Can't reproduce with translatable 2.0.x-dev on SilverStripe 3.1.12: http://screencast.com/t/zLnW5Gjl. @jyrkij @hubertusanton Can you provide more details please?

@hubertusanton
Copy link
Author

Tested this on 3.1.12 and translatable 2.0.6. It still occurs.

I do the following steps (in your video you create pages on root, maybe thats the reason it works?)
The steps below are in a situation where all sites have pages.

1 - log into cms ( you end up in default lang tree )
2 - select another language
3 - create a page under another one (with right click)
4 - publish this page
5 - goto /admin/pages
6 - select 'not default language' the page above in step 3 was created in
7 - the page is not there, because it was created as a faulty record in the wrong language

This causes the bug:
d194b50

When you change ?locale= to ?Locale= which i do in all our projects by hand, its fixed.

@chillu
Copy link
Member

chillu commented Jun 1, 2015

@hubertusanton Does this PR fix your issue? #193

@hubertusanton
Copy link
Author

@chillu Yes it does! Thanks!
Applied your pull request with a patch to 2.0.6 and the problem is solved.

@chillu chillu closed this as completed Jun 16, 2015
chillu added a commit that referenced this issue Jan 13, 2016
Causes inconsistent behaviour between form field name ("Locale")
and view state in GET parameters ("Locale" and "locale").

Related to #156.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants