Updated update.php towards code style
using php code sniffer
This commit is contained in:
parent
09e44caf71
commit
e157859dfb
1 changed files with 68 additions and 45 deletions
113
update.php
113
update.php
|
@ -37,30 +37,35 @@ 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(
|
||||||
DBA::escape($profile["about"]),
|
"UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
|
||||||
DBA::escape($profile["locality"]),
|
DBA::escape($profile["about"]),
|
||||||
DBA::escape($profile["pub_keywords"]),
|
DBA::escape($profile["locality"]),
|
||||||
DBA::escape($profile["gender"]),
|
DBA::escape($profile["pub_keywords"]),
|
||||||
intval($profile["uid"])
|
DBA::escape($profile["gender"]),
|
||||||
);
|
intval($profile["uid"])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_1179() {
|
function update_1179()
|
||||||
if (Config::get('system','no_community_page'))
|
{
|
||||||
Config::set('system','community_page_style', CP_NO_COMMUNITY_PAGE);
|
if (Config::get('system', '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,18 +82,20 @@ 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'))) {
|
||||||
Config::set('system','directory', dirname(Config::get('system','directory_submit_url')));
|
Config::set('system', 'directory', dirname(Config::get('system', 'directory_submit_url')));
|
||||||
Config::delete('system','directory_submit_url');
|
Config::delete('system', 'directory_submit_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
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')) {
|
||||||
|
@ -96,22 +104,23 @@ function update_1191() {
|
||||||
$addons_arr = [];
|
$addons_arr = [];
|
||||||
|
|
||||||
if ($addons) {
|
if ($addons) {
|
||||||
$addons_arr = explode(",",str_replace(" ", "", $addons));
|
$addons_arr = explode(",", str_replace(" ", "", $addons));
|
||||||
|
|
||||||
$idx = array_search($addon, $addons_arr);
|
$idx = array_search($addon, $addons_arr);
|
||||||
if ($idx !== false){
|
if ($idx !== false) {
|
||||||
unset($addons_arr[$idx]);
|
unset($addons_arr[$idx]);
|
||||||
//delete forumlist manually from addon and hook table
|
//delete forumlist manually from addon and hook table
|
||||||
// since Addon::uninstall() don't work here
|
// since Addon::uninstall() don't work here
|
||||||
q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
|
q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
|
||||||
q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
|
q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
|
||||||
Config::set('system','addon', implode(", ", $addons_arr));
|
Config::set('system', 'addon', implode(", ", $addons_arr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,21 +132,24 @@ 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,18 +159,24 @@ 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$"']);
|
||||||
|
|
||||||
// All legacy hashes are re-hashed using the new secure hashing function
|
// All legacy hashes are re-hashed using the new secure hashing function
|
||||||
$stmt = DBA::select('user', ['uid', 'password'], ['legacy_password' => true]);
|
$stmt = DBA::select('user', ['uid', 'password'], ['legacy_password' => true]);
|
||||||
while($user = DBA::fetch($stmt)) {
|
while ($user = DBA::fetch($stmt)) {
|
||||||
DBA::update('user', ['password' => User::hashPassword($user['password'])], ['uid' => $user['uid']]);
|
DBA::update('user', ['password' => User::hashPassword($user['password'])], ['uid' => $user['uid']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 = [];
|
||||||
|
|
||||||
|
@ -303,4 +326,4 @@ function update_1293()
|
||||||
|
|
||||||
Logger::log("Gender fix completed. Success: $success. Fail: $fail");
|
Logger::log("Gender fix completed. Success: $success. Fail: $fail");
|
||||||
return Update::SUCCESS;
|
return Update::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue