1
0
Fork 0

Merge pull request #11689 from Quix0r/rewrites/double-quotes-single

Changed more double-quotes to single
This commit is contained in:
Hypolite Petovan 2022-06-25 12:02:01 -04:00 committed by GitHub
commit 3c70d592f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 99 additions and 63 deletions

View file

@ -26,7 +26,7 @@
* This script was taken from http://php.net/manual/en/function.pcntl-fork.php * This script was taken from http://php.net/manual/en/function.pcntl-fork.php
*/ */
if (php_sapi_name() !== 'cli') { if (php_sapi_name() !== 'cli') {
header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden'); header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit(); exit();
} }
@ -45,13 +45,13 @@ $longopts = ['foreground'];
$options = getopt($shortopts, $longopts); $options = getopt($shortopts, $longopts);
// Ensure that daemon.php is executed from the base path of the installation // Ensure that daemon.php is executed from the base path of the installation
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) { if (!file_exists('boot.php') && (sizeof($_SERVER['argv']) != 0)) {
$directory = dirname($_SERVER["argv"][0]); $directory = dirname($_SERVER['argv'][0]);
if (substr($directory, 0, 1) != "/") { if (substr($directory, 0, 1) != '/') {
$directory = $_SERVER["PWD"] . "/" . $directory; $directory = $_SERVER['PWD'] . '/' . $directory;
} }
$directory = realpath($directory . "/.."); $directory = realpath($directory . '/..');
chdir($directory); chdir($directory);
} }
@ -86,16 +86,16 @@ TXT
$pidfile = DI::config()->get('system', 'pidfile'); $pidfile = DI::config()->get('system', 'pidfile');
if (in_array("start", $_SERVER["argv"])) { if (in_array('start', $_SERVER['argv'])) {
$mode = "start"; $mode = 'start';
} }
if (in_array("stop", $_SERVER["argv"])) { if (in_array('stop', $_SERVER['argv'])) {
$mode = "stop"; $mode = 'stop';
} }
if (in_array("status", $_SERVER["argv"])) { if (in_array('status', $_SERVER['argv'])) {
$mode = "status"; $mode = 'status';
} }
$foreground = array_key_exists('f', $options) || array_key_exists('foreground', $options); $foreground = array_key_exists('f', $options) || array_key_exists('foreground', $options);
@ -104,7 +104,7 @@ if (!isset($mode)) {
die("Please use either 'start', 'stop' or 'status'.\n"); die("Please use either 'start', 'stop' or 'status'.\n");
} }
if (empty($_SERVER["argv"][0])) { if (empty($_SERVER['argv'][0])) {
die("Unexpected script behaviour. This message should never occur.\n"); die("Unexpected script behaviour. This message should never occur.\n");
} }
@ -114,12 +114,12 @@ if (is_readable($pidfile)) {
$pid = intval(file_get_contents($pidfile)); $pid = intval(file_get_contents($pidfile));
} }
if (empty($pid) && in_array($mode, ["stop", "status"])) { if (empty($pid) && in_array($mode, ['stop', 'status'])) {
DI::config()->set('system', 'worker_daemon_mode', false); DI::config()->set('system', 'worker_daemon_mode', false);
die("Pidfile wasn't found. Is the daemon running?\n"); die("Pidfile wasn't found. Is the daemon running?\n");
} }
if ($mode == "status") { if ($mode == 'status') {
if (posix_kill($pid, 0)) { if (posix_kill($pid, 0)) {
die("Daemon process $pid is running.\n"); die("Daemon process $pid is running.\n");
} }
@ -130,12 +130,12 @@ if ($mode == "status") {
die("Daemon process $pid isn't running.\n"); die("Daemon process $pid isn't running.\n");
} }
if ($mode == "stop") { if ($mode == 'stop') {
posix_kill($pid, SIGTERM); posix_kill($pid, SIGTERM);
unlink($pidfile); unlink($pidfile);
Logger::notice("Worker daemon process was killed", ["pid" => $pid]); Logger::notice('Worker daemon process was killed', ['pid' => $pid]);
DI::config()->set('system', 'worker_daemon_mode', false); DI::config()->set('system', 'worker_daemon_mode', false);
die("Worker daemon process $pid was killed.\n"); die("Worker daemon process $pid was killed.\n");
@ -145,7 +145,7 @@ if (!empty($pid) && posix_kill($pid, 0)) {
die("Daemon process $pid is already running.\n"); die("Daemon process $pid is already running.\n");
} }
Logger::notice('Starting worker daemon.', ["pid" => $pid]); Logger::notice('Starting worker daemon.', ['pid' => $pid]);
if (!$foreground) { if (!$foreground) {
echo "Starting worker daemon.\n"; echo "Starting worker daemon.\n";
@ -194,7 +194,7 @@ $last_cron = 0;
// Now running as a daemon. // Now running as a daemon.
while (true) { while (true) {
if (!$do_cron && ($last_cron + $wait_interval) < time()) { if (!$do_cron && ($last_cron + $wait_interval) < time()) {
Logger::info('Forcing cron worker call.', ["pid" => $pid]); Logger::info('Forcing cron worker call.', ['pid' => $pid]);
$do_cron = true; $do_cron = true;
} }
@ -214,7 +214,7 @@ while (true) {
} }
$start = time(); $start = time();
Logger::info("Sleeping", ["pid" => $pid, 'until' => gmdate(DateTimeFormat::MYSQL, $start + $wait_interval)]); Logger::info('Sleeping', ['pid' => $pid, 'until' => gmdate(DateTimeFormat::MYSQL, $start + $wait_interval)]);
do { do {
$seconds = (time() - $start); $seconds = (time() - $start);
@ -236,10 +236,10 @@ while (true) {
if ($timeout) { if ($timeout) {
$do_cron = true; $do_cron = true;
Logger::info("Woke up after $wait_interval seconds.", ["pid" => $pid, 'sleep' => $wait_interval]); Logger::info('Woke up after $wait_interval seconds.', ['pid' => $pid, 'sleep' => $wait_interval]);
} else { } else {
$do_cron = false; $do_cron = false;
Logger::info("Worker jobs are calling to be forked.", ["pid" => $pid]); Logger::info('Worker jobs are calling to be forked.', ['pid' => $pid]);
} }
} }

View file

@ -439,8 +439,13 @@ function item_post(App $a) {
// Ensure to only modify attachments that you own // Ensure to only modify attachments that you own
$srch = '<' . intval($contact_id) . '>'; $srch = '<' . intval($contact_id) . '>';
$condition = ['allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', $condition = [
'id' => $attach]; 'allow_cid' => $srch,
'allow_gid' => '',
'deny_cid' => '',
'deny_gid' => '',
'id' => $attach,
];
if (!Attach::exists($condition)) { if (!Attach::exists($condition)) {
continue; continue;
} }

View file

@ -614,9 +614,9 @@ class App
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !local_user()) { if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !local_user()) {
// Only continue when the given profile link seems valid // Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters // Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") && if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) { strstr(parse_url($_GET['zrl'], PHP_URL_PATH), '/profile/')) {
if (Core\Session::get('visitor_home') != $_GET["zrl"]) { if (Core\Session::get('visitor_home') != $_GET['zrl']) {
Core\Session::set('my_url', $_GET['zrl']); Core\Session::set('my_url', $_GET['zrl']);
Core\Session::set('authenticated', 0); Core\Session::set('authenticated', 0);

View file

@ -825,6 +825,7 @@ class Database
* *
* @return boolean Are there rows for that condition? * @return boolean Are there rows for that condition?
* @throws \Exception * @throws \Exception
* @todo Please unwrap the DBStructure::existsTable() call so this method has one behavior only: checking existence on records
*/ */
public function exists(string $table, array $condition): bool public function exists(string $table, array $condition): bool
{ {
@ -1719,29 +1720,29 @@ class Database
*/ */
public function processlist(): array public function processlist(): array
{ {
$ret = $this->p("SHOW PROCESSLIST"); $ret = $this->p('SHOW PROCESSLIST');
$data = $this->toArray($ret); $data = $this->toArray($ret);
$processes = 0; $processes = 0;
$states = []; $states = [];
foreach ($data as $process) { foreach ($data as $process) {
$state = trim($process["State"]); $state = trim($process['State']);
// Filter out all non blocking processes // Filter out all non blocking processes
if (!in_array($state, ["", "init", "statistics", "updating"])) { if (!in_array($state, ['', 'init', 'statistics', 'updating'])) {
++$states[$state]; ++$states[$state];
++$processes; ++$processes;
} }
} }
$statelist = ""; $statelist = '';
foreach ($states as $state => $usage) { foreach ($states as $state => $usage) {
if ($statelist != "") { if ($statelist != '') {
$statelist .= ", "; $statelist .= ', ';
} }
$statelist .= $state . ": " . $usage; $statelist .= $state . ': ' . $usage;
} }
return (["list" => $statelist, "amount" => $processes]); return (['list' => $statelist, 'amount' => $processes]);
} }
/** /**

View file

@ -2312,6 +2312,8 @@ class Contact
} }
/** /**
* Updates contact record by provided id and optional network
*
* @param integer $id contact id * @param integer $id contact id
* @param string $network Optional network we are probing for * @param string $network Optional network we are probing for
* @return boolean * @return boolean
@ -2335,13 +2337,15 @@ class Contact
} }
/** /**
* Updates contact record by provided id and probed data
*
* @param integer $id contact id * @param integer $id contact id
* @param array $ret Probed data * @param array $ret Probed data
* @return boolean * @return boolean
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function updateFromProbeArray(int $id, array $ret) private static function updateFromProbeArray(int $id, array $ret): bool
{ {
/* /*
Warning: Never ever fetch the public key via Probe::uri and write it into the contacts. Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
@ -2552,12 +2556,14 @@ class Contact
} }
/** /**
* Updates contact record by provided URL
*
* @param integer $url contact url * @param integer $url contact url
* @return integer Contact id * @return integer Contact id
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function updateFromProbeByURL($url) public static function updateFromProbeByURL(string $url): int
{ {
$id = self::getIdForURL($url); $id = self::getIdForURL($url);
@ -2578,7 +2584,7 @@ class Contact
* @param string $network Network of that contact * @param string $network Network of that contact
* @return string with protocol * @return string with protocol
*/ */
public static function getProtocol($url, $network) public static function getProtocol(string $url, string $network): string
{ {
if ($network != Protocol::DFRN) { if ($network != Protocol::DFRN) {
return $network; return $network;
@ -2945,6 +2951,7 @@ class Contact
* Update the local relationship when a local user loses a follower * Update the local relationship when a local user loses a follower
* *
* @param array $contact User-specific contact (uid != 0) array * @param array $contact User-specific contact (uid != 0) array
* @return void
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */

View file

@ -103,17 +103,27 @@ class FContact
$posts = Post::countPosts(['author-id' => $contact['id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]); $posts = Post::countPosts(['author-id' => $contact['id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]);
} }
$fields = ['name' => $arr["name"], 'photo' => $arr["photo"], $fields = [
'request' => $arr["request"], 'nick' => $arr["nick"], 'name' => $arr['name'],
'addr' => strtolower($arr["addr"]), 'guid' => $arr["guid"], 'photo' => $arr['photo'],
'batch' => $arr["batch"], 'notify' => $arr["notify"], 'request' => $arr['request'],
'poll' => $arr["poll"], 'confirm' => $arr["confirm"], 'nick' => $arr['nick'],
'alias' => $arr["alias"], 'pubkey' => $arr["pubkey"], 'addr' => strtolower($arr['addr']),
'uri-id' => $uriid, 'interacting_count' => $interacting ?? 0, 'guid' => $arr['guid'],
'interacted_count' => $interacted ?? 0, 'post_count' => $posts ?? 0, 'batch' => $arr['batch'],
'updated' => DateTimeFormat::utcNow()]; 'notify' => $arr['notify'],
'poll' => $arr['poll'],
'confirm' => $arr['confirm'],
'alias' => $arr['alias'],
'pubkey' => $arr['pubkey'],
'uri-id' => $uriid,
'interacting_count' => $interacting ?? 0,
'interacted_count' => $interacted ?? 0,
'post_count' => $posts ?? 0,
'updated' => DateTimeFormat::utcNow(),
];
$condition = ['url' => $arr["url"], 'network' => $arr["network"]]; $condition = ['url' => $arr['url'], 'network' => $arr['network']];
DBA::update('fcontact', $fields, $condition, true); DBA::update('fcontact', $fields, $condition, true);
} }
@ -123,7 +133,6 @@ class FContact
* fcontact guid * fcontact guid
* *
* @param string $fcontact_guid Hexadecimal string guid * @param string $fcontact_guid Hexadecimal string guid
*
* @return string|null the contact url or null * @return string|null the contact url or null
* @throws \Exception * @throws \Exception
*/ */

View file

@ -475,7 +475,10 @@ class Profile extends BaseModule
} }
/** /**
* Updates contact from probing
*
* @param int $contact_id Id of the contact with uid != 0 * @param int $contact_id Id of the contact with uid != 0
* @return void
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */

View file

@ -1547,6 +1547,7 @@ class Processor
* Switches a contact to AP if needed * Switches a contact to AP if needed
* *
* @param integer $cid Contact ID * @param integer $cid Contact ID
* @return void
* @throws \Exception * @throws \Exception
*/ */
private static function switchContact(int $cid) private static function switchContact(int $cid)

View file

@ -1087,6 +1087,7 @@ class Receiver
* @param integer $cid Contact ID * @param integer $cid Contact ID
* @param integer $uid User ID * @param integer $uid User ID
* @param string $url Profile URL * @param string $url Profile URL
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
@ -1113,6 +1114,7 @@ class Receiver
* *
* @param $receivers * @param $receivers
* @param $actor * @param $actor
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */

View file

@ -916,7 +916,13 @@ class Transmitter
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS]; $networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
} }
$condition = ['uid' => $uid, 'archive' => false, 'pending' => false, 'blocked' => false, 'network' => Protocol::FEDERATED]; $condition = [
'uid' => $uid,
'archive' => false,
'pending' => false,
'blocked' => false,
'network' => Protocol::FEDERATED,
];
if (!empty($uid)) { if (!empty($uid)) {
$condition['rel'] = [Contact::FOLLOWER, Contact::FRIEND]; $condition['rel'] = [Contact::FOLLOWER, Contact::FRIEND];

View file

@ -55,7 +55,7 @@ class ReversedFileReader implements \Iterator
* @param string $filename File to open * @param string $filename File to open
* @return $this * @return $this
*/ */
public function open(string $filename) public function open(string $filename): ReversedFileReader
{ {
$this->fh = fopen($filename, 'r'); $this->fh = fopen($filename, 'r');
if (!$this->fh) { if (!$this->fh) {
@ -73,9 +73,10 @@ class ReversedFileReader implements \Iterator
/** /**
* Read $size bytes behind last position * Read $size bytes behind last position
* *
* @param int $size
* @return string * @return string
*/ */
private function _read($size) private function _read(int $size): string
{ {
$this->pos -= $size; $this->pos -= $size;
fseek($this->fh, $this->pos); fseek($this->fh, $this->pos);
@ -86,7 +87,7 @@ class ReversedFileReader implements \Iterator
* Read next line from end of file * Read next line from end of file
* Return null if no lines are left to read * Return null if no lines are left to read
* *
* @return ?string * @return string|null Depending on data being buffered
*/ */
private function _readline() private function _readline()
{ {
@ -140,7 +141,7 @@ class ReversedFileReader implements \Iterator
* @see Iterator::key() * @see Iterator::key()
* @return int * @return int
*/ */
public function key() public function key(): int
{ {
return $this->key; return $this->key;
} }
@ -151,7 +152,7 @@ class ReversedFileReader implements \Iterator
* @see Iterator::current() * @see Iterator::current()
* @return string * @return string
*/ */
public function current() public function current(): string
{ {
return $this->value; return $this->value;
} }
@ -162,7 +163,7 @@ class ReversedFileReader implements \Iterator
* @see Iterator::valid() * @see Iterator::valid()
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
return ! is_null($this->value); return ! is_null($this->value);
} }

View file

@ -41,11 +41,11 @@ use Friendica\Util\Strings;
class OnePoll class OnePoll
{ {
public static function execute($contact_id = 0, $command = '') public static function execute(int $contact_id = 0, string $command = '')
{ {
Logger::notice('Start polling/probing contact', ['id' => $contact_id]); Logger::notice('Start polling/probing contact', ['id' => $contact_id]);
$force = ($command == "force"); $force = ($command == 'force');
if (empty($contact_id)) { if (empty($contact_id)) {
Logger::notice('no contact provided'); Logger::notice('no contact provided');
@ -118,6 +118,7 @@ class OnePoll
* *
* @param array $contact The personal contact entry * @param array $contact The personal contact entry
* @param array $fields The fields that are updated * @param array $fields The fields that are updated
* @return void
* @throws \Exception * @throws \Exception
*/ */
private static function updateContact(array $contact, array $fields) private static function updateContact(array $contact, array $fields)