[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Switch Language Module: restore default lang path in disk language scan
"Bruno Kambere \(@kambereBr\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a832eaed23d3_3818be2416113@gitlab-sidekiq-low-urgency-cpu-bound-v2-8694b5698b-fx6x2.mail> |
Bruno Kambere pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
dd4451c0 by Bruno Kambere at 2026-08-17T18:40:25+03:00
[FIX] Switch Language Module: restore default lang path in disk language scan
---
* [FIX] Switch Language Module: restore default lang path in disk language scan
See merge request tikiwiki/tiki!10917
- - - - -
2 changed files:
- lib/language/Language.php
- lib/test/language/LanguageTest.php
Changes:
=====================================
lib/language/Language.php
=====================================
@@ -143,7 +143,7 @@ class Language extends TikiDb_Bridge
}
/**
- * @param bool $path
+ * @param string|bool $path Directory to scan, or false to use the default 'lang' directory
* @param null $short
* @param bool $all
* @return array|mixed
@@ -172,6 +172,11 @@ class Language extends TikiDb_Bridge
*/
private static function list_disk_languages($path = 'lang')
{
+ // Callers pass false to mean "use the default path"
+ if (! $path) {
+ $path = 'lang';
+ }
+
if (! is_dir($path)) {
return [];
}
=====================================
lib/test/language/LanguageTest.php
=====================================
@@ -25,6 +25,31 @@ class LanguageTest extends TikiTestCase
$this->assertEquals($expectedResult, Language::removePhpSlashes($string));
}
+ public function testListDiskLanguagesFalsyPathUsesDefaultDirectory(): void
+ {
+ $listDiskLanguages = new ReflectionMethod(Language::class, 'list_disk_languages');
+ $listDiskLanguages->setAccessible(true);
+
+ $expected = $listDiskLanguages->invoke(null, 'lang');
+ $this->assertNotEmpty($expected, 'The lang directory should contain language directories');
+
+ foreach ([false, null, ''] as $falsyPath) {
+ $this->assertEqualsCanonicalizing(
+ $expected,
+ $listDiskLanguages->invoke(null, $falsyPath),
+ 'Falsy path ' . var_export($falsyPath, true) . ' should fall back to the lang directory'
+ );
+ }
+ }
+
+ public function testListDiskLanguagesMissingDirectoryReturnsEmptyArray(): void
+ {
+ $listDiskLanguages = new ReflectionMethod(Language::class, 'list_disk_languages');
+ $listDiskLanguages->setAccessible(true);
+
+ $this->assertSame([], $listDiskLanguages->invoke(null, 'lang/does_not_exist'));
+ }
+
// TODO: We need a way to create a Tiki database just for the tests
/*public function testGetDbTranslatedLanguages() {
}*/
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dd4451c0df49956146bde30799a2f9e71d7fd537
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dd4451c0df49956146bde30799a2f9e71d7fd537
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs