ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLanguagesInstalledAndUpdatedObjective Class Reference
+ Inheritance diagram for ilLanguagesInstalledAndUpdatedObjective:
+ Collaboration diagram for ilLanguagesInstalledAndUpdatedObjective:

Public Member Functions

 __construct (\ilSetupLanguage $il_setup_language, ?InstallLanguage $install_language=null, ?UpdateLanguage $update_language=null)
 
 getHash ()
 The directory configuration is part of the hash: with a class-only hash Setup could keep the default-directory instance, which refreshes languages without the component-contributed modules. More...
 
 getLabel ()
 @inheritDoc More...
 
 isNotable ()
 @inheritDoc More...
 
 getPreconditions (Setup\Environment $environment)
 @inheritDoc More...
 
 achieve (Setup\Environment $environment)
 @inheritDoc More...
 
 isApplicable (Setup\Environment $environment)
 @inheritDoc More...
 
- Public Member Functions inherited from ilLanguageObjective
 __construct ()
 

Protected Member Functions

 getInstallLanguages ()
 Return installed languages. More...
 
 informAboutSkippedInvalidMarkupEntries (Setup\Environment $environment)
 Customizing entries with disallowed markup are not applied; the languages are installed regardless. More...
 
 informAboutSkippedDuplicateEntries (Setup\Environment $environment)
 A warning only: the languages are installed regardless. More...
 
 informAboutOverlaysOfUnshippedModules (Setup\Environment $environment)
 
 informAboutUnrecordedTakenOverModules (Setup\Environment $environment)
 
 informAboutInvalidMarkupInLocalChanges (Setup\Environment $environment, array $language_keys)
 Local changes written before the markup check existed are only reported, never changed: that is the administrator's decision. More...
 
 informAboutMissingClientDataDirectory (Setup\Environment $environment, array $language_keys)
 Typically during "setup install", before the client directory exists: the overlay of local changes cannot be written, the web serves the shipped values (the build) until the next "setup update". More...
 
 informAboutUnwritableOverlayDirectories (Setup\Environment $environment, array $language_keys)
 Checked before writing. More...
 
 informIfNotRunAsClientDataDirectoryOwner (Setup\Environment $environment, array $language_keys=[])
 Writable for Setup is not enough: files created by another user (typically root) cannot be replaced by the web server later. More...
 
 informAboutUnwrittenOverlays (Setup\Environment $environment, array $language_keys)
 
 useSetupDatabase (Setup\Environment $environment)
 Must run before anything is read from ilSetupLanguage, so that the language list comes from the Setup database. More...
 
 useSetupClientDataDir (Setup\Environment $environment)
 Taken from the Setup environment, which knows it before ilias.ini.php is written; otherwise ilSetupLanguage falls back to ilias.ini.php. More...
 
 inform (Setup\Environment $environment, string $message)
 
 installLanguages (array $language_keys)
 Installs missing languages and refreshes installed ones on every run, so that changed language files take effect. More...
 

Protected Attributes

ilSetupLanguage $il_setup_language
 
InstallLanguage $install_language
 
UpdateLanguage $update_language
 

Private Attributes

array $install_languages = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLanguagesInstalledAndUpdatedObjective::__construct ( \ilSetupLanguage  $il_setup_language,
?InstallLanguage  $install_language = null,
?UpdateLanguage  $update_language = null 
)
Parameters
InstallLanguage | null$install_languagenull only for callers constructed deep inside the Setup tree (plugin objectives); a Setup-only instance is then built here instead of reading $GLOBALS['DIC']
UpdateLanguage | null$update_languagesee $install_language

Definition at line 42 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

46 {
47 $this->il_setup_language = $il_setup_language;
48 $this->install_language = $install_language ?? InstallLanguage::forSetup($il_setup_language);
49 $this->update_language = $update_language ?? UpdateLanguage::forSetup($il_setup_language);
50 }

References $il_setup_language, $install_language, and $update_language.

Member Function Documentation

◆ achieve()

ilLanguagesInstalledAndUpdatedObjective::achieve ( Setup\Environment  $environment)

@inheritDoc

Definition at line 123 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

123 : Setup\Environment
124 {
125 // Must come first: getInstallLanguages() reads from the database too.
126 $this->useSetupDatabase($environment);
127 $this->useSetupClientDataDir($environment);
128
129 $language_keys = [];
130 $invalid_language_keys = [];
131 foreach ($this->getInstallLanguages() as $language_key) {
132 if ($this->il_setup_language->checkLanguageForInstallation($language_key)) {
133 $language_keys[] = $language_key;
134 } else {
135 $invalid_language_keys[] = $language_key;
136 }
137 }
138 if ($invalid_language_keys !== []) {
139 // an invalid language file only skips that language, the Setup run goes on
140 $this->inform(
141 $environment,
142 'Skipped languages with invalid language files (left unchanged): '
143 . implode(', ', $invalid_language_keys)
144 );
145 }
146
147 $this->informAboutMissingClientDataDirectory($environment, $language_keys);
148 $this->informAboutUnwritableOverlayDirectories($environment, $language_keys);
149 $this->informAboutUnwrittenOverlays($environment, $this->installLanguages($language_keys));
150 $this->informAboutSkippedInvalidMarkupEntries($environment);
151 $this->informAboutSkippedDuplicateEntries($environment);
152 foreach ($this->il_setup_language->getSkippedUnreadableOverlays() as $language_key => $modules) {
153 $this->inform($environment, PlainLogText::of(
154 'WARNING: The overlay (local changes) of language ' . $language_key . ' cannot be read for the modules '
155 . implode(', ', $modules) . ': they were left unchanged, their local changes are only served again '
156 . 'once the overlay below <client data dir>/lang is repaired. Until then their rollback copy in '
157 . 'lng_data/lng_modules is incomplete.'
158 ));
159 }
160 $this->informAboutOverlaysOfUnshippedModules($environment);
161 $this->informAboutUnrecordedTakenOverModules($environment);
162 $this->informAboutInvalidMarkupInLocalChanges($environment, $language_keys);
163
164 return $environment;
165 }
useSetupDatabase(Setup\Environment $environment)
Must run before anything is read from ilSetupLanguage, so that the language list comes from the Setup...
informAboutUnwrittenOverlays(Setup\Environment $environment, array $language_keys)
inform(Setup\Environment $environment, string $message)
informAboutMissingClientDataDirectory(Setup\Environment $environment, array $language_keys)
Typically during "setup install", before the client directory exists: the overlay of local changes ca...
informAboutSkippedInvalidMarkupEntries(Setup\Environment $environment)
Customizing entries with disallowed markup are not applied; the languages are installed regardless.
informAboutSkippedDuplicateEntries(Setup\Environment $environment)
A warning only: the languages are installed regardless.
informAboutUnwritableOverlayDirectories(Setup\Environment $environment, array $language_keys)
Checked before writing.
useSetupClientDataDir(Setup\Environment $environment)
Taken from the Setup environment, which knows it before ilias.ini.php is written; otherwise ilSetupLa...
informAboutInvalidMarkupInLocalChanges(Setup\Environment $environment, array $language_keys)
Local changes written before the markup check existed are only reported, never changed: that is the a...
installLanguages(array $language_keys)
Installs missing languages and refreshes installed ones on every run, so that changed language files ...

References getInstallLanguages(), inform(), informAboutInvalidMarkupInLocalChanges(), informAboutMissingClientDataDirectory(), informAboutOverlaysOfUnshippedModules(), informAboutSkippedDuplicateEntries(), informAboutSkippedInvalidMarkupEntries(), informAboutUnrecordedTakenOverModules(), informAboutUnwritableOverlayDirectories(), informAboutUnwrittenOverlays(), installLanguages(), useSetupClientDataDir(), and useSetupDatabase().

+ Here is the call graph for this function:

◆ getHash()

ilLanguagesInstalledAndUpdatedObjective::getHash ( )

The directory configuration is part of the hash: with a class-only hash Setup could keep the default-directory instance, which refreshes languages without the component-contributed modules.

Definition at line 56 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

56 : string
57 {
58 $directories = [];
59 foreach ($this->il_setup_language->getLanguageFileDirectoryManager()->getAllDirectories() as $directory) {
60 $directories[] = implode('|', [
61 $directory::class,
62 $directory->getPrefix(),
63 $directory->getPath(),
64 $directory->getSuffix(),
65 ]);
66 }
67
68 return hash("sha256", implode("\n", [
69 self::class,
70 $this->il_setup_language->usesDefaultLanguageFileDirectories() ? 'default-directories' : 'configured-directories',
71 ...$directories,
72 ]));
73 }

◆ getInstallLanguages()

ilLanguagesInstalledAndUpdatedObjective::getInstallLanguages ( )
protected

Return installed languages.

Definition at line 78 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

78 : array
79 {
80 return $this->install_languages ??= $this->il_setup_language->getInstalledLanguages() ?: ['en'];
81 }

Referenced by achieve(), and isApplicable().

+ Here is the caller graph for this function:

◆ getLabel()

ilLanguagesInstalledAndUpdatedObjective::getLabel ( )

@inheritDoc

Definition at line 86 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

86 : string
87 {
88 // No database access here: the Setup CLI calls this before achieve().
89 if ($this->install_languages === null) {
90 return "Install/Update languages";
91 }
92 return "Install/Update languages " . implode(", ", $this->install_languages);
93 }

◆ getPreconditions()

ilLanguagesInstalledAndUpdatedObjective::getPreconditions ( Setup\Environment  $environment)

@inheritDoc

Definition at line 106 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

106 : array
107 {
108 $preconditions = [new ilDatabaseInitializedObjective()];
109 // with the default directories the build would serve no module at all
110 if (!$this->il_setup_language->usesDefaultLanguageFileDirectories()) {
111 $preconditions[] = new ShippedLanguageFilesCompiledObjective(
112 $this->il_setup_language->getLanguageFileDirectoryManager(),
113 dirname(__DIR__, 5)
114 );
115 }
116
117 return $preconditions;
118 }
Build step (php cli/setup.php build) for the migrated modules: builds what native gettext serves from...

◆ inform()

ilLanguagesInstalledAndUpdatedObjective::inform ( Setup\Environment  $environment,
string  $message 
)
protected

Definition at line 464 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

464 : void
465 {
466 $io = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
467 if ($io instanceof Setup\AdminInteraction) {
468 $io->inform($message);
469 return;
470 }
471 error_log($message);
472 }
This defines ways in which objectives may interact with admins during the setup.

References $message.

Referenced by achieve(), informAboutInvalidMarkupInLocalChanges(), informAboutMissingClientDataDirectory(), informAboutOverlaysOfUnshippedModules(), informAboutSkippedDuplicateEntries(), informAboutSkippedInvalidMarkupEntries(), informAboutUnrecordedTakenOverModules(), informAboutUnwritableOverlayDirectories(), informAboutUnwrittenOverlays(), and informIfNotRunAsClientDataDirectoryOwner().

+ Here is the caller graph for this function:

◆ informAboutInvalidMarkupInLocalChanges()

ilLanguagesInstalledAndUpdatedObjective::informAboutInvalidMarkupInLocalChanges ( Setup\Environment  $environment,
array  $language_keys 
)
protected

Local changes written before the markup check existed are only reported, never changed: that is the administrator's decision.

Parameters
list<string>$language_keys

Definition at line 231 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

231 : void
232 {
234 $manager = $this->il_setup_language->getLanguageFileDirectoryManager();
235 $client_data_dir = $this->il_setup_language->getClientDataDir();
236 foreach ($language_keys as $language_key) {
237 $values = [];
238 try {
239 // a module with an overlay, or whose lng_data was taken over, is checked in its overlay only
240 $overlay_only = array_fill_keys(MigratedLanguageFileSync::modulesWithLocalChangesTakenOver($client_data_dir, $language_key), true);
241 foreach ($manager->getDirectories() as $directory) {
242 $module = $directory->getPrefix();
243 if (MigratedLanguageFileSync::hasOverlay($manager, $language_key, $module, $client_data_dir)) {
244 $overlay_only[$module] = true;
245 }
246 foreach (MigratedLanguageFileSync::loadLocalChanges($manager, $language_key, $module, $client_data_dir) ?? [] as $identifier => $entry) {
247 $values[$module . '#:#' . $identifier] = $entry['value'];
248 }
249 }
250 foreach ($this->il_setup_language->getLocalChanges($language_key) as $module => $entries) {
251 if (isset($overlay_only[$module])) {
252 continue;
253 }
254 foreach ($entries as $identifier => $value) {
255 $values[$module . '#:#' . $identifier] ??= (string) $value;
256 }
257 }
258 } catch (\Throwable $t) {
259 error_log(PlainLogText::of(sprintf(
260 'Could not check the local changes of language "%s" for markup: %s',
261 $language_key,
262 $t->getMessage()
263 )));
264 continue;
265 }
266
267 $keys = array_map('strval', array_keys($policy->findInvalidValues($values)));
268 if ($keys === []) {
269 continue;
270 }
271 error_log(PlainLogText::of(sprintf(
272 'Local changes of language "%s" contain markup that is not allowed: %s',
273 $language_key,
274 implode(', ', $keys)
275 )));
276 $this->inform(
277 $environment,
278 PlainLogText::of(
279 'WARNING: Local changes of language ' . $language_key . ' contain HTML that is not allowed '
280 . 'in language texts (left unchanged - please correct them in the administration): '
281 . PlainLogText::keyList($keys)
282 )
283 );
284 }
285 }
The HTML a translation value may contain, decided in one place for the shipped files (cleaned in Setu...
if(!isset($arguments[0])) if(count( $arguments) > 3) if(! $remove_from_lang &&isset($arguments[2]) &&!is_dir($arguments[2])) $module

References $module, $policy, and inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutMissingClientDataDirectory()

ilLanguagesInstalledAndUpdatedObjective::informAboutMissingClientDataDirectory ( Setup\Environment  $environment,
array  $language_keys 
)
protected

Typically during "setup install", before the client directory exists: the overlay of local changes cannot be written, the web serves the shipped values (the build) until the next "setup update".

Parameters
list<string>$language_keys

Definition at line 293 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

293 : void
294 {
295 if (
296 $language_keys === []
297 || $this->il_setup_language->getClientDataDir() !== null
298 || !$this->il_setup_language->hasMigratedModules($language_keys)
299 ) {
300 return;
301 }
302
303 $this->inform(
304 $environment,
305 'WARNING: The client data directory is not known or does not exist yet, so the local changes '
306 . '(e.g. lang/*.lang.local) of modules maintained in PO files are not written to their overlay in '
307 . 'this run - these modules show their shipped texts without local changes until then. Run "setup '
308 . 'update" (as the web server user) once the client data directory exists.'
309 );
310 }

References inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutOverlaysOfUnshippedModules()

ilLanguagesInstalledAndUpdatedObjective::informAboutOverlaysOfUnshippedModules ( Setup\Environment  $environment)
protected

Definition at line 199 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

199 : void
200 {
201 foreach ($this->il_setup_language->getOverlaysOfUnshippedModules() as $language_key => $modules) {
202 $this->inform($environment, PlainLogText::of(
203 'WARNING: The modules ' . implode(', ', $modules) . ' have no shipped .po for language '
204 . $language_key . ', but an overlay below <client data dir>/lang or an entry in <client data '
205 . 'dir>/lang/taken-over.' . $language_key . '.json. Remove the overlay directory <client data '
206 . 'dir>/lang/<module>/' . $language_key . ' and the entry before the module is shipped again (or '
207 . 'if it no longer exists) - otherwise they win over the local changes in lng_data.'
208 ));
209 }
210 }

References inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutSkippedDuplicateEntries()

ilLanguagesInstalledAndUpdatedObjective::informAboutSkippedDuplicateEntries ( Setup\Environment  $environment)
protected

A warning only: the languages are installed regardless.

Definition at line 185 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

185 : void
186 {
187 foreach ($this->il_setup_language->getSkippedDuplicateEntries() as $language_key => $entries) {
188 $this->inform(
189 $environment,
190 PlainLogText::of(
191 'WARNING: Customizing entries of language ' . $language_key . ' were not applied, their '
192 . 'identifier already exists in another module or in another spelling: '
193 . PlainLogText::keyList(array_map('strval', array_keys($entries)))
194 )
195 );
196 }
197 }

References inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutSkippedInvalidMarkupEntries()

ilLanguagesInstalledAndUpdatedObjective::informAboutSkippedInvalidMarkupEntries ( Setup\Environment  $environment)
protected

Customizing entries with disallowed markup are not applied; the languages are installed regardless.

Definition at line 170 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

170 : void
171 {
172 foreach ($this->il_setup_language->getSkippedInvalidMarkupEntries() as $language_key => $entries) {
173 $this->inform(
174 $environment,
175 PlainLogText::of(
176 'WARNING: Customizing entries of language ' . $language_key . ' were not applied, their '
177 . 'value contains HTML that is not allowed in language texts: '
178 . PlainLogText::keyList(array_map('strval', array_keys($entries)))
179 )
180 );
181 }
182 }

References inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutUnrecordedTakenOverModules()

ilLanguagesInstalledAndUpdatedObjective::informAboutUnrecordedTakenOverModules ( Setup\Environment  $environment)
protected

Definition at line 212 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

212 : void
213 {
214 foreach ($this->il_setup_language->getUnrecordedTakenOverModules() as $language_key => $modules) {
215 $this->inform($environment, PlainLogText::of(
216 'WARNING: Could not record in <client data dir>/lang/taken-over.' . $language_key . '.json that the '
217 . 'local changes of language ' . $language_key . ' in lng_data were taken over for the modules '
218 . implode(', ', $modules) . ' (see the PHP error log for details). They are taken over again by the '
219 . 'next "setup update" - <client data dir>/lang (including .locks and the record file) must be '
220 . 'writable for the user running Setup.'
221 ));
222 }
223 }

References inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutUnwritableOverlayDirectories()

ilLanguagesInstalledAndUpdatedObjective::informAboutUnwritableOverlayDirectories ( Setup\Environment  $environment,
array  $language_keys 
)
protected

Checked before writing.

Does not abort: the database is written regardless, the files are repaired by the next run with sufficient permissions.

Parameters
list<string>$language_keys

Definition at line 318 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

318 : void
319 {
320 $unwritable_directories = $this->il_setup_language->findUnwritableOverlayDirectories($language_keys);
321 if ($unwritable_directories !== []) {
322 $this->inform(
323 $environment,
324 'WARNING: The PO/MO language files of modules maintained in PO files cannot be written to '
325 . implode(', ', $unwritable_directories) . ' (not writable, or a file occupies the '
326 . 'directory\'s place). The languages are still installed/updated in the database, but these '
327 . 'modules keep showing outdated texts. Setup must be run as the web server user (the owner '
328 . 'of the client data directory) - re-run "setup update" as that user to repair the files.'
329 );
330 }
331
332 $this->informIfNotRunAsClientDataDirectoryOwner($environment, $language_keys);
333 }
informIfNotRunAsClientDataDirectoryOwner(Setup\Environment $environment, array $language_keys=[])
Writable for Setup is not enough: files created by another user (typically root) cannot be replaced b...

References inform(), and informIfNotRunAsClientDataDirectoryOwner().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informAboutUnwrittenOverlays()

ilLanguagesInstalledAndUpdatedObjective::informAboutUnwrittenOverlays ( Setup\Environment  $environment,
array  $language_keys 
)
protected
Parameters
list<string>$language_keys languages whose PO/MO overlay could not be written

Definition at line 405 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

405 : void
406 {
407 if ($language_keys === []) {
408 return;
409 }
410
411 $this->inform(
412 $environment,
413 'WARNING: The PO/MO language files of modules maintained in PO files could not be written for '
414 . 'the languages ' . implode(', ', $language_keys) . ' (see the PHP error log for details). '
415 . 'Setup must be run as the web server user - re-run "setup update" as that user.'
416 );
417 }

References inform().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ informIfNotRunAsClientDataDirectoryOwner()

ilLanguagesInstalledAndUpdatedObjective::informIfNotRunAsClientDataDirectoryOwner ( Setup\Environment  $environment,
array  $language_keys = [] 
)
protected

Writable for Setup is not enough: files created by another user (typically root) cannot be replaced by the web server later.

The owner of the client data directory counts as web server user.

Parameters
list<string>$language_keys

Definition at line 341 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

341 : void
342 {
343 $client_data_dir = $this->il_setup_language->getClientDataDir();
344 if ($client_data_dir === null || !function_exists('posix_geteuid')) {
345 return;
346 }
347 $owner = @fileowner($client_data_dir);
348 $current_user = posix_geteuid();
349 if ($owner === false || ($owner === $current_user && $current_user !== 0)) {
350 return;
351 }
352 if (!$this->il_setup_language->hasMigratedModules($language_keys)) {
353 return;
354 }
355
356 $overlay_root = rtrim($client_data_dir, '/') . '/lang';
357 if ($owner === 0) {
358 $this->inform(
359 $environment,
360 sprintf(
361 'WARNING: Setup runs as user id %d, and the client data directory %s belongs to root. '
362 . 'Running Setup as root is not supported: the web server cannot replace the PO/MO '
363 . 'language files and directories of modules maintained in PO files that this run '
364 . 'creates. Fix: run "chown -R <web server user> %s" after this run, and run Setup '
365 . 'as the web server user from now on.',
366 $current_user,
367 $client_data_dir,
368 $overlay_root
369 )
370 );
371 return;
372 }
373
374 $owner_info = function_exists('posix_getpwuid') ? @posix_getpwuid($owner) : false;
375 $owner_name = is_array($owner_info) ? (string) $owner_info['name'] : (string) $owner;
376 $unwritable_for_owner = $this->il_setup_language->findUnwritableOverlayDirectories($language_keys, $owner);
377
378 $this->inform(
379 $environment,
380 sprintf(
381 'WARNING: Setup runs as user id %d, but the client data directory %s belongs to user id %d. '
382 . 'Running Setup as another user than the web server user (the owner of the client data '
383 . 'directory) is not supported%s: the PO/MO language files and directories of modules '
384 . 'maintained in PO files that this run creates belong to user id %d and cannot be '
385 . 'replaced by the web server later on.%s Fix: run "chown -R %s %s" after this run, and '
386 . 'run Setup as user %s from now on.',
387 $current_user,
388 $client_data_dir,
389 $owner,
390 $current_user === 0 ? ' (this includes root)' : '',
391 $current_user,
392 $unwritable_for_owner === []
393 ? ''
394 : ' Already not writable for user id ' . $owner . ': ' . implode(', ', $unwritable_for_owner) . '.',
395 $owner_name,
396 $overlay_root,
397 $owner_name
398 )
399 );
400 }

References inform().

Referenced by informAboutUnwritableOverlayDirectories().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installLanguages()

ilLanguagesInstalledAndUpdatedObjective::installLanguages ( array  $language_keys)
protected

Installs missing languages and refreshes installed ones on every run, so that changed language files take effect.

Both Activities get the full list and ignore keys that do not apply to them; UpdateLanguage also runs on just-installed keys, which is harmless.

An instance with only the default directories never refreshes: that would delete the lng_data rows of component-contributed modules.

Parameters
list<string>$language_keys
Returns
list<string> the languages whose PO/MO overlay could not be written (see InstallLanguage/UpdateLanguage, "overlay_write_failed_language_keys")

Definition at line 487 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

487 : array
488 {
489 if ($language_keys === []) {
490 return [];
491 }
492
493 $install_result = $this->install_language->perform([
494 'language_keys' => $language_keys,
495 'mode' => InstallLanguage::MODE_INSTALL,
496 ]);
497 $overlay_write_failed = $install_result['overlay_write_failed_language_keys'] ?? [];
498
499 if (!$this->il_setup_language->usesDefaultLanguageFileDirectories()) {
500 $update_result = $this->update_language->perform([
501 'language_keys' => $language_keys,
502 ]);
503 $overlay_write_failed = array_merge(
504 $overlay_write_failed,
505 $update_result['overlay_write_failed_language_keys'] ?? []
506 );
507 }
508
509 return array_values(array_unique($overlay_write_failed));
510 }

Referenced by achieve().

+ Here is the caller graph for this function:

◆ isApplicable()

ilLanguagesInstalledAndUpdatedObjective::isApplicable ( Setup\Environment  $environment)

@inheritDoc

Definition at line 422 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

422 : bool
423 {
424 // getLabel() is shown between isApplicable() and achieve() and lists the languages.
425 if ($environment->getResource(Setup\Environment::RESOURCE_DATABASE) instanceof \ilDBInterface) {
426 $this->useSetupDatabase($environment);
427 $this->getInstallLanguages();
428 }
429
430 return true;
431 }
Interface ilDBInterface.

References getInstallLanguages(), and useSetupDatabase().

+ Here is the call graph for this function:

◆ isNotable()

ilLanguagesInstalledAndUpdatedObjective::isNotable ( )

@inheritDoc

Definition at line 98 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

98 : bool
99 {
100 return true;
101 }

◆ useSetupClientDataDir()

ilLanguagesInstalledAndUpdatedObjective::useSetupClientDataDir ( Setup\Environment  $environment)
protected

Taken from the Setup environment, which knows it before ilias.ini.php is written; otherwise ilSetupLanguage falls back to ilias.ini.php.

Definition at line 447 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

447 : void
448 {
449 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
450 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
451 if (!$ini instanceof ilIniFile || $client_id === null) {
452 return;
453 }
454
456 (string) $ini->readVariable('clients', 'datadir'),
457 (string) $client_id
458 );
459 if ($client_data_dir !== null) {
460 $this->il_setup_language->setClientDataDir($client_data_dir);
461 }
462 }
static fromDataDirAndClientId(?string $data_dir, ?string $client_id)
Composes the client data directory from its two parts (e.g.
INI file parser — compatibility wrapper.
$client_id
Definition: ltiresult.php:32

References $client_id, and ILIAS\Language\ComponentTranslation\MigratedLanguageFilePaths\fromDataDirAndClientId().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ useSetupDatabase()

ilLanguagesInstalledAndUpdatedObjective::useSetupDatabase ( Setup\Environment  $environment)
protected

Must run before anything is read from ilSetupLanguage, so that the language list comes from the Setup database.

Definition at line 436 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

436 : void
437 {
438 $this->il_setup_language->setDbHandler(
439 $environment->getResource(Setup\Environment::RESOURCE_DATABASE)
440 );
441 }

Referenced by achieve(), and isApplicable().

+ Here is the caller graph for this function:

Field Documentation

◆ $il_setup_language

ilSetupLanguage ilLanguagesInstalledAndUpdatedObjective::$il_setup_language
protected

Definition at line 31 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

Referenced by __construct().

◆ $install_language

InstallLanguage ilLanguagesInstalledAndUpdatedObjective::$install_language
protected

Definition at line 32 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

Referenced by __construct().

◆ $install_languages

array ilLanguagesInstalledAndUpdatedObjective::$install_languages = null
private

◆ $update_language

UpdateLanguage ilLanguagesInstalledAndUpdatedObjective::$update_language
protected

Definition at line 33 of file class.ilLanguagesInstalledAndUpdatedObjective.php.

Referenced by __construct().


The documentation for this class was generated from the following file: