[TASK] Remove unselected languages in LocalConfiguration 11/35011/2
authorAndreas Fernandez <andreas.fernandez@aspedia.de>
Wed, 3 Dec 2014 15:04:31 +0000 (16:04 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 3 Dec 2014 20:10:09 +0000 (21:10 +0100)
If selecting one ore more languages in EXT:lang, the complete
language tree is written in EXTCONF/lang/availableLanguages in
LocalConfiguration.php. Empty values in this array represent
unselected languages. This patch removes the empty values
from the language array.

Resolves: #63546
Releases: master, 6.2
Change-Id: I327f05c16f3824f1c91c8f2e095c5b5059b420b9
Reviewed-on: http://review.typo3.org/35011
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/lang/Classes/Domain/Model/LanguageSelectionForm.php
typo3/sysext/lang/Tests/Unit/Domain/Model/LanguageSelectionFormTest.php

index ccea98d..6c5f3c0 100644 (file)
@@ -56,7 +56,7 @@ class LanguageSelectionForm extends \TYPO3\CMS\Extbase\DomainObject\AbstractEnti
         * @return void
         */
        public function setSelectedLanguages(array $selectedLanguages) {
-               $this->selectedLanguages = $selectedLanguages;
+               $this->selectedLanguages = array_values(array_filter($selectedLanguages));
        }
 
        /**
@@ -79,6 +79,7 @@ class LanguageSelectionForm extends \TYPO3\CMS\Extbase\DomainObject\AbstractEnti
                        foreach ($this->selectedLanguages as $language) {
                                $locales[] = $language->getLocale();
                        }
+
                        return implode(',', $locales);
                }
                return '';
index cadaecc..82588b1 100644 (file)
@@ -71,14 +71,12 @@ class LanguageSelectionFormTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function setSelectedLanguagesSetsSelectedLanguages() {
-               $selectedLanguages = array(
-                       'nl' => '1',
-                       'de' => '0',
-               );
+               $selectedLanguages = array('', '', '', '', 'de', '', '', 'nl');
+               $cleanedSelectedLanguages = array('de', 'nl');
                $this->fixture->setSelectedLanguages($selectedLanguages);
 
                $this->assertSame(
-                       $selectedLanguages,
+                       $cleanedSelectedLanguages,
                        $this->fixture->getSelectedLanguages()
                );
        }