Updated update.php towards code style

using php code sniffer
This commit is contained in:
Jeroen De Meerleer 2018-12-21 10:36:01 +01:00 committed by Hypolite Petovan
parent 09e44caf71
commit e157859dfb
1 changed files with 68 additions and 45 deletions

View File

@ -37,18 +37,21 @@ use Friendica\Util\DateTimeFormat;
* If you need to run a script before the database update, name the function "pre_update_4712()" * If you need to run a script before the database update, name the function "pre_update_4712()"
*/ */
function update_1178() { function update_1178()
{
require_once 'mod/profiles.php'; require_once 'mod/profiles.php';
$profiles = q("SELECT `uid`, `about`, `locality`, `pub_keywords`, `gender` FROM `profile` WHERE `is-default`"); $profiles = q("SELECT `uid`, `about`, `locality`, `pub_keywords`, `gender` FROM `profile` WHERE `is-default`");
foreach ($profiles AS $profile) { foreach ($profiles as $profile) {
if ($profile["about"].$profile["locality"].$profile["pub_keywords"].$profile["gender"] == "") if ($profile["about"].$profile["locality"].$profile["pub_keywords"].$profile["gender"] == "") {
continue; continue;
}
$profile["pub_keywords"] = profile_clean_keywords($profile["pub_keywords"]); $profile["pub_keywords"] = profile_clean_keywords($profile["pub_keywords"]);
$r = q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d", $r = q(
"UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
DBA::escape($profile["about"]), DBA::escape($profile["about"]),
DBA::escape($profile["locality"]), DBA::escape($profile["locality"]),
DBA::escape($profile["pub_keywords"]), DBA::escape($profile["pub_keywords"]),
@ -58,9 +61,11 @@ function update_1178() {
} }
} }
function update_1179() { function update_1179()
if (Config::get('system','no_community_page')) {
if (Config::get('system', 'no_community_page')) {
Config::set('system', 'community_page_style', CP_NO_COMMUNITY_PAGE); Config::set('system', 'community_page_style', CP_NO_COMMUNITY_PAGE);
}
// Update the central item storage with uid=0 // Update the central item storage with uid=0
Worker::add(PRIORITY_LOW, "threadupdate"); Worker::add(PRIORITY_LOW, "threadupdate");
@ -68,7 +73,8 @@ function update_1179() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1181() { function update_1181()
{
// Fill the new fields in the term table. // Fill the new fields in the term table.
Worker::add(PRIORITY_LOW, "TagUpdate"); Worker::add(PRIORITY_LOW, "TagUpdate");
@ -76,7 +82,8 @@ function update_1181() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1189() { function update_1189()
{
if (strlen(Config::get('system', 'directory_submit_url')) && if (strlen(Config::get('system', 'directory_submit_url')) &&
!strlen(Config::get('system', 'directory'))) { !strlen(Config::get('system', 'directory'))) {
@ -87,7 +94,8 @@ function update_1189() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1191() { function update_1191()
{
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
if (Addon::isEnabled('forumlist')) { if (Addon::isEnabled('forumlist')) {
@ -111,7 +119,8 @@ function update_1191() {
} }
// select old formlist addon entries // select old formlist addon entries
$r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ", $r = q(
"SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
DBA::escape('forumlist') DBA::escape('forumlist')
); );
@ -123,19 +132,22 @@ function update_1191() {
$key = $rr['k']; $key = $rr['k'];
$value = $rr['v']; $value = $rr['v'];
if ($key === 'randomise') if ($key === 'randomise') {
PConfig::delete($uid, $family, $key); PConfig::delete($uid, $family, $key);
}
if ($key === 'show_on_profile') { if ($key === 'show_on_profile') {
if ($value) if ($value) {
PConfig::set($uid, feature, forumlist_profile, $value); PConfig::set($uid, feature, forumlist_profile, $value);
}
PConfig::delete($uid, $family, $key); PConfig::delete($uid, $family, $key);
} }
if ($key === 'show_on_network') { if ($key === 'show_on_network') {
if ($value) if ($value) {
PConfig::set($uid, feature, forumlist_widget, $value); PConfig::set($uid, feature, forumlist_widget, $value);
}
PConfig::delete($uid, $family, $key); PConfig::delete($uid, $family, $key);
} }
@ -147,12 +159,18 @@ function update_1191() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1203() { function update_1203()
$r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)", {
DBA::escape(Contact::ACCOUNT_TYPE_COMMUNITY), DBA::escape(Contact::PAGE_COMMUNITY), DBA::escape(Contact::PAGE_PRVGROUP)); $r = q(
"UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
DBA::escape(Contact::ACCOUNT_TYPE_COMMUNITY),
DBA::escape(Contact::PAGE_COMMUNITY),
DBA::escape(Contact::PAGE_PRVGROUP)
);
} }
function update_1244() { function update_1244()
{
// Sets legacy_password for all legacy hashes // Sets legacy_password for all legacy hashes
DBA::update('user', ['legacy_password' => true], ['SUBSTR(password, 1, 4) != "$2y$"']); DBA::update('user', ['legacy_password' => true], ['SUBSTR(password, 1, 4) != "$2y$"']);
@ -168,7 +186,8 @@ function update_1244() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1245() { function update_1245()
{
$rino = Config::get('system', 'rino_encrypt'); $rino = Config::get('system', 'rino_encrypt');
if (!$rino) { if (!$rino) {
@ -180,7 +199,8 @@ function update_1245() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1247() { function update_1247()
{
// Removing hooks with the old name // Removing hooks with the old name
DBA::e("DELETE FROM `hook` DBA::e("DELETE FROM `hook`
WHERE `hook` LIKE 'plugin_%'"); WHERE `hook` LIKE 'plugin_%'");
@ -189,7 +209,8 @@ WHERE `hook` LIKE 'plugin_%'");
Addon::reload(); Addon::reload();
} }
function update_1260() { function update_1260()
{
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t('%s: Updating author-id and owner-id in item and thread table. ', DateTimeFormat::utcNow().' '.date('e'))); Config::set('system', 'maintenance_reason', L10n::t('%s: Updating author-id and owner-id in item and thread table. ', DateTimeFormat::utcNow().' '.date('e')));
@ -229,13 +250,15 @@ function update_1260() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1261() { function update_1261()
{
// This fixes the results of an issue in the develop branch of 2018-05. // This fixes the results of an issue in the develop branch of 2018-05.
DBA::update('contact', ['blocked' => false, 'pending' => false], ['uid' => 0, 'blocked' => true, 'pending' => true]); DBA::update('contact', ['blocked' => false, 'pending' => false], ['uid' => 0, 'blocked' => true, 'pending' => true]);
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1278() { function update_1278()
{
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t('%s: Updating post-type.', DateTimeFormat::utcNow().' '.date('e'))); Config::set('system', 'maintenance_reason', L10n::t('%s: Updating post-type.', DateTimeFormat::utcNow().' '.date('e')));
@ -247,7 +270,8 @@ function update_1278() {
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1288() { function update_1288()
{
// Updates missing `uri-id` values // Updates missing `uri-id` values
DBA::e("UPDATE `item-activity` INNER JOIN `item` ON `item`.`iaid` = `item-activity`.`id` SET `item-activity`.`uri-id` = `item`.`uri-id` WHERE `item-activity`.`uri-id` IS NULL OR `item-activity`.`uri-id` = 0"); DBA::e("UPDATE `item-activity` INNER JOIN `item` ON `item`.`iaid` = `item-activity`.`id` SET `item-activity`.`uri-id` = `item`.`uri-id` WHERE `item-activity`.`uri-id` IS NULL OR `item-activity`.`uri-id` = 0");
@ -267,7 +291,6 @@ function update_1293()
foreach ($allGenders as $key => $gender) { foreach ($allGenders as $key => $gender) {
if ($gender['gender'] != '') { if ($gender['gender'] != '') {
foreach ($allLangs as $key => $lang) { foreach ($allLangs as $key => $lang) {
$a = new \stdClass(); $a = new \stdClass();
$a->strings = []; $a->strings = [];