Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Translatable and 3.1 - publishall not working - hack


Go to End


831 Views

Avatar
mikg

Community Member, 1 Post

25 April 2013 at 8:28pm

Edited: 26/04/2013 8:15pm

This is fixed on github now. Ingo committed a broader solution to the problem the day this was posted. Kudo's for the quick reaction!

Hi there,

When using the Translatable module (master branch from github dated 14/04/2013) the publishall function (http://<yoursite>/admin/pages/publishall) (http://api.silverstripe.org/3.0/source-class-CMSMain.html#1188-1240) is not working and just returns to the confirm form.

Upon investigation I found that Translatable strips the needed security token and the confirm parameter from the POST request that the publishall confirmation form sends.

As a workaround I added the following line after line 21 in the init function of TranslatableCMSMainExtension.php . There may be a more generic way as I suspect other CMSMain functions like buildbrokenlinks() to suffer from the same problem.
if($req->param('Action') == 'publishall') return;

diff
(sorry for the bad layout, preformatted text get its leading white space stripped in the forum, even when tagged as a code block)
the line with the + in first position is the one that was added:

TranslatableCMSMainExtension.php
@@ -19,6 +19,7 @@
                // $Lang serves as a "context" which can be inspected by Translatable - hence it
                // has the same name as the database property on Translatable.
                $req = $this->owner->getRequest();
+               if($req->param('Action') == 'publishall') return;
                $id = $req->param('ID');
                if($req->requestVar("Locale")) {
                        $this->owner->Locale = $req->requestVar("Locale");

Cheers,
mikg