|
ILIAS
trunk Revision v13.0_alpha-62-g3b72d83f2e5
|
Write access to the language installation: installing, flushing and registering languages in the database. More...
Collaboration diagram for ILIAS\Language\Setup\LanguageInstallationManager:Public Member Functions | |
| __construct (private readonly \ilDBInterface $db, private readonly LanguageFileDirectoryManager $language_file_directory_manager, private readonly string $absolute_path, private readonly InstalledLanguageRepository $repository, private readonly ?\Closure $now=null, private readonly TranslationCache $translation_cache=new NullTranslationCache(), private readonly ?\Closure $client_data_dir_resolver=null, private readonly ?LoggerInterface $logger=null,) | |
| getSkippedInvalidMarkupEntries () | |
| Entries of the customizing/local files that the insertLanguageFor...() calls of this instance left out because of markup TranslationMarkupPolicy does not allow. More... | |
| getSkippedDuplicateEntries () | |
| Entries the insertLanguageFor...() calls left out: their identifier exists in another module or spelling (language.md rule 2). More... | |
| getSkippedUnreadableOverlays () | |
| The migrated modules left out of the insertLanguageFor...() calls because their overlay cannot be read. More... | |
| getOverlaysOfUnshippedModules () | |
| Modules no longer shipped for the language that still have an overlay or a taken-over record. More... | |
| getUnrecordedTakenOverModules () | |
| Modules whose taken-over record could not be written: they are taken over again by the next run. More... | |
| installLanguages (array $lang_keys, array $local_keys=[]) | |
| Installs the given languages, flushes all other known ones. More... | |
| registerInstalledLanguage (string $lang_key, array $known_languages, array $local_language_keys) | |
| Registers or updates the object_data row of a (re-)inserted language ("installed" vs. More... | |
| flushLanguageForInstallation (string $lang_key) | |
| flushLanguageForUninstallation (string $lang_key) | |
| insertLanguageForInstallation (string $lang_key) | |
| Installs or refreshes a language from every directory the LanguageFileDirectoryManager knows (including customizing/local), merged on top of the recorded local changes. More... | |
| insertLanguageForRemovingLocalChanges (string $lang_key) | |
Re-seeds a language purely from the shipped global/component files (.lang, shipped .po), without customizing/local files and local changes: the write path of "remove local changes". More... | |
| insertLanguageForApplyingLocalChanges (string $lang_key) | |
| Applies only the customizing/local file on top of an installed language, leaving the base data untouched: the write path of "Install local" (see InstallLanguage::perform()). More... | |
| findUnwritableOverlayDirectories (array $lang_keys, ?int $for_user_id=null) | |
| The overlay directories of the modules migrated for $lang_keys that cannot be written, see MigratedLanguageFileSync::findUnwritableOverlayDirectories(). More... | |
Private Member Functions | |
| logWarning (string $message) | |
| markupPolicy () | |
| invalidMarkupOfCustomizingValue (string $value, ?string $current, ?string $shipped) | |
| The violations of a customizing $value, only if it changes something (see TranslationMarkupPolicy::findInvalidChangedValues()). More... | |
| duplicatesOfCustomizingLines (array $content, string $prefix, array $existing) | |
| clientDataDir () | |
| utcTimestamp (?int $unix_timestamp=null) | |
| removeOverlays (string $lang_key) | |
| The overlay counterpart of flushLanguage($lang_key, "all") for a language that is no longer installed - see ilObjLanguage::uninstall(). More... | |
| flushLanguage (string $lang_key, string $mode="all") | |
| deleteLangData (string $lang_key, bool $keep_local_change) | |
| insertLanguage (string $lang_key, iterable $directories, array $lang_array, bool $merge_shipped_migrated_modules, bool $keep_local_changes, bool $delete_unchanged_migrated_rows=false) | |
| Writes the data of the given $directories/$lang_array seed; the callers above decide both. More... | |
| findOverlaysOfUnshippedModules (string $lang_key, ?string $client_data_dir, ?array $shipped_modules) | |
| writeLanguage (string $lang_key, iterable $directories, array $lang_array, array $shipped_migrated_modules, array $locked_modules, bool $keep_local_changes, bool $delete_unchanged_migrated_rows, ?string $client_data_dir, array $overlay_only_modules=[], array $skipped_modules=[]) | |
| insertLanguage() once the overlays of $locked_modules are locked. More... | |
| resolveMigratedModule (array $local_entries, array $customized, array $shipped_entries, array $overlay, \Closure $write_row, \Closure $delete_row) | |
| The shipped/local decision for one migrated module: a three-way comparison per shipped entry between L = the local value (. More... | |
| isReadableOverlay (string $lang_key, string $module, ?string $client_data_dir) | |
| loadOverlay (string $lang_key, string $module, ?string $client_data_dir) | |
| The overlay state of a migrated module, or null. More... | |
| assertModulesCorrectlySaved (string $lang_key, array $modules) | |
| A wrong table collation silently corrupts the serialized module arrays, which would otherwise only surface as missing translations (mantis #20046/#19140). More... | |
| invalidateLanguageCache (string $lang_key) | |
| migratedModuleRemarks (string $lang_key, array $shipped_migrated_modules, array $customized_remarks, array $shipped_line_comments, ?string $client_data_dir, array $overlay_only_modules=[]) | |
| The remarks of every migrated module (identifier => remark; a plural message under its identifier): lng_data, overridden by the overlay, overridden by the customizing file. More... | |
| migratedLocalChangeDates (string $lang_key, array $modules) | |
| lng_data.local_change of every locally changed entry of $modules in $lang_key (as written by this run), module => identifier => database timestamp - for the overlay, see MigratedLanguageFileSync::sync(). More... | |
| syncMigratedModules (string $lang_key, array $lang_array, ?string $client_data_dir, array $expected_overlays=[], array $remarks=[], array $local_change_dates=[]) | |
Static Private Member Functions | |
| static | databaseRowsOfMigratedModule (array $rows, array $final_entries, array $shipped_entries, array $remarks=[]) |
| The lng_data rows of a migrated module from the rows buffered while its content was decided: the rows of a plural message's forms (and a plain row of its identifier) become one row of the identifier with the final default value (see MigratedLanguageFileSync::collapsePluralForms() and databaseValues()), the first remark and, only if that value differs from the shipped default, the first local_change. More... | |
Private Attributes | |
| const string | SEPARATOR = "#:#" |
| const string | COMMENT_SEPARATOR = "###" |
| array | $skipped_invalid_markup_entries = [] |
| array | $skipped_duplicate_entries = [] |
| array | $skipped_unreadable_overlays = [] |
| array | $overlays_of_unshipped_modules = [] |
| array | $unrecorded_taken_over_modules = [] |
| TranslationMarkupPolicy | $markup_policy = null |
Write access to the language installation: installing, flushing and registering languages in the database.
Reading lives in InstalledLanguageRepository.
Definition at line 40 of file LanguageInstallationManager.php.
| ILIAS\Language\Setup\LanguageInstallationManager::__construct | ( | private readonly \ilDBInterface | $db, |
| private readonly LanguageFileDirectoryManager | $language_file_directory_manager, | ||
| private readonly string | $absolute_path, | ||
| private readonly InstalledLanguageRepository | $repository, | ||
| private readonly ?\Closure | $now = null, |
||
| private readonly TranslationCache | $translation_cache = new NullTranslationCache(), |
||
| private readonly ?\Closure | $client_data_dir_resolver = null, |
||
| private readonly ?LoggerInterface | $logger = null |
||
| ) |
| ( |
Closure():\DateTimeImmutable)|null $now injectable clock (UTC now by default), for tests
| ( |
Closure():?string)|null $client_data_dir_resolver resolved on every call, as no client may exist at construction time; null = no overlay is maintained, the database is written regardless
| LoggerInterface | null | $logger | null in the Setup: warnings go to the PHP error log |
Definition at line 79 of file LanguageInstallationManager.php.
|
private |
A wrong table collation silently corrupts the serialized module arrays, which would otherwise only surface as missing translations (mantis #20046/#19140).
| list<string> | $modules |
Definition at line 1216 of file LanguageInstallationManager.php.
References $ilDB.
|
private |
Definition at line 208 of file LanguageInstallationManager.php.
|
staticprivate |
The lng_data rows of a migrated module from the rows buffered while its content was decided: the rows of a plural message's forms (and a plain row of its identifier) become one row of the identifier with the final default value (see MigratedLanguageFileSync::collapsePluralForms() and databaseValues()), the first remark and, only if that value differs from the shipped default, the first local_change.
The row stands for the default value alone, so after a rollback it does not hold back updates of the legacy .lang files. Every other row is kept.
| array<string,array{0 | string, 1: ?string, 2: ?string}> $rows identifier => value, local_change, remarks |
| array<string,string> | $final_entries the module's final identifier => value map |
| array<string,string> | $shipped_entries |
| array<string,string> | $remarks identifier => remark, see migratedModuleRemarks() |
Definition at line 1037 of file LanguageInstallationManager.php.
References ILIAS\Scripts\PHPStan\$rows.
|
private |
Definition at line 369 of file LanguageInstallationManager.php.
|
private |
| list<string> | $content lines of a customizing file, without header |
| list<array<string,array<string,mixed>>> | $existing module => identifier => … this run writes besides lng_data, which a flush before an installation has emptied for this language |
Definition at line 184 of file LanguageInstallationManager.php.
References $module.
|
private |
| list<string>|null | $shipped_modules null: looked up here |
Definition at line 634 of file LanguageInstallationManager.php.
References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().
Here is the call graph for this function:| ILIAS\Language\Setup\LanguageInstallationManager::findUnwritableOverlayDirectories | ( | array | $lang_keys, |
| ?int | $for_user_id = null |
||
| ) |
The overlay directories of the modules migrated for $lang_keys that cannot be written, see MigratedLanguageFileSync::findUnwritableOverlayDirectories().
To be checked before installing, so a missing permission is reported up front instead of only logged per module.
| list<string> | $lang_keys | |
| int | null | $for_user_id | see MigratedLanguageFileSync::findUnwritableOverlayDirectories() |
Definition at line 474 of file LanguageInstallationManager.php.
References ILIAS\Language\ComponentTranslation\MigratedLanguageFileSync\findUnwritableOverlayDirectories().
Here is the call graph for this function:
|
private |
| string | $mode | either "all" or "keep_local" |
Definition at line 358 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\installLanguages().
Here is the caller graph for this function:| ILIAS\Language\Setup\LanguageInstallationManager::flushLanguageForInstallation | ( | string | $lang_key | ) |
Definition at line 345 of file LanguageInstallationManager.php.
| ILIAS\Language\Setup\LanguageInstallationManager::flushLanguageForUninstallation | ( | string | $lang_key | ) |
Definition at line 350 of file LanguageInstallationManager.php.
| ILIAS\Language\Setup\LanguageInstallationManager::getOverlaysOfUnshippedModules | ( | ) |
Modules no longer shipped for the language that still have an overlay or a taken-over record.
Only reported: once migrated again, they would win over lng_data changes made in between.
Definition at line 143 of file LanguageInstallationManager.php.
References ILIAS\Language\Setup\LanguageInstallationManager\$overlays_of_unshipped_modules.
| ILIAS\Language\Setup\LanguageInstallationManager::getSkippedDuplicateEntries | ( | ) |
Entries the insertLanguageFor...() calls left out: their identifier exists in another module or spelling (language.md rule 2).
Definition at line 122 of file LanguageInstallationManager.php.
References ILIAS\Language\Setup\LanguageInstallationManager\$skipped_duplicate_entries.
| ILIAS\Language\Setup\LanguageInstallationManager::getSkippedInvalidMarkupEntries | ( | ) |
Entries of the customizing/local files that the insertLanguageFor...() calls of this instance left out because of markup TranslationMarkupPolicy does not allow.
Definition at line 110 of file LanguageInstallationManager.php.
References ILIAS\Language\Setup\LanguageInstallationManager\$skipped_invalid_markup_entries.
| ILIAS\Language\Setup\LanguageInstallationManager::getSkippedUnreadableOverlays | ( | ) |
The migrated modules left out of the insertLanguageFor...() calls because their overlay cannot be read.
Definition at line 132 of file LanguageInstallationManager.php.
References ILIAS\Language\Setup\LanguageInstallationManager\$skipped_unreadable_overlays.
| ILIAS\Language\Setup\LanguageInstallationManager::getUnrecordedTakenOverModules | ( | ) |
Modules whose taken-over record could not be written: they are taken over again by the next run.
Definition at line 153 of file LanguageInstallationManager.php.
References ILIAS\Language\Setup\LanguageInstallationManager\$unrecorded_taken_over_modules.
|
private |
Writes the data of the given $directories/$lang_array seed; the callers above decide both.
Of a migrated module (see MigratedLanguageFileSync) whose shipped .po is merged ($merge_shipped_migrated_modules), the .lang lines of the global/component files are ignored and each shipped entry is reconciled via resolveMigratedModule(); customizing lines still apply as local changes.
Afterwards the stored module arrays are verified (collation, mantis #20046/#19140), the language cache is invalidated and each migrated overlay is synced to the final content: only the delta to the shipped .po is written, see MigratedLanguageFileSync::sync().
Concurrent writes: every migrated module that has an overlay is locked for the whole run (MigratedLanguageFileSync::withOverlayLock()). A module without overlay is not locked; if one appears meanwhile, its sync() is refused and the module reported (see $expected_overlay_exists of sync()).
| iterable<LanguageFileDirectory> | $directories | |
| array<string,array<string,string>> | $lang_array module => identifier => value | |
| bool | $keep_local_changes | whether local changes recorded only in a migrated module's overlay count as local changes (false for "remove local changes") |
| bool | $delete_unchanged_migrated_rows | delete the not locally changed lng_data rows of migrated modules that are no longer written from the shipped .po, for callers that did not flush first |
Definition at line 509 of file LanguageInstallationManager.php.
| ILIAS\Language\Setup\LanguageInstallationManager::insertLanguageForApplyingLocalChanges | ( | string | $lang_key | ) |
Applies only the customizing/local file on top of an installed language, leaving the base data untouched: the write path of "Install local" (see InstallLanguage::perform()).
The caller flushes nothing.
The seed must hold every stored entry, not only the local changes: insertLanguage() rebuilds the lng_modules row of each module from the seed plus the given directories, so a narrower seed would silently drop base entries the customizing file does not override.
Migrated modules are the exception: they are reconciled with their shipped .po as in insertLanguageForInstallation() (see resolveMigratedModule()) and seeded with their local changes only. Seeding every stored entry would turn a stale value into a permanent "local change" and lose the shipped update.
Definition at line 440 of file LanguageInstallationManager.php.
References $module, ILIAS\Language\ComponentTranslation\MigratedLanguageFileSync\findShippedModuleFiles(), and ILIAS\UI\examples\Deck\repository().
Here is the call graph for this function:| ILIAS\Language\Setup\LanguageInstallationManager::insertLanguageForInstallation | ( | string | $lang_key | ) |
Installs or refreshes a language from every directory the LanguageFileDirectoryManager knows (including customizing/local), merged on top of the recorded local changes.
A migrated module's shipped .po is the only source of its shipped values; a three-way comparison per entry decides shipped vs. local (see resolveMigratedModule()).
Definition at line 393 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\installLanguages(), and LanguageInstallationManagerMigratedSourcesAndLocksTest\testLocksAreAcquiredInSortedOrderRegardlessOfTheContributedDirectoryOrder().
Here is the caller graph for this function:| ILIAS\Language\Setup\LanguageInstallationManager::insertLanguageForRemovingLocalChanges | ( | string | $lang_key | ) |
Re-seeds a language purely from the shipped global/component files (.lang, shipped .po), without customizing/local files and local changes: the write path of "remove local changes".
insertLanguageForInstallation() would re-apply the customizing file.
Also removes the overlay of every migrated module, as no delta to the shipped .po is left (the counterpart of the caller's flush of lng_data/lng_modules).
Definition at line 414 of file LanguageInstallationManager.php.
| ILIAS\Language\Setup\LanguageInstallationManager::installLanguages | ( | array | $lang_keys, |
| array | $local_keys = [] |
||
| ) |
Installs the given languages, flushes all other known ones.
Mirrors ilSetupLanguage::installLanguages().
| list<string> | $lang_keys |
| list<string> | $local_keys unused, kept for backwards compatibility (as in ilSetupLanguage) |
Definition at line 229 of file LanguageInstallationManager.php.
References ILIAS\$db, $ilDB, ILIAS\Language\Setup\LanguageInstallationManager\flushLanguage(), ILIAS\Language\Setup\LanguageInstallationManager\insertLanguageForInstallation(), ILIAS\Language\Setup\LanguageInstallationManager\registerInstalledLanguage(), ILIAS\Language\Setup\LanguageInstallationManager\removeOverlays(), ILIAS\UI\examples\Deck\repository(), and ILIAS\Language\Setup\LanguageInstallationManager\utcTimestamp().
Here is the call graph for this function:
|
private |
Definition at line 1232 of file LanguageInstallationManager.php.
|
private |
The violations of a customizing $value, only if it changes something (see TranslationMarkupPolicy::findInvalidChangedValues()).
Definition at line 169 of file LanguageInstallationManager.php.
References ILIAS\Language\Setup\LanguageInstallationManager\markupPolicy().
Here is the call graph for this function:
|
private |
Definition at line 1137 of file LanguageInstallationManager.php.
References $module.
|
private |
The overlay state of a migrated module, or null.
An unreadable overlay is reported and treated as absent, so it cannot abort a reinstall whose data was already flushed; sync() rewrites it afterwards. Returns only the delta (see MigratedLanguageFileSync::loadLocalChanges()), the rest carries the shipped value.
An entry "merge" took over into the shipped .po (see LocalChangeComments::isMergedIntoShipped()) gets its own value as "original", so a newer shipped value wins in resolveMigratedModule() instead of the taken-over value staying a local change.
Definition at line 1165 of file LanguageInstallationManager.php.
References $module.
|
private |
Definition at line 91 of file LanguageInstallationManager.php.
References $message, and ILIAS\Repository\logger().
Here is the call graph for this function:
|
private |
Definition at line 158 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\invalidMarkupOfCustomizingValue().
Here is the caller graph for this function:
|
private |
lng_data.local_change of every locally changed entry of $modules in $lang_key (as written by this run), module => identifier => database timestamp - for the overlay, see MigratedLanguageFileSync::sync().
| list<string> | $modules |
Definition at line 1364 of file LanguageInstallationManager.php.
References $ilDB.
|
private |
The remarks of every migrated module (identifier => remark; a plural message under its identifier): lng_data, overridden by the overlay, overridden by the customizing file.
A module whose overlay cannot be read is left out, so its sync() keeps the overlay's remarks.
Before the migration lng_data.remarks held the shipped "###" comment of the .lang line: a lng_data remark is only taken over if it differs from that comment ($shipped_line_comments), from the note of the shipped .po and is no dated "new variable" marker, i.e. an administrator's remark.
| array<string,array<string,string>> | $shipped_migrated_modules |
| array<string,array<string,string>> | $customized_remarks |
| array<string,array<string,string>> | $shipped_line_comments module => identifier => "###" comment of the shipped .lang lines |
| list<string> | $overlay_only_modules their lng_data remarks are not read, see insertLanguage() |
Definition at line 1258 of file LanguageInstallationManager.php.
| ILIAS\Language\Setup\LanguageInstallationManager::registerInstalledLanguage | ( | string | $lang_key, |
| array | $known_languages, | ||
| array | $local_language_keys | ||
| ) |
Registers or updates the object_data row of a (re-)inserted language ("installed" vs.
"installed_local"); single place for this bookkeeping of installLanguages() and InstallLanguage::perform().
| array<string,array{obj_id:int,status:string}> | $known_languages result of InstalledLanguageRepository::getAvailableLanguages() |
| list<string> | $local_language_keys result of InstalledLanguageRepository::getLocalLanguages() |
Definition at line 283 of file LanguageInstallationManager.php.
References ILIAS\$db.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\installLanguages().
Here is the caller graph for this function:
|
private |
The overlay counterpart of flushLanguage($lang_key, "all") for a language that is no longer installed - see ilObjLanguage::uninstall().
A failure is logged and does not undo the flush.
Definition at line 321 of file LanguageInstallationManager.php.
References $module, ILIAS\Language\ComponentTranslation\MigratedLanguageFileSync\forgetLocalChangesTakenOver(), and ILIAS\Language\ComponentTranslation\MigratedLanguageFileSync\removeOverlay().
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\installLanguages().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
The shipped/local decision for one migrated module: a three-way comparison per shipped entry between L = the local value (.
$local_entries: lng_data, customizing/local file or, with $overlay, the overlay), O = the shipped value the overlay tracked the entry against ("original"), and S = the value the shipped .po carries now:
A value from the customizing file ($customized) always stays local. Overlay entries that are neither shipped nor local are dropped. A local entry without shipped counterpart (removed from the .po or added locally) is dropped if L === O (via $delete_row; it only carries its last shipped value), otherwise or if O is unknown kept as a local change. The legacy .lang update treats a removed key alike.
| array<string,string> | $local_entries identifier => value |
| array<string,true> | $customized identifiers that came from the customizing/local file |
| array<string,string> | $shipped_entries identifier => shipped value |
| array<string,array{value | string, local_change: bool, local_change_date: ?string, original: ?string}> $overlay |
Closure(string, string, ?string):void $write_row persists one lng_data row
Closure(string):void $delete_row removes one lng_data row (after all rows were written)
Definition at line 1090 of file LanguageInstallationManager.php.
|
private |
| array<string,array<string,string>> | $lang_array |
| array<string,bool|null> | $expected_overlays module => $expected_overlay_exists of MigratedLanguageFileSync::sync() |
| array<string,array<string,string>|null> | $remarks module => $remarks of MigratedLanguageFileSync::sync() (null/missing: keep the overlay's remarks) |
| array<string,array<string,string>> | $local_change_dates module => $local_change_dates of MigratedLanguageFileSync::sync() |
Definition at line 1395 of file LanguageInstallationManager.php.
References $module.
|
private |
Definition at line 213 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\installLanguages().
Here is the caller graph for this function:
|
private |
insertLanguage() once the overlays of $locked_modules are locked.
| iterable<LanguageFileDirectory> | $directories |
| array<string,array<string,string>> | $lang_array |
| array<string,array<string,string>> | $shipped_migrated_modules |
| list<string> | $locked_modules |
| list<string> | $overlay_only_modules migrated modules whose lng_data rows are never read |
| list<string> | $skipped_modules migrated modules of which nothing is written |
Definition at line 672 of file LanguageInstallationManager.php.
|
private |
Definition at line 71 of file LanguageInstallationManager.php.
|
private |
Definition at line 65 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\getOverlaysOfUnshippedModules().
|
private |
Definition at line 55 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\getSkippedDuplicateEntries().
|
private |
Definition at line 50 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\getSkippedInvalidMarkupEntries().
|
private |
Definition at line 60 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\getSkippedUnreadableOverlays().
|
private |
Definition at line 70 of file LanguageInstallationManager.php.
Referenced by ILIAS\Language\Setup\LanguageInstallationManager\getUnrecordedTakenOverModules().
|
private |
Definition at line 45 of file LanguageInstallationManager.php.
|
private |
Definition at line 44 of file LanguageInstallationManager.php.