mirror of
https://github.com/friendica/friendica
synced 2024-11-17 16:23:46 +00:00
Updated towards code review
This commit is contained in:
parent
b2211d31b9
commit
ff180fb0f1
2 changed files with 46 additions and 46 deletions
|
@ -7,7 +7,6 @@ namespace Friendica\Database;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemURI;
|
||||
|
@ -374,49 +373,4 @@ class PostUpdate
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
|
46
update.php
46
update.php
|
@ -254,3 +254,49 @@ function update_1288() {
|
|||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// Post-update script of PR 5751
|
||||
function update_1293() {
|
||||
$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");
|
||||
return Update::SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue