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
Language status fields defaults inconsistency in admin vs API #1826
Comments
@poljpocket The ProcessPageAdd module has a feature where it will interactively suggest language status for a newly created page to mirror that of its parent page (whether that means languages on or off). But this is an interactive feature and something that the editor sees and adjusts as needed before the page is actually created. When a page is created from the API, there is no interactive screen for it so suggest anything like that. So if you want a particular status for a language or a particular value for a field, etc., it is assumed you would set it. If PW did that automatically it might overwrite what you intended. It may be that in your installation it would add convenience for PW to do this, and so we have a
Theoretically the LanguageSupport module could do this (and it already hooks this method), but the issue is just that it would be injecting assumptions as part of the save process, and a breaking change. So someone might create a page from the API, knowing that it would only be active for the default language, only to find it active (without them telling it to be) for some other language after they saved it. |
@poljpocket are you ok with Ryan's answer? Can you close this issue? |
@matjazpotocnik sorry of course, this is ok. Thanks for the reminder! |
Short description of the issue
For multi-language environments using
LanguageSupportPageNames
module, there is an inconsistency in thestatus123
-fields (123 = language ID) between creating pages in the admin and via the API.Expected behaviour
When creating a new page via the API (e.g.
$pages->newPage(...)
), the per-language status fields get populated with1
(active) status as this would be the case if the page was created in the admin.P.S.: This is also expected in any case where a
Page Reference
field in 'text tags' mode allows for new pages to be automatically added.Actual behaviour
Creating a page via the API does not set per-language status fields at all, leaving them at
0
(inactive) and effectively only activating the new page in the default language.Screenshots/Links that demonstrate the issue
There is a forum post discussing both situations where others and myself have run into this problem.
Suggestion for a possible fix
A possible fix isn't as simple because I am not aware of any side-effects this could have. There is some logic in the hook
Pages::saveReady
inLanguageSupportPageNames
to decide if a page's language specific status should be active or not. The forum post contains a workaround at least for reproduction method 2 (see below) which explicitly sets the status fields for any non-default language before the page is actually saved:Steps to reproduce the issue
Method 1:
Page Reference - Text Tags
and choose atemplate
andparent page
to be able to enableAllow new pages to be created from field?
option. Enable said option.Method 2:
Setup/Environment
The text was updated successfully, but these errors were encountered: