Browse Source

4 spaces to tab

pull/6482/head
Jeroen De Meerleer 2 years ago
committed by Hypolite Petovan
parent
commit
a224308d42
1 changed files with 42 additions and 42 deletions
  1. +42
    -42
      src/Database/PostUpdate.php

+ 42
- 42
src/Database/PostUpdate.php View File

@ -377,46 +377,46 @@ class PostUpdate
// Post-update script of PR 5596
function fixGenderStrings() {
$allGenders = DBA::select('contact', ['id', 'gender']);
$allLangs = L10n::getAvailableLanguages();
$success = 0;
$fail = 0;
foreach($allGenders as $key=>$gender) {
foreach($allLangs as $key=>$lang) {
$a = new \stdClass();
$a->strings = [];
// First we get the the localizations
if (file_exists("view/lang/$lang/strings.php")) {
include "view/lang/$lang/strings.php";
}
if (file_exists("addon/morechoice/lang/$lang/strings.php")) {
include "addon/morechoice/lang/$lang/strings.php";
}
$localizedStrings = $a->strings;
unset($a);
$key = array_search($gender['gender'], $localizedStrings);
if($key !== false) {
break;
}
// defaulting to empty string
$key = '';
}
DBA::update('contact', ['gender' => $key], ['id' => $gender['id']]);
logger::log('Updated contact ' . $gender['id'] . ' to gender ' . $key . ' (was: ' . $gender['gender'] . ')');
if ($key == '') {
$fail++;
}
else {
$success++;
}
}
Logger::log("Gender fix completed. Success: $success. Fail: $fail");
}
$allGenders = DBA::select('contact', ['id', 'gender']);
$allLangs = L10n::getAvailableLanguages();
$success = 0;
$fail = 0;
foreach($allGenders as $key=>$gender) {
foreach($allLangs as $key=>$lang) {
$a = new \stdClass();
$a->strings = [];
// First we get the the localizations
if (file_exists("view/lang/$lang/strings.php")) {
include "view/lang/$lang/strings.php";
}
if (file_exists("addon/morechoice/lang/$lang/strings.php")) {
include "addon/morechoice/lang/$lang/strings.php";
}
$localizedStrings = $a->strings;
unset($a);
$key = array_search($gender['gender'], $localizedStrings);
if($key !== false) {
break;
}
// defaulting to empty string
$key = '';
}
DBA::update('contact', ['gender' => $key], ['id' => $gender['id']]);
logger::log('Updated contact ' . $gender['id'] . ' to gender ' . $key . ' (was: ' . $gender['gender'] . ')');
if ($key == '') {
$fail++;
}
else {
$success++;
}
}
Logger::log("Gender fix completed. Success: $success. Fail: $fail");
}
}

Loading…
Cancel
Save