From d7d6a43655734a1ebeb0d70481452447baf5a80e Mon Sep 17 00:00:00 2001
From: Art4
Date: Tue, 26 Nov 2024 07:55:01 +0000
Subject: [PATCH 01/34] Add checks for CLD2Detector ans CLD2Encoding classes
---
cld/cld.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/cld/cld.php b/cld/cld.php
index 5ca4c932..83361e2b 100644
--- a/cld/cld.php
+++ b/cld/cld.php
@@ -22,6 +22,16 @@ function cld_detect_languages(array &$data)
return;
}
+ if (!class_exists('CLD2Detector')) {
+ Logger::warning('CLD2Detector class does not exist.');
+ return;
+ }
+
+ if (!class_exists('CLD2Encoding')) {
+ Logger::warning('CLD2Encoding class does not exist.');
+ return;
+ }
+
$cld2 = new \CLD2Detector();
$cld2->setEncodingHint(CLD2Encoding::UTF8); // optional, hints about text encoding
From fc0dda0cd9b607dc8d87f73644108f922f6bb1e1 Mon Sep 17 00:00:00 2001
From: Art4
Date: Tue, 26 Nov 2024 08:23:27 +0000
Subject: [PATCH 02/34] refactor convert addon, replace each() calls with
foreach loop
---
convert/convert.php | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/convert/convert.php b/convert/convert.php
index 57ce6ea8..2c97e2aa 100644
--- a/convert/convert.php
+++ b/convert/convert.php
@@ -6,7 +6,6 @@
* Author: Mike Macgirvin
*/
-use Friendica\App;
use Friendica\Core\Hook;
function convert_install() {
@@ -26,7 +25,7 @@ function convert_content() {
// @TODO Let's one day rewrite this to a modern composer package
include 'UnitConvertor.php';
- class TP_Converter extends UnitConvertor
+ $conv = new class('en') extends UnitConvertor
{
public function __construct(string $lang = 'en')
{
@@ -43,7 +42,7 @@ function convert_content() {
private function findBaseUnit($from, $to)
{
- while (list($skey, $sval) = each($this->bases)) {
+ foreach ($this->bases as $skey => $sval) {
if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
return $skey;
}
@@ -63,7 +62,7 @@ function convert_content() {
$cells[] = $cell;
// We now have the base unit and value now lets produce the table;
- while (list($key, $val) = each($this->bases[$base_unit])) {
+ foreach ($this->bases[$base_unit] as $val) {
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
$cells[] = $cell;
@@ -86,9 +85,7 @@ function convert_content() {
return $string;
}
- }
-
- $conv = new TP_Converter('en');
+ };
$conversions = [
'Temperature' => ['base' => 'Celsius',
@@ -176,10 +173,10 @@ function convert_content() {
]
];
- while (list($key, $val) = each($conversions)) {
+ foreach ($conversions as $key => $val) {
$conv->addConversion($val['base'], $val['conv']);
$list[$key][] = $val['base'];
- while (list($ukey, $uval) = each($val['conv'])) {
+ foreach ($val['conv'] as $ukey => $uval) {
$list[$key][] = $ukey;
}
}
@@ -202,10 +199,9 @@ function convert_content() {
$o .= ' ';
$o .= '';
- reset($list);
- while(list($key, $val) = each($list)) {
+ foreach ($list as $key => $val) {
$o .= "\n\t";
- while(list($ukey, $uval) = each($val)) {
+ foreach ($val as $ukey => $uval) {
$selected = (($uval == $_POST['from_unit']) ? ' selected="selected" ' : '');
$o .= "\n\t\t$uval ";
}
From 90ffd40d58814cb815aef4cf4d0e3077301cdbd4 Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 11:38:55 +0000
Subject: [PATCH 03/34] remove wrong return tag
---
convert/UnitConvertor.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/convert/UnitConvertor.php b/convert/UnitConvertor.php
index d7933a8f..a3650e9b 100644
--- a/convert/UnitConvertor.php
+++ b/convert/UnitConvertor.php
@@ -169,7 +169,6 @@ class UnitConvertor
* @param string name of the source unit from which to convert
* @param string name of the target unit to which we are converting
* @param integer double precision of the end result
- * @return void
* @access public
*/
function convert($value, $from_unit, $to_unit, $precision)
@@ -280,4 +279,4 @@ class UnitConvertor
} // end func getConvSpecs
} // end class UnitConvertor
-?>
\ No newline at end of file
+?>
From 9117626c6a5f1c16ca7e17efa26c8f4aa164ae10 Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 11:40:45 +0000
Subject: [PATCH 04/34] Fix errors in diaspora addon
---
diaspora/diasphp.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/diaspora/diasphp.php b/diaspora/diasphp.php
index 1588b582..266b9899 100644
--- a/diaspora/diasphp.php
+++ b/diaspora/diasphp.php
@@ -9,6 +9,8 @@ use Friendica\Core\System;
class Diasphp {
private $cookiejar;
+ private $token_regex;
+ private $pod;
function __construct($pod) {
$this->token_regex = '/content="(.*?)" name="csrf-token/';
From 1346a92505d234a1a695c871c3a17913bff927d3 Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 11:43:21 +0000
Subject: [PATCH 05/34] Fix errors in libravatar addon
---
libravatar/Services/Libravatar.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libravatar/Services/Libravatar.php b/libravatar/Services/Libravatar.php
index 18aa5c90..70fcfe39 100644
--- a/libravatar/Services/Libravatar.php
+++ b/libravatar/Services/Libravatar.php
@@ -217,7 +217,7 @@ class Services_Libravatar
*
* @param array $options Array of options for getUrl()
*
- * @return void
+ * @return array
* @throws Exception When an invalid option is used
*/
protected function checkOptionsArray($options)
@@ -462,6 +462,8 @@ class Services_Libravatar
return $v['target'];
}
}
+
+ return '';
}
/**
From e488f597bec009385f3232e3e1d7ab92a62b34cb Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 11:52:59 +0000
Subject: [PATCH 06/34] Fix errors in mailstream addon
---
mailstream/mailstream.php | 2 +-
mailstream/phpmailer/class.phpmailer.php | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php
index ae57c4dd..9910a63d 100644
--- a/mailstream/mailstream.php
+++ b/mailstream/mailstream.php
@@ -378,7 +378,7 @@ function mailstream_send(string $message_id, array $item, array $user): bool
if (!$address) {
$address = $user['email'];
}
- $mail = new PHPmailer();
+ $mail = new PHPMailer();
try {
$mail->XMailer = 'Friendica Mailstream Addon';
$mail->SetFrom($frommail, mailstream_sender($item));
diff --git a/mailstream/phpmailer/class.phpmailer.php b/mailstream/phpmailer/class.phpmailer.php
index ab7fe030..a47b13f7 100644
--- a/mailstream/phpmailer/class.phpmailer.php
+++ b/mailstream/phpmailer/class.phpmailer.php
@@ -1519,6 +1519,7 @@ class PHPMailer
public function getSMTPInstance()
{
if (!is_object($this->smtp)) {
+ /** @phpstan-ignore-next-line file class.smtp.php does not exist */
$this->smtp = new SMTP;
}
return $this->smtp;
@@ -2705,7 +2706,7 @@ class PHPMailer
$file_buffer = $this->encodeString($file_buffer, $encoding);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
- set_magic_quotes_runtime($magic_quotes);
+ //set_magic_quotes_runtime($magic_quotes);
} else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
From 7453c6f41ab4a2fbc3cec72f38dcfcbdde359080 Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 22:33:12 +0000
Subject: [PATCH 07/34] fix error in PHPMailer
---
mailstream/phpmailer/class.phpmailer.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mailstream/phpmailer/class.phpmailer.php b/mailstream/phpmailer/class.phpmailer.php
index a47b13f7..ff3d81e3 100644
--- a/mailstream/phpmailer/class.phpmailer.php
+++ b/mailstream/phpmailer/class.phpmailer.php
@@ -2691,10 +2691,10 @@ class PHPMailer
if (!is_readable($path)) {
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
- $magic_quotes = get_magic_quotes_runtime();
+ $magic_quotes = false;
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
- set_magic_quotes_runtime(false);
+ //set_magic_quotes_runtime(false);
} else {
//Doesn't exist in PHP 5.4, but we don't need to check because
//get_magic_quotes_runtime always returns false in 5.4+
From a5aaea5211ff4cc5ee17dcd9e80fb09c39ce334c Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 22:55:15 +0000
Subject: [PATCH 08/34] fix errors in pnut addon, add support for PHP 7.4
---
pnut/lib/phpnut.php | 173 +++++++++++++++++++++++---------------------
1 file changed, 92 insertions(+), 81 deletions(-)
diff --git a/pnut/lib/phpnut.php b/pnut/lib/phpnut.php
index 303a860b..5794d795 100644
--- a/pnut/lib/phpnut.php
+++ b/pnut/lib/phpnut.php
@@ -2,6 +2,8 @@
namespace phpnut;
+use CURLFile;
+
/**
* phpnut.php
* pnut.io PHP library
@@ -99,6 +101,10 @@ class phpnut
// if processing stream_markers or any fast stream, decrease $sleepFor
public $streamingSleepFor = 20000;
+ private $_clientId;
+
+ private $_clientSecret;
+
/**
* Constructs an phpnut PHP object with the specified client ID and
* client secret.
@@ -162,7 +168,7 @@ class phpnut
* from the user. If you don't specify anything, you'll only receive
* access to the user's basic profile (the default).
*/
- public function getAuthUrl(?string $callback_uri=null, array|string|null $scope=null): string
+ public function getAuthUrl(?string $callback_uri=null, array $scope=null): string
{
if (empty($this->_clientId)) {
throw new phpnutException('You must specify your pnut client ID');
@@ -256,8 +262,10 @@ class phpnut
/**
* Check the scope of current token to see if it has required scopes
* has to be done after a check
+ *
+ * @return int|array
*/
- public function checkScopes(array $app_scopes): int|array
+ public function checkScopes(array $app_scopes)
{
if (count($this->_scopes) === 0) {
return -1; // _scope is empty
@@ -303,7 +311,7 @@ class phpnut
{
return $this->httpReq('delete', "{$this->_baseUrl}token");
}
-
+
/**
* Retrieve an app access token from the app.net API. This allows you
* to access the API without going through the user access flow if you
@@ -314,7 +322,7 @@ class phpnut
* @return string The app access token
*/
public function getAppAccessToken()
- {
+ {
if (empty($this->_clientId) || empty($this->_clientSecret)) {
throw new phpnutException('You must specify your Pnut client ID and client secret');
}
@@ -450,8 +458,10 @@ class phpnut
/**
* Internal function to handle all
* HTTP requests (POST,PUT,GET,DELETE)
+ *
+ * @param string|array $params
*/
- protected function httpReq(string $act, string $req, string|array $params=[], string $contentType='application/x-www-form-urlencoded')
+ protected function httpReq(string $act, string $req, $params = [], string $contentType='application/x-www-form-urlencoded')
{
$ch = curl_init($req);
$headers = [];
@@ -520,7 +530,7 @@ class phpnut
} else {
throw new phpnutException($response['error']);
}
- }
+ }
// look for response migration errors
elseif (isset($response['meta'], $response['meta']['error_message'])) {
@@ -588,7 +598,7 @@ class phpnut
{
return $this->_last_request;
}
-
+
public function getLastResponse()
{
return $this->_last_response;
@@ -752,7 +762,7 @@ class phpnut
* Retrieve the Posts that are 'in reply to' a specific Post.
* @param integer $post_id The ID of the post you want to retrieve replies for.
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getPostThread(int $post_id, array $params=[])
{
@@ -767,7 +777,7 @@ class phpnut
* Retrieve revisions of a post. Currently only one can be created.
* @param integer $post_id The ID of the post you want to retrieve previous revisions of.
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getPostRevisions(int $post_id, array $params=[])
{
@@ -781,13 +791,13 @@ class phpnut
/**
* Get the most recent Posts created by a specific User in reverse
* chronological order (most recent first).
- * @param mixed $user_id Either the ID of the user you wish to retrieve posts by,
+ * @param string|int $user_id $user_id Either the ID of the user you wish to retrieve posts by,
* or the string "me", which will retrieve posts for the user you're authenticated
* as.
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
- public function getUserPosts(string|int $user_id='me', array $params=[])
+ public function getUserPosts($user_id = 'me', array $params=[])
{
return $this->httpReq(
'get',
@@ -799,13 +809,13 @@ class phpnut
/**
* Get the most recent Posts mentioning by a specific User in reverse
* chronological order (newest first).
- * @param mixed $user_id Either the ID of the user who is being mentioned, or
+ * @param string|int $user_id Either the ID of the user who is being mentioned, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
- public function getUserMentions(string|int $user_id='me', array $params=[])
+ public function getUserMentions($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@@ -817,7 +827,7 @@ class phpnut
/**
* Get the currently authenticated user's recent messages
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getUserMessages(array $params=[])
{
@@ -832,7 +842,7 @@ class phpnut
* Return the 20 most recent posts from the current User and
* the Users they follow.
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getUserStream(array $params=[])
{
@@ -847,7 +857,7 @@ class phpnut
* Retrieve a list of all public Posts on pnut.io, often referred to as the
* global stream.
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getPublicPosts(array $params=[])
{
@@ -860,7 +870,7 @@ class phpnut
/**
* Retrieve a list of "explore" streams
- * @return An array of associative arrays, each representing a single explore stream.
+ * @return array An array of associative arrays, each representing a single explore stream.
*/
public function getPostExploreStreams()
{
@@ -874,7 +884,7 @@ class phpnut
* Retrieve a list of posts from an "explore" stream on pnut.io.
* @param string $slug []
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getPostExploreStream(string $slug, array $params=[])
{
@@ -916,10 +926,11 @@ class phpnut
* are: count, before_id, since_id, include_muted, include_deleted,
* and include_post_raw.
* See https://github.com/phpnut/api-spec/blob/master/resources/posts.md#general-parameters
+ * @param string|int $user_id
* @return array An array of associative arrays, each representing a single
* user who has bookmarked a post
*/
- public function getBookmarked(string|int $user_id='me', array $params=[])
+ public function getBookmarked($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@@ -967,7 +978,7 @@ class phpnut
/**
* Repost an existing Post object.
* @param integer $post_id The id of the post
- * @return the reposted post
+ * @return mixed the reposted post
*/
public function repost(int $post_id)
{
@@ -980,7 +991,7 @@ class phpnut
/**
* Delete a post that the user has reposted.
* @param integer $post_id The id of the post
- * @return the un-reposted post
+ * @return mixed the un-reposted post
*/
public function deleteRepost(int $post_id)
{
@@ -997,7 +1008,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* include_directed_posts, and include_raw.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function searchHashtags(string $hashtag, array $params=[])
{
@@ -1044,7 +1055,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* and include_post_raw.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getUserPersonalStream(array $params=[])
{
@@ -1063,7 +1074,7 @@ class phpnut
);
}
}
-
+
/**
* Return the 20 most recent Posts from the current User's personalized stream
* and mentions stream merged into one stream.
@@ -1071,7 +1082,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* include_directed_posts, and include_raw.
- * @return An array of associative arrays, each representing a single post.
+ * @return array An array of associative arrays, each representing a single post.
*/
public function getUserUnifiedStream(array $params=[])
{
@@ -1096,14 +1107,14 @@ class phpnut
/**
* Returns a specific user object.
- * @param mixed $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
+ * @param string|int $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
* "me" to retrieve data for the users you're currently authenticated as.
* @param array $params An associative array of optional general parameters.
* This will likely change as the API evolves, as of this writing allowed keys
* are: include_raw|include_user_raw.
* @return array An associative array representing the user data.
*/
- public function getUser(string|int $user_id='me', array $params=[])
+ public function getUser($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@@ -1131,10 +1142,10 @@ class phpnut
/**
* Add the specified user ID to the list of users followed.
* Returns the User object of the user being followed.
- * @param integer $user_id The user ID of the user to follow.
+ * @param string|int $user_id The user ID of the user to follow.
* @return array An associative array representing the user you just followed.
*/
- public function followUser(string|int $user_id)
+ public function followUser($user_id)
{
return $this->httpReq(
'put',
@@ -1145,10 +1156,10 @@ class phpnut
/**
* Removes the specified user ID to the list of users followed.
* Returns the User object of the user being unfollowed.
- * @param integer $user_id The user ID of the user to unfollow.
+ * @param string|int $user_id The user ID of the user to unfollow.
* @return array An associative array representing the user you just unfollowed.
*/
- public function unfollowUser(string|int $user_id)
+ public function unfollowUser($user_id)
{
return $this->httpReq(
'delete',
@@ -1158,13 +1169,13 @@ class phpnut
/**
* Returns an array of User objects the specified user is following.
- * @param mixed $user_id Either the ID of the user being followed, or
+ * @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array An array of associative arrays, each representing a single
* user following $user_id
*/
- public function getFollowing(string|int $user_id='me', array $params=[])
+ public function getFollowing($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@@ -1172,31 +1183,31 @@ class phpnut
. $this->buildQueryString($params)
);
}
-
+
/**
* Returns an array of User ids the specified user is following.
- * @param mixed $user_id Either the ID of the user being followed, or
+ * @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array user ids the specified user is following.
*/
- public function getFollowingIDs(string|int $user_id='me')
+ public function getFollowingIDs($user_id='me')
{
return $this->httpReq(
'get',
"{$this->_baseUrl}users/{$user_id}/following?include_user=0"
);
}
-
+
/**
* Returns an array of User objects for users following the specified user.
- * @param mixed $user_id Either the ID of the user being followed, or
+ * @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array An array of associative arrays, each representing a single
* user following $user_id
*/
- public function getFollowers(string|int $user_id='me', array $params=[])
+ public function getFollowers($user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@@ -1204,15 +1215,15 @@ class phpnut
. $this->buildQueryString($params)
);
}
-
+
/**
* Returns an array of User ids for users following the specified user.
- * @param mixed $user_id Either the ID of the user being followed, or
+ * @param string|int $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array user ids for users following the specified user
*/
- public function getFollowersIDs(string|int $user_id='me')
+ public function getFollowersIDs($user_id='me')
{
return $this->httpReq(
'get',
@@ -1236,9 +1247,9 @@ class phpnut
/**
* Mute a user
- * @param integer $user_id The user ID to mute
+ * @param string|int $user_id The user ID to mute
*/
- public function muteUser(string|int $user_id)
+ public function muteUser($user_id)
{
return $this->httpReq(
'put',
@@ -1248,9 +1259,9 @@ class phpnut
/**
* Unmute a user
- * @param integer $user_id The user ID to unmute
+ * @param string|int $user_id The user ID to unmute
*/
- public function unmuteUser(string|int $user_id)
+ public function unmuteUser($user_id)
{
return $this->httpReq(
'delete',
@@ -1288,7 +1299,7 @@ class phpnut
* @param string $search The search query. Supports @username or #tag searches as
* well as normal search terms. Searches username, display name, bio information.
* Does not search posts.
- * @return array An array of associative arrays, each representing one user.
+ * @return array|false An array of associative arrays, each representing one user.
*/
public function searchUsers(array $params=[], string $query='')
{
@@ -1333,7 +1344,7 @@ class phpnut
$mimeType = $test['mime'];
}
$data = [
- $which => new CurlFile($image, $mimeType)
+ $which => new CURLFile($image, $mimeType)
];
return $this->httpReq(
'post-raw',
@@ -1445,10 +1456,10 @@ class phpnut
/**
* get an existing private message channel between multiple users
- * @param mixed $users Can be a comma- or space-separated string, or an array.
+ * @param string|array $users Can be a comma- or space-separated string, or an array.
* Usernames with @-symbol, or user ids.
*/
- public function getExistingPM(string|array $users, array $params=[])
+ public function getExistingPM($users, array $params=[])
{
if (is_string($users)) {
$users = explode(',', str_replace(' ', ',', $users));
@@ -1561,7 +1572,7 @@ class phpnut
/**
* Retrieve a list of "explore" streams
- * @return An array of associative arrays, each representing a single explore stream.
+ * @return array An array of associative arrays, each representing a single explore stream.
*/
public function getChannelExploreStreams()
{
@@ -1575,7 +1586,7 @@ class phpnut
* Retrieve a list of channels from an "explore" stream on pnut.io.
* @param string $slug []
* @param array $params An associative array of optional general parameters.
- * @return An array of associative arrays, each representing a single channel.
+ * @return array An array of associative arrays, each representing a single channel.
*/
public function getChannelExploreStream(string $slug, array $params=[])
{
@@ -1585,7 +1596,7 @@ class phpnut
. $this->buildQueryString($params)
);
}
-
+
/**
* mark channel inactive
*/
@@ -1685,11 +1696,11 @@ class phpnut
/**
* create message
- * @param $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
+ * @param string|int $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
* @param array $data array('text'=>'YOUR_MESSAGE') If a type=io.pnut.core.pm, then "destinations" key can be set to address as an array of people to send this PM too
* @param array $params query parameters
*/
- public function createMessage(string|int $channelid, array $data, array $params=[])
+ public function createMessage($channelid, array $data, array $params=[])
{
if (isset($data['destinations'])) {
if (is_string($data['destinations'])) {
@@ -1802,16 +1813,16 @@ class phpnut
public function createFile($file, array $data, array $params=[])
{
if (!$file) {
- throw new PhpnutException('You must specify a path to a file');
+ throw new phpnutException('You must specify a path to a file');
}
if (!file_exists($file)) {
- throw new PhpnutException('File path specified does not exist');
+ throw new phpnutException('File path specified does not exist');
}
if (!is_readable($file)) {
- throw new PhpnutException('File path specified is not readable');
+ throw new phpnutException('File path specified is not readable');
}
if (!array_key_exists('type', $data) || !$data['type']) {
- throw new PhpnutException('Type is required when creating a file');
+ throw new phpnutException('Type is required when creating a file');
}
if (!array_key_exists('name', $data)) {
$data['name'] = basename($file);
@@ -1823,7 +1834,7 @@ class phpnut
$mimeType = null;
}
if (!array_key_exists('kind', $data)) {
- $test = @getimagesize($path);
+ $test = @getimagesize($file);
if ($test && array_key_exists('mime', $test)) {
$data['kind'] = 'image';
if (!$mimeType) {
@@ -1840,7 +1851,7 @@ class phpnut
finfo_close($finfo);
}
if (!$mimeType) {
- throw new PhpnutException('Unable to determine mime type of file, try specifying it explicitly');
+ throw new phpnutException('Unable to determine mime type of file, try specifying it explicitly');
}
$data['content'] = new \CurlFile($file, $mimeType);
return $this->httpReq(
@@ -2001,7 +2012,7 @@ class phpnut
$json = json_encode($data);
return $this->httpReq(
'post',
- $this->_baseUrl.'polls?'.$this->buildQueryString($params),
+ $this->_baseUrl.'polls?'.$this->buildQueryString($params),
$json,
'application/json'
);
@@ -2019,7 +2030,7 @@ class phpnut
return $this->httpReq(
'put',
$this->_baseUrl.'polls/'.urlencode($poll_id).'/response?'.$this->buildQueryString($params),
- $json,
+ $json,
'application/json'
);
}
@@ -2118,7 +2129,7 @@ class phpnut
$params
);
}
-
+
/**
* Get User Information
*/
@@ -2129,7 +2140,7 @@ class phpnut
"{$this->_baseUrl}token"
);
}
-
+
/**
* Get Application Authorized User IDs
*/
@@ -2147,7 +2158,7 @@ class phpnut
$params
);
}
-
+
/**
* Get Application Authorized User Tokens
*/
@@ -2181,7 +2192,7 @@ class phpnut
{
$this->_streamCallback = $function;
}
-
+
/**
* Opens a stream that's been created for this user/app and starts sending
* events/objects to your defined callback functions. You must define at
@@ -2231,7 +2242,7 @@ class phpnut
);
return true;
}
-
+
/**
* Close the currently open stream.
* @return true;
@@ -2251,7 +2262,7 @@ class phpnut
$this->_currentStream = null;
$this->_multiStream = null;
}
-
+
/**
* Retrieve all streams for the current access token.
* @return array An array of stream definitions.
@@ -2263,7 +2274,7 @@ class phpnut
"{$this->_baseUrl}streams"
);
}
-
+
/**
* Returns a single stream specified by a stream ID. The stream must have been
* created with the current access token.
@@ -2276,7 +2287,7 @@ class phpnut
$this->_baseUrl.'streams/'.urlencode($streamId)
);
}
-
+
/**
* Creates a stream for the current app access token.
*
@@ -2307,7 +2318,7 @@ class phpnut
);
return $response;
}
-
+
/**
* Update stream for the current app access token
*
@@ -2338,7 +2349,7 @@ class phpnut
);
return $response;
}
-
+
/**
* Deletes a stream if you no longer need it.
*
@@ -2352,7 +2363,7 @@ class phpnut
$this->_baseUrl.'streams/'.urlencode($streamId)
);
}
-
+
/**
* Deletes all streams created by the current access token.
*/
@@ -2363,7 +2374,7 @@ class phpnut
"{$this->_baseUrl}streams"
);
}
-
+
/**
* Internal function used to process incoming chunks from the stream. This is only
* public because it needs to be accessed by CURL. Do not call or use this function
@@ -2394,7 +2405,7 @@ class phpnut
}
return strlen($data);
}
-
+
/**
* Opens a long lived HTTP connection to the pnut.io servers, and sends data
* received to the httpStreamReceive function. As a general rule you should not
@@ -2426,7 +2437,7 @@ class phpnut
$this->_lastStreamActivity = time();
curl_multi_add_handle($this->_multiStream, $this->_currentStream);
}
-
+
public function reconnectStream(): void
{
$this->closeStream();
@@ -2442,7 +2453,7 @@ class phpnut
}
$this->httpStream('get', $this->_streamUrl);
}
-
+
/**
* Process an open stream for x microseconds, then return. This is useful if you want
* to be doing other things while processing the stream. If you just want to
@@ -2487,7 +2498,7 @@ class phpnut
}
} while ($timeSoFar+$sleepFor < $microseconds);
}
-
+
/**
* Process an open stream forever. This function will never return, if you
* want to perform other actions while consuming the stream, you should use
From 787240046751b39f635af33c6e5a6c4162d02e68 Mon Sep 17 00:00:00 2001
From: Art4
Date: Wed, 27 Nov 2024 23:14:01 +0000
Subject: [PATCH 09/34] Fix errors in pumpio addon
---
pumpio/oauth/http.php | 86 ++++++++++++++++++++++---------------------
1 file changed, 44 insertions(+), 42 deletions(-)
diff --git a/pumpio/oauth/http.php b/pumpio/oauth/http.php
index 5d5e23f0..3045e509 100644
--- a/pumpio/oauth/http.php
+++ b/pumpio/oauth/http.php
@@ -109,9 +109,11 @@ class http_class
var $connected_port = -1;
var $connected_ssl = 0;
+ private $content_length_set;
+
/* Private methods - DO NOT CALL */
- Function Tokenize($string,$separator="")
+ private function Tokenize($string,$separator="")
{
if(!strcmp($separator,""))
{
@@ -135,18 +137,18 @@ class http_class
}
}
- Function CookieEncode($value, $name)
+ private function CookieEncode($value, $name)
{
return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
}
- Function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
+ private function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
{
$this->error_code = $error_code;
return($this->error=$error);
}
- Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
+ private function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
{
if(IsSet($php_error_message)
&& strlen($php_error_message))
@@ -154,7 +156,7 @@ class http_class
return($this->SetError($error, $error_code));
}
- Function SetDataAccessError($error,$check_connection=0)
+ private function SetDataAccessError($error,$check_connection=0)
{
$this->error=$error;
$this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
@@ -174,7 +176,7 @@ class http_class
}
}
- Function OutputDebug($message)
+ private function OutputDebug($message)
{
if($this->log_debug)
error_log($message);
@@ -188,7 +190,7 @@ class http_class
}
}
- Function GetLine()
+ private function GetLine()
{
for($line="";;)
{
@@ -227,7 +229,7 @@ class http_class
}
}
- Function PutLine($line)
+ private function PutLine($line)
{
if($this->debug)
$this->OutputDebug("C $line");
@@ -239,7 +241,7 @@ class http_class
return(1);
}
- Function PutData($data)
+ private function PutData($data)
{
if(strlen($data))
{
@@ -254,7 +256,7 @@ class http_class
return(1);
}
- Function FlushData()
+ private function FlushData()
{
if(!fflush($this->connection))
{
@@ -264,7 +266,7 @@ class http_class
return(1);
}
- Function ReadChunkSize()
+ private function ReadChunkSize()
{
if($this->remaining_chunk==0)
{
@@ -289,7 +291,7 @@ class http_class
return("");
}
- Function ReadBytes($length)
+ private function ReadBytes($length)
{
if($this->use_curl)
{
@@ -356,7 +358,7 @@ class http_class
return($bytes);
}
- Function EndOfInput()
+ private function EndOfInput()
{
if($this->use_curl)
return($this->read_response>=strlen($this->response));
@@ -367,7 +369,7 @@ class http_class
return(feof($this->connection));
}
- Function Resolve($domain, &$ip, $server_type)
+ private function Resolve($domain, &$ip, $server_type)
{
if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain))
$ip=$domain;
@@ -385,7 +387,7 @@ class http_class
return('');
}
- Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
+ private function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
{
$domain=$host_name;
$port = $host_port;
@@ -552,7 +554,7 @@ class http_class
}
}
- Function Disconnect()
+ private function Disconnect()
{
if($this->debug)
$this->OutputDebug("Disconnected from ".$this->connected_host);
@@ -569,7 +571,7 @@ class http_class
/* Public methods */
- Function GetRequestArguments($url, &$arguments)
+ public function GetRequestArguments($url, &$arguments)
{
$this->error = '';
$this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
@@ -621,7 +623,7 @@ class http_class
return("");
}
- Function Open($arguments)
+ public function Open($arguments)
{
if(strlen($this->error))
return($this->error);
@@ -750,7 +752,7 @@ class http_class
return("");
}
- Function Close($force = 0)
+ public function Close($force = 0)
{
if($this->state=="Disconnected")
return("1 already disconnected");
@@ -767,7 +769,7 @@ class http_class
return($this->Disconnect());
}
- Function PickCookies(&$cookies,$secure)
+ private function PickCookies(&$cookies,$secure)
{
if(IsSet($this->cookies[$secure]))
{
@@ -803,7 +805,7 @@ class http_class
}
}
- Function GetFileDefinition($file, &$definition)
+ private function GetFileDefinition($file, &$definition)
{
$name="";
if(IsSet($file["FileName"]))
@@ -990,9 +992,6 @@ class http_class
if(GetType($length=@filesize($file["FileName"]))!="integer")
{
$error="it was not possible to determine the length of the file ".$file["FileName"];
- if(IsSet($php_errormsg)
- && strlen($php_errormsg))
- $error.=": ".$php_errormsg;
if(!file_exists($file["FileName"]))
$error="it was not possible to access the file ".$file["FileName"];
return($error);
@@ -1007,7 +1006,7 @@ class http_class
return("");
}
- Function ConnectFromProxy($arguments, &$headers)
+ private function ConnectFromProxy($arguments, &$headers)
{
if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
|| (strlen($this->user_agent)
@@ -1052,7 +1051,7 @@ class http_class
return("");
}
- Function SendRequest($arguments)
+ public function SendRequest($arguments)
{
if(strlen($this->error))
return($this->error);
@@ -1440,7 +1439,7 @@ class http_class
return("");
}
- Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
+ private function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
{
if(strlen($this->error))
return($this->error);
@@ -1472,7 +1471,7 @@ class http_class
return("");
}
- Function SendRequestBody($data, $end_of_data)
+ private function SendRequestBody($data, $end_of_data)
{
if(strlen($this->error))
return($this->error);
@@ -1508,7 +1507,7 @@ class http_class
return("");
}
- Function ReadReplyHeadersResponse(&$headers)
+ private function ReadReplyHeadersResponse(&$headers)
{
$headers=array();
if(strlen($this->error))
@@ -1635,7 +1634,7 @@ class http_class
return("");
}
- Function Redirect(&$headers)
+ private function Redirect(&$headers)
{
if($this->follow_redirect)
{
@@ -1678,7 +1677,7 @@ class http_class
return("");
}
- Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
+ private function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
{
if($proxy)
{
@@ -1697,9 +1696,10 @@ class http_class
if(IsSet($headers[$authenticate_header])
&& $this->sasl_authenticate)
{
- if(function_exists("class_exists")
- && !class_exists("sasl_client_class"))
+ if(!class_exists('sasl_client_class'))
+ {
return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
+ }
if(GetType($headers[$authenticate_header])=="array")
$authenticate=$headers[$authenticate_header];
else
@@ -1719,7 +1719,7 @@ class http_class
else
$mechanisms[]=$mechanism;
}
- $sasl=new sasl_client_class;
+ $sasl=new \sasl_client_class();
if(IsSet($user))
$sasl->SetCredential("user",$user);
if(IsSet($password))
@@ -1731,6 +1731,8 @@ class http_class
$sasl->SetCredential("uri",$this->request_uri);
$sasl->SetCredential("method",$this->request_method);
$sasl->SetCredential("session",$this->session);
+ $message = '';
+ $interactions = [];
do
{
$status=$sasl->Start($mechanisms,$message,$interactions);
@@ -1906,8 +1908,8 @@ class http_class
}
return("");
}
-
- Function ReadReplyHeaders(&$headers)
+
+ public function ReadReplyHeaders(&$headers)
{
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
return($error);
@@ -1938,7 +1940,7 @@ class http_class
return("");
}
- Function ReadReplyBody(&$body,$length)
+ private function ReadReplyBody(&$body,$length)
{
$body="";
if(strlen($this->error))
@@ -1980,7 +1982,7 @@ class http_class
return("");
}
- Function ReadWholeReplyBody(&$body)
+ public function ReadWholeReplyBody(&$body)
{
$body = '';
for(;;)
@@ -1993,7 +1995,7 @@ class http_class
}
}
- Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
+ private function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
{
$now=gmdate("Y-m-d H-i-s");
$cookies=array();
@@ -2034,17 +2036,17 @@ class http_class
}
}
- Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
+ private function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
{
$this->SaveCookies($cookies, $domain, $secure_only, 1);
}
- Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
+ private function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
{
$this->SavePersistentCookies($cookies, $domain, $secure_only);
}
- Function RestoreCookies($cookies, $clear=1)
+ private function RestoreCookies($cookies, $clear=1)
{
$new_cookies=($clear ? array() : $this->cookies);
for($secure_cookies=0, Reset($cookies); $secure_cookies
Date: Wed, 27 Nov 2024 23:18:20 +0000
Subject: [PATCH 10/34] Fix classes in s3_storage addon
---
s3_storage/src/S3Client.php | 8 ++++----
s3_storage/src/S3Config.php | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/s3_storage/src/S3Client.php b/s3_storage/src/S3Client.php
index 643df2b0..613eda97 100644
--- a/s3_storage/src/S3Client.php
+++ b/s3_storage/src/S3Client.php
@@ -4,10 +4,10 @@ namespace Friendica\Addon\s3_storage\src;
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
-use Akeeba\Engine\Postproc\Connector\S3v4\Configuration;
-use Akeeba\Engine\Postproc\Connector\S3v4\Connector;
-use Akeeba\Engine\Postproc\Connector\S3v4\Exception\CannotDeleteFile;
-use Akeeba\Engine\Postproc\Connector\S3v4\Input;
+use Akeeba\S3\Configuration;
+use Akeeba\S3\Connector;
+use Akeeba\S3\Exception\CannotDeleteFile;
+use Akeeba\S3\Input;
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
use Friendica\Core\Storage\Exception\StorageException;
use Friendica\Util\Strings;
diff --git a/s3_storage/src/S3Config.php b/s3_storage/src/S3Config.php
index 809cdd28..1831c666 100644
--- a/s3_storage/src/S3Config.php
+++ b/s3_storage/src/S3Config.php
@@ -4,8 +4,8 @@ namespace Friendica\Addon\s3_storage\src;
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
-use Akeeba\Engine\Postproc\Connector\S3v4\Configuration;
-use Akeeba\Engine\Postproc\Connector\S3v4\Connector;
+use Akeeba\S3\Configuration;
+use Akeeba\S3\Connector;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Storage\Capability\ICanConfigureStorage;
From 5f2a9e9891e4524708116d598170e9172b30ffa3 Mon Sep 17 00:00:00 2001
From: Art4
Date: Fri, 29 Nov 2024 22:36:05 +0000
Subject: [PATCH 11/34] Fix error in bluesky addon
---
bluesky/bluesky.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php
index 74d4fee8..c91823e3 100644
--- a/bluesky/bluesky.php
+++ b/bluesky/bluesky.php
@@ -1563,7 +1563,7 @@ function bluesky_get_uri_class(string $uri): ?stdClass
}
$elements = explode(':', $uri);
- if (empty($elements) || ($elements[0] != 'at')) {
+ if ($elements[0] !== 'at') {
$post = Post::selectFirstPost(['extid'], ['uri' => $uri]);
return bluesky_get_uri_class($post['extid'] ?? '');
}
From 5664bc84fba5c8cd206b43f87685a1cbcb3b7a92 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:27:45 +0000
Subject: [PATCH 12/34] Fix errors in bluesky addon
---
bluesky/bluesky.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php
index 8e2c1ca0..91e524fe 100644
--- a/bluesky/bluesky.php
+++ b/bluesky/bluesky.php
@@ -683,6 +683,8 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
return;
}
+ $post = [];
+
if ($item['verb'] == Activity::LIKE) {
$record = [
'subject' => $parent,
From bee780552ddf974e6cb3a8788a81a7e88a782697 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:28:38 +0000
Subject: [PATCH 13/34] Fix errors in convert addon
---
convert/convert.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/convert/convert.php b/convert/convert.php
index 2c97e2aa..2545974c 100644
--- a/convert/convert.php
+++ b/convert/convert.php
@@ -181,7 +181,7 @@ function convert_content() {
}
}
- $o .= 'Unit Conversions ';
+ $o = 'Unit Conversions ';
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
$o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '
';
From 07993f70985713ac692d73fa0ad78fecffbb2432 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:30:39 +0000
Subject: [PATCH 14/34] Fix errors in js_upload addon
---
.../file-uploader/tests/action-acceptance.php | 16 ++++++++--------
.../tests/action-handler-queue-test.php | 8 ++++----
.../file-uploader/tests/action-handler-test.php | 8 ++++----
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/js_upload/file-uploader/tests/action-acceptance.php b/js_upload/file-uploader/tests/action-acceptance.php
index fc9583f2..172b8857 100644
--- a/js_upload/file-uploader/tests/action-acceptance.php
+++ b/js_upload/file-uploader/tests/action-acceptance.php
@@ -2,12 +2,12 @@
usleep(100000);
-$fileName;
-$fileSize;
+$fileName = '';
+$fileSize = 0;;
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
-
+
// xhr request
$headers = apache_request_headers();
$fileSize = (int)$headers['Content-Length'];
@@ -34,13 +34,13 @@ if ($fileSize > 9 * 1024){
die ('{error: "server-error file size is bigger than 9kB"}');
}
-if (count($_GET)){
+if (count($_GET)){
array_merge($_GET, array('fileName'=>$fileName));
-
+
$response = array_merge($_GET, array('success'=>true, 'fileName'=>$fileName));
-
- // to pass data through iframe you will need to encode all html tags
- echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
+
+ // to pass data through iframe you will need to encode all html tags
+ echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
} else {
die ('{error: "server-error query params not passed"}');
}
diff --git a/js_upload/file-uploader/tests/action-handler-queue-test.php b/js_upload/file-uploader/tests/action-handler-queue-test.php
index ff13576d..78760d64 100644
--- a/js_upload/file-uploader/tests/action-handler-queue-test.php
+++ b/js_upload/file-uploader/tests/action-handler-queue-test.php
@@ -2,11 +2,11 @@
sleep(4);
-$fileName;
+$fileName = '';
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
-
+
// xhr request
$headers = apache_request_headers();
if ((int)$headers['Content-Length'] == 0){
@@ -14,7 +14,7 @@ if (isset($_GET['qqfile'])){
}
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
-
+
// form request
if ($_FILES['qqfile']['size'] == 0){
die ('{error: "file size is zero"}');
@@ -25,7 +25,7 @@ if (isset($_GET['qqfile'])){
if (count($_GET)){
$_GET['success'] = true;
- echo json_encode(array_merge($_GET));
+ echo json_encode(array_merge($_GET));
} else {
die ('{error: "query params not passed"}');
}
diff --git a/js_upload/file-uploader/tests/action-handler-test.php b/js_upload/file-uploader/tests/action-handler-test.php
index 24466b12..9fa72023 100644
--- a/js_upload/file-uploader/tests/action-handler-test.php
+++ b/js_upload/file-uploader/tests/action-handler-test.php
@@ -2,11 +2,11 @@
usleep(300);
-$fileName;
+$fileName = '';
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
-
+
// xhr request
$headers = apache_request_headers();
if ((int)$headers['Content-Length'] == 0){
@@ -14,7 +14,7 @@ if (isset($_GET['qqfile'])){
}
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
-
+
// form request
if ($_FILES['qqfile']['size'] == 0){
die ('{error: "file size is zero"}');
@@ -25,7 +25,7 @@ if (isset($_GET['qqfile'])){
if (count($_GET)){
//return query params
- echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
+ echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
} else {
die ('{error: "query params not passed"}');
}
From 04afbe36e3e62625debec212ec1f6782edbb8bd4 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:32:07 +0000
Subject: [PATCH 15/34] Fix errors in keycloakpassword addon
---
keycloakpassword/keycloakpassword.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/keycloakpassword/keycloakpassword.php b/keycloakpassword/keycloakpassword.php
index bfff4ea4..e9809f86 100644
--- a/keycloakpassword/keycloakpassword.php
+++ b/keycloakpassword/keycloakpassword.php
@@ -6,7 +6,6 @@
* Author: Ryan
*/
-use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@@ -92,7 +91,7 @@ function keycloakpassword_authenticate(array &$b)
$client_id,
$secret,
$endpoint . '/logout',
- [ 'refresh_token' => res['refresh_token'] ]
+ [ 'refresh_token' => $res['refresh_token'] ]
);
}
}
From fcec1a3d836b2134e318003bbd49e7a9a85cee30 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:35:19 +0000
Subject: [PATCH 16/34] Fix errors in langfilter addon
---
langfilter/langfilter.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php
index e5efa8fb..2bf986f0 100644
--- a/langfilter/langfilter.php
+++ b/langfilter/langfilter.php
@@ -7,7 +7,6 @@
* License: MIT
*/
-use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
@@ -148,6 +147,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
$iso639 = new Matriphe\ISO639\ISO639;
+ $confidence = null;
+
// Extract the language of the post
if (!empty($hook_data['item']['language'])) {
$languages = json_decode($hook_data['item']['language'], true);
From ace19814d7a934e46ef5303be3ff05cc6279ddc2 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:37:58 +0000
Subject: [PATCH 17/34] Fix errors in leistungsschutzrecht addon
---
leistungsschutzrecht/leistungsschutzrecht.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php
index f6c65399..ec8091ac 100644
--- a/leistungsschutzrecht/leistungsschutzrecht.php
+++ b/leistungsschutzrecht/leistungsschutzrecht.php
@@ -6,7 +6,6 @@
* Author: Michael Vogel
*/
-use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
@@ -149,7 +148,7 @@ function leistungsschutzrecht_is_member_site(string $url): bool
$cleanedurlpart = explode('%', $urldata['host']);
$hostname = explode('.', $cleanedurlpart[0]);
- if (empty($hostname)) {
+ if ($hostname === false || $hostname === '') {
return false;
}
From e86d15993b6794ea581624b34c0631685e8d14aa Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:41:11 +0000
Subject: [PATCH 18/34] Fix errors in libravatar addon
---
libravatar/Services/Libravatar.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libravatar/Services/Libravatar.php b/libravatar/Services/Libravatar.php
index 70fcfe39..e51ef070 100644
--- a/libravatar/Services/Libravatar.php
+++ b/libravatar/Services/Libravatar.php
@@ -401,9 +401,8 @@ class Services_Libravatar
*/
protected function srvGet($domain, $https = false)
{
-
// Are we going secure? Set up a fallback too.
- if (isset($https) && $https === true) {
+ if ($https === true) {
$subdomain = '_avatars-sec._tcp.';
$fallback = 'seccdn.';
} else {
@@ -426,6 +425,7 @@ class Services_Libravatar
$top = $srv[0];
$sum = 0;
+ $pri = [];
// Try to adhere to RFC2782's weighting algorithm, page 3
// "arrange all SRV RRs (that have not been ordered yet) in any order,
From 5f6f374f09f8c186422d245d523644020694395b Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:42:40 +0000
Subject: [PATCH 19/34] Fix errors in ljpost addon
---
ljpost/ljpost.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php
index 7acc6589..b416c605 100644
--- a/ljpost/ljpost.php
+++ b/ljpost/ljpost.php
@@ -8,7 +8,6 @@
* Author: Cat Gray
*/
-use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@@ -203,10 +202,12 @@ EOT;
Logger::debug('ljpost: data: ' . $xml);
+ $x = '';
+
if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
- Logger::info('posted to livejournal: ' . ($x) ? $x : '');
+ Logger::info('posted to livejournal: ' . $x);
}
}
From c04016b7d3b4e24adfa8f43e9420c004e9b7d36f Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:48:49 +0000
Subject: [PATCH 20/34] fix errors in mailstream addon
---
mailstream/phpmailer/class.phpmailer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mailstream/phpmailer/class.phpmailer.php b/mailstream/phpmailer/class.phpmailer.php
index ff3d81e3..dcf02361 100644
--- a/mailstream/phpmailer/class.phpmailer.php
+++ b/mailstream/phpmailer/class.phpmailer.php
@@ -3287,7 +3287,7 @@ class PHPMailer
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
- } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
+ } elseif (array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} elseif (function_exists('gethostname') && gethostname() !== false) {
$result = gethostname();
From 50912fdc173dbb5f82f6dc8414d0d5d40f7b0879 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:50:06 +0000
Subject: [PATCH 21/34] Fix errors in nsfw addon
---
nsfw/nsfw.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php
index 4a54d899..674fc201 100644
--- a/nsfw/nsfw.php
+++ b/nsfw/nsfw.php
@@ -8,7 +8,6 @@
*
*/
-use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@@ -119,7 +118,9 @@ function nsfw_prepare_body_content_filter(&$hook_data)
$word_list = ['nsfw'];
}
- $found = false;
+ $found = false;
+ $tag_search = false;
+
if (count($word_list)) {
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
@@ -129,7 +130,6 @@ function nsfw_prepare_body_content_filter(&$hook_data)
continue;
}
- $tag_search = false;
switch ($word[0]) {
case '/'; // Regular expression
$found = @preg_match($word, $body);
From 3f89aa180610b0ce0ead35c082ad43e3c702bcde Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 19:51:18 +0000
Subject: [PATCH 22/34] Fix errors in pnut addon
---
pnut/lib/phpnut.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pnut/lib/phpnut.php b/pnut/lib/phpnut.php
index 5794d795..89d5e5f8 100644
--- a/pnut/lib/phpnut.php
+++ b/pnut/lib/phpnut.php
@@ -1339,6 +1339,8 @@ class phpnut
*/
protected function updateUserImage(string $image, string $which='avatar')
{
+ $mimeType = '';
+
$test = @getimagesize($image);
if ($test && array_key_exists('mime', $test)) {
$mimeType = $test['mime'];
From 43ee267d38c1084cdac54f0872a902d788897631 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 20:12:23 +0000
Subject: [PATCH 23/34] fix errors in pumpio addon
---
pumpio/pumpio.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php
index 5e053d7c..d7c2ac32 100644
--- a/pumpio/pumpio.php
+++ b/pumpio/pumpio.php
@@ -6,7 +6,6 @@
* Author: Michael Vogel
*/
-use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@@ -582,6 +581,8 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
$uri = $orig_post['uri'];
}
+ $objectType = '';
+
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
} elseif (strstr($uri, '/api/comment/')) {
@@ -827,6 +828,7 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id)
}
$contactid = 0;
+ $contact = [];
if (Strings::compareLink($post->actor->url, $own_id)) {
$contactid = $self['id'];
@@ -1430,6 +1432,8 @@ function pumpio_fetchallcomments($uid, $id)
Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
+ $item = new \stdClass();
+
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $item);
} else {
From fccf361ef121492aaf486ffca72eafbf4e558536 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 20:13:41 +0000
Subject: [PATCH 24/34] fix errors in ratioed addon
---
ratioed/RatioedPanel.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/ratioed/RatioedPanel.php b/ratioed/RatioedPanel.php
index e25c7f34..bd9b44dc 100644
--- a/ratioed/RatioedPanel.php
+++ b/ratioed/RatioedPanel.php
@@ -26,6 +26,7 @@ class RatioedPanel extends Active
$action = $this->parameters['action'] ?? '';
$uid = $this->parameters['uid'] ?? 0;
+ $user = [];
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
From a41f8c13fea5cb52687fc35c1756c04c0620b510 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 20:27:57 +0000
Subject: [PATCH 25/34] fix errors in statusnet addon
---
statusnet/library/codebirdsn.php | 13 +++++++------
statusnet/statusnet.php | 2 ++
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/statusnet/library/codebirdsn.php b/statusnet/library/codebirdsn.php
index 325bcb07..91e256be 100644
--- a/statusnet/library/codebirdsn.php
+++ b/statusnet/library/codebirdsn.php
@@ -31,11 +31,10 @@ use Friendica\Core\System;
/**
* Define constants
*/
-$constants = explode(' ', 'OBJECT ARRAY JSON');
-foreach ($constants as $i => $id) {
- $id = 'CODEBIRD_RETURNFORMAT_' . $id;
- defined($id) or define($id, $i);
-}
+defined('CODEBIRD_RETURNFORMAT_ARRAY') or define('CODEBIRD_RETURNFORMAT_ARRAY', 0);
+defined('CODEBIRD_RETURNFORMAT_JSON') or define('CODEBIRD_RETURNFORMAT_JSON', 1);
+defined('CODEBIRD_RETURNFORMAT_OBJECT') or define('CODEBIRD_RETURNFORMAT_OBJECT', 2);
+
$constants = array(
'CURLE_SSL_CERTPROBLEM' => 58,
'CURLE_SSL_CACERT' => 60,
@@ -788,6 +787,8 @@ class CodebirdSN
$possible_files = explode(' ', $possible_files[$method]);
+ $data = '';
+
$multipart_border = '--------------------' . $this->_nonce();
$multipart_request = '';
foreach ($params as $key => $value) {
@@ -917,7 +918,7 @@ class CodebirdSN
$authorization = 'Authorization: Bearer ' . self::$_oauth_bearer_token;
}
$request_headers = array();
- if (isset($authorization)) {
+ if ($authorization !== '') {
$request_headers[] = $authorization;
$request_headers[] = 'Expect:';
}
diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php
index 4bc32050..48f9c254 100644
--- a/statusnet/statusnet.php
+++ b/statusnet/statusnet.php
@@ -366,6 +366,8 @@ function statusnet_post_hook(array &$b)
$otoken = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthtoken');
$osecret = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthsecret');
+ $iscomment = null;
+
if ($ckey && $csecret && $otoken && $osecret) {
$dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent
From b6a47699bfc68e3c57af797053cf79efe4d96e78 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 20:36:07 +0000
Subject: [PATCH 26/34] fix errors in tictac addon
---
tictac/tictac.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/tictac/tictac.php b/tictac/tictac.php
index 10103835..082b58c1 100644
--- a/tictac/tictac.php
+++ b/tictac/tictac.php
@@ -7,7 +7,6 @@
* Status: unsupported
*/
-use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@@ -30,7 +29,12 @@ function tictac_module() {}
function tictac_content() {
- $o = '';
+ $o = '';
+ $dimen = 3;
+ $handicap = 0;
+ $mefirst = 0;
+ $yours = '';
+ $mine = '';
if($_POST['move']) {
$handicap = DI::args()->get(1);
@@ -45,9 +49,6 @@ function tictac_content() {
$handicap = DI::args()->get(1);
$dimen = 3;
}
- else {
- $dimen = 3;
- }
$o .= '' . DI::l10n()->t('3D Tic-Tac-Toe') . ' ';
@@ -163,7 +164,7 @@ class tictac {
];
function __construct($dimen, $handicap, $mefirst, $yours, $mine) {
- $this->dimen = 3;
+ $this->dimen = $dimen;
$this->handicap = $handicap ? 1 : 0;
$this->mefirst = $mefirst ? 1 : 0;
$this->yours = str_replace('XXX','',$yours);
@@ -228,6 +229,8 @@ class tictac {
}
function parse_moves($player) {
+ $str = '';
+
if($player == 'me')
$str = $this->mine;
if($player == 'you')
From 15c21cebb1bccd48a598c61d06b25d6fd8a43eb9 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 30 Nov 2024 20:36:58 +0000
Subject: [PATCH 27/34] Fix errors in wppost addon
---
wppost/wppost.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/wppost/wppost.php b/wppost/wppost.php
index dba738de..f2ee5d21 100644
--- a/wppost/wppost.php
+++ b/wppost/wppost.php
@@ -259,9 +259,11 @@ EOT;
Logger::debug('wppost: data: ' . $xml);
+ $x = '';
+
if ($wp_blog !== 'test') {
$x = DI::httpClient()->post($wp_blog, $xml)->getBodyString();
}
- Logger::info('posted to wordpress: ' . (($x) ? $x : ''));
+ Logger::info('posted to wordpress: ' . $x);
}
}
From 82ed43f5076f8d14f7562ab68daf97b8ce8a0afa Mon Sep 17 00:00:00 2001
From: Art4
Date: Sat, 7 Dec 2024 22:08:59 +0000
Subject: [PATCH 28/34] Fix errors
---
curweather/curweather.php | 4 ++--
js_upload/file-uploader/server/php.php | 8 ++++----
membersince/membersince.php | 7 +++----
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/curweather/curweather.php b/curweather/curweather.php
index 9aa8584a..e5e2710d 100644
--- a/curweather/curweather.php
+++ b/curweather/curweather.php
@@ -29,10 +29,10 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
$now = new DateTime();
if (!is_null($cached)) {
- $cdate = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last');
+ $cdate = (int) DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last');
$cached = unserialize($cached);
- if ($cdate + $cachetime > $now->getTimestamp()) {
+ if ($cdate + (int) $cachetime > $now->getTimestamp()) {
return $cached;
}
}
diff --git a/js_upload/file-uploader/server/php.php b/js_upload/file-uploader/server/php.php
index 2248c8f0..ff485dec 100644
--- a/js_upload/file-uploader/server/php.php
+++ b/js_upload/file-uploader/server/php.php
@@ -77,10 +77,10 @@ class qqFileUploader {
public function __construct(array $allowedExtensions = [], $sizeLimit = 10485760)
{
$allowedExtensions = array_map('strtolower', $allowedExtensions);
-
+
$this->allowedExtensions = $allowedExtensions;
$this->sizeLimit = $sizeLimit;
-
+
$this->checkServerSettings();
if (isset($_GET['qqfile'])) {
@@ -88,7 +88,7 @@ class qqFileUploader {
} elseif (isset($_FILES['qqfile'])) {
$this->file = new qqUploadedFileForm();
} else {
- $this->file = false;
+ $this->file = false;
}
}
@@ -105,7 +105,7 @@ class qqFileUploader {
private function toBytes(string $str): int
{
- $val = trim($str);
+ $val = (int) trim($str);
$last = strtolower($str[strlen($str) - 1]);
switch($last) {
diff --git a/membersince/membersince.php b/membersince/membersince.php
index f8128eb7..20e41ac9 100644
--- a/membersince/membersince.php
+++ b/membersince/membersince.php
@@ -7,7 +7,6 @@
* Status: Unsupported
*/
-use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Util\DateTimeFormat;
@@ -19,7 +18,7 @@ function membersince_install()
function membersince_display(array &$b)
{
- if (DI::app()->getCurrentTheme() == 'frio') {
+ if (DI::appHelper()->getCurrentTheme() == 'frio') {
// Works in Frio.
$doc = new DOMDocument();
$doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
@@ -39,7 +38,7 @@ function membersince_display(array &$b)
$label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
// The div for the register date of the profile owner.
- $entry = $doc->createElement('div', DateTimeFormat::local(DI::app()->profile['register_date']));
+ $entry = $doc->createElement('div', DateTimeFormat::local(DI::appHelper()->profile['register_date']));
$entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
$div->appendChild($hr);
@@ -50,6 +49,6 @@ function membersince_display(array &$b)
$b = $doc->saveHTML();
} else {
// Works in Vier.
- $b = preg_replace('/<\/dl>/', "\n\n\n\n" . DI::l10n()->t('Member since:') . " \n" . DateTimeFormat::local(DI::app()->profile['register_date']) . " \n ", $b, 1);
+ $b = preg_replace('/<\/dl>/', "\n\n\n\n" . DI::l10n()->t('Member since:') . " \n" . DateTimeFormat::local(DI::appHelper()->profile['register_date']) . " \n ", $b, 1);
}
}
From 5b13274bed5c7f944a35b5b63739aba140e4bb1c Mon Sep 17 00:00:00 2001
From: Art4
Date: Sun, 8 Dec 2024 21:02:07 +0000
Subject: [PATCH 29/34] Fix class name collision
---
js_upload/js_upload.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php
index 0d045dee..f1d85aa3 100644
--- a/js_upload/js_upload.php
+++ b/js_upload/js_upload.php
@@ -60,7 +60,7 @@ function js_upload_post_init(array &$b)
// max file size in bytes
$sizeLimit = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
- $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
+ $uploader = new js_upload_qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload();
@@ -101,7 +101,7 @@ function js_upload_post_end(int &$b)
/**
* Handle file uploads via XMLHttpRequest
*/
-class qqUploadedFileXhr
+class js_upload_qqUploadedFileXhr
{
private $pathnm = '';
@@ -155,7 +155,7 @@ class qqUploadedFileXhr
/**
* Handle file uploads via regular form post (uses the $_FILES array)
*/
-class qqUploadedFileForm
+class js_upload_qqUploadedFileForm
{
/**
* Save the file to the specified path
@@ -183,7 +183,7 @@ class qqUploadedFileForm
}
}
-class qqFileUploader
+class js_upload_qqFileUploader
{
private $allowedExtensions;
private $sizeLimit;
@@ -197,9 +197,9 @@ class qqFileUploader
$this->sizeLimit = $sizeLimit;
if (isset($_GET['qqfile'])) {
- $this->file = new qqUploadedFileXhr();
+ $this->file = new js_upload_qqUploadedFileXhr();
} elseif (isset($_FILES['qqfile'])) {
- $this->file = new qqUploadedFileForm();
+ $this->file = new js_upload_qqUploadedFileForm();
} else {
$this->file = false;
}
From 2fe37c6d4a26a795b5c06cf15a90b6b4a2d363fb Mon Sep 17 00:00:00 2001
From: Art4
Date: Sun, 8 Dec 2024 21:24:03 +0000
Subject: [PATCH 30/34] Fix errors in pnut addon
---
mailstream/phpmailer/class.phpmailer.php | 1 -
pnut/lib/phpnut.php | 17 +++++++----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/mailstream/phpmailer/class.phpmailer.php b/mailstream/phpmailer/class.phpmailer.php
index dcf02361..3aec2255 100644
--- a/mailstream/phpmailer/class.phpmailer.php
+++ b/mailstream/phpmailer/class.phpmailer.php
@@ -1519,7 +1519,6 @@ class PHPMailer
public function getSMTPInstance()
{
if (!is_object($this->smtp)) {
- /** @phpstan-ignore-next-line file class.smtp.php does not exist */
$this->smtp = new SMTP;
}
return $this->smtp;
diff --git a/pnut/lib/phpnut.php b/pnut/lib/phpnut.php
index 89d5e5f8..a8e97db4 100644
--- a/pnut/lib/phpnut.php
+++ b/pnut/lib/phpnut.php
@@ -108,7 +108,7 @@ class phpnut
/**
* Constructs an phpnut PHP object with the specified client ID and
* client secret.
- * @param string $client_id The client ID you received from pnut.io when
+ * @param string $client_id_or_token The client ID you received from pnut.io when
* creating your app.
* @param string $client_secret The client secret you received from
* pnut.io when creating your app.
@@ -161,7 +161,7 @@ class phpnut
* or not access to your app. Usually you would place this as a link for
* the user to client, or a redirect to send them to the auth URL.
* Also can be called after authentication for additional scopes
- * @param string $callbackUri Where you want the user to be directed
+ * @param string $callback_uri Where you want the user to be directed
* after authenticating with pnut.io. This must be one of the URIs
* allowed by your pnut.io application settings.
* @param array $scope An array of scopes (permissions) you wish to obtain
@@ -748,7 +748,7 @@ class phpnut
* Delete a Post. The current user must be the same user who created the Post.
* It returns the deleted Post on success.
* @param integer $post_id The ID of the post to delete
- * @param array An associative array representing the post that was deleted
+ * @return array An associative array representing the post that was deleted
*/
public function deletePost(int $post_id)
{
@@ -1296,7 +1296,7 @@ class phpnut
/**
* List the users who match a specific search term
- * @param string $search The search query. Supports @username or #tag searches as
+ * @param string $query The search query. Supports @username or #tag searches as
* well as normal search terms. Searches username, display name, bio information.
* Does not search posts.
* @return array|false An array of associative arrays, each representing one user.
@@ -2023,7 +2023,7 @@ class phpnut
/**
* Responds to a poll.
* @param integer $poll_id The ID of the poll to respond to
- * @param array list of positions for the poll response
+ * @param array $positions list of positions for the poll response
* @param array $params An associative array of optional general parameters.
*/
public function respondToPoll(int $poll_id, array $positions, array $params=[])
@@ -2098,8 +2098,6 @@ class phpnut
* List the polls that match a specific search term
* @param array $params a list of filter, search query, and general Poll parameters
* see: https://docs.pnut.io/resources/channels/search
- * @param string $query The search query. Supports
- * normal search terms.
* @return array An array of associative arrays, each representing one poll.
* or false on error
*/
@@ -2186,7 +2184,7 @@ class phpnut
* whenever an event is received via an open pnut.io stream. Your function
* will receive a single parameter, which is the object wrapper containing
* the meta and data.
- * @param mixed A PHP callback (either a string containing the function name,
+ * @param mixed $fuction A PHP callback (either a string containing the function name,
* or an array where the first element is the class/object and the second
* is the method).
*/
@@ -2247,7 +2245,6 @@ class phpnut
/**
* Close the currently open stream.
- * @return true;
*/
public function closeStream(): void
{
@@ -2460,7 +2457,7 @@ class phpnut
* Process an open stream for x microseconds, then return. This is useful if you want
* to be doing other things while processing the stream. If you just want to
* consume the stream without other actions, you can call processForever() instead.
- * @param float @microseconds The number of microseconds to process for before
+ * @param null|float $microseconds The number of microseconds to process for before
* returning. There are 1,000,000 microseconds in a second.
*
* @return void
From 89a673cc11f840a856d2e4f703f12d0f383fd252 Mon Sep 17 00:00:00 2001
From: Art4
Date: Sun, 8 Dec 2024 22:19:58 +0000
Subject: [PATCH 31/34] Fix typo
---
pnut/lib/phpnut.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/pnut/lib/phpnut.php b/pnut/lib/phpnut.php
index a8e97db4..ff765243 100644
--- a/pnut/lib/phpnut.php
+++ b/pnut/lib/phpnut.php
@@ -2177,14 +2177,12 @@ class phpnut
);
}
-
-
/**
* Registers your function (or an array of object and method) to be called
* whenever an event is received via an open pnut.io stream. Your function
* will receive a single parameter, which is the object wrapper containing
* the meta and data.
- * @param mixed $fuction A PHP callback (either a string containing the function name,
+ * @param mixed $function A PHP callback (either a string containing the function name,
* or an array where the first element is the class/object and the second
* is the method).
*/
From b99ac65c0bbca1b5c8c94922fe1114b3501c953e Mon Sep 17 00:00:00 2001
From: Art4
Date: Sun, 8 Dec 2024 22:49:23 +0000
Subject: [PATCH 32/34] Fix errors in membersince addon
---
membersince/membersince.php | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/membersince/membersince.php b/membersince/membersince.php
index 20e41ac9..448b8cf2 100644
--- a/membersince/membersince.php
+++ b/membersince/membersince.php
@@ -9,6 +9,7 @@
use Friendica\Core\Hook;
use Friendica\DI;
+use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
function membersince_install()
@@ -18,6 +19,18 @@ function membersince_install()
function membersince_display(array &$b)
{
+ $uid = DI::userSession()->getLocalUserId();
+
+ if ($uid === false) {
+ return;
+ }
+
+ $user = User::getById($uid, ['register_date']);
+
+ if ($user === false || !array_key_exists('register_date', $user)) {
+ return;
+ }
+
if (DI::appHelper()->getCurrentTheme() == 'frio') {
// Works in Frio.
$doc = new DOMDocument();
@@ -38,7 +51,7 @@ function membersince_display(array &$b)
$label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
// The div for the register date of the profile owner.
- $entry = $doc->createElement('div', DateTimeFormat::local(DI::appHelper()->profile['register_date']));
+ $entry = $doc->createElement('div', DateTimeFormat::local($user['register_date']));
$entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
$div->appendChild($hr);
@@ -49,6 +62,6 @@ function membersince_display(array &$b)
$b = $doc->saveHTML();
} else {
// Works in Vier.
- $b = preg_replace('/<\/dl>/', "\n\n\n\n" . DI::l10n()->t('Member since:') . " \n" . DateTimeFormat::local(DI::appHelper()->profile['register_date']) . " \n ", $b, 1);
+ $b = preg_replace('/<\/dl>/', "\n\n\n\n" . DI::l10n()->t('Member since:') . " \n" . DateTimeFormat::local($user['register_date']) . " \n ", $b, 1);
}
}
From cfb6b3123f9a3e593c4316967ebefc78e01c4bba Mon Sep 17 00:00:00 2001
From: Art4
Date: Sun, 8 Dec 2024 23:06:51 +0000
Subject: [PATCH 33/34] Fix errors in statusnet addon
---
statusnet/library/codebirdsn.php | 24 +++++++++++++-----------
statusnet/library/statusnetoauth.php | 5 -----
statusnet/library/twitteroauth.php | 4 +---
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/statusnet/library/codebirdsn.php b/statusnet/library/codebirdsn.php
index 91e256be..70743356 100644
--- a/statusnet/library/codebirdsn.php
+++ b/statusnet/library/codebirdsn.php
@@ -116,7 +116,7 @@ class CodebirdSN
* Returns singleton class instance
* Always use this method unless you're working with multiple authenticated users at once
*
- * @return Codebird The instance
+ * @return CodebirdSN The instance
*/
public static function getInstance()
{
@@ -420,6 +420,7 @@ class CodebirdSN
}
break;
case CODEBIRD_RETURNFORMAT_OBJECT:
+ /** @var object $reply */
$reply->httpstatus = $httpstatus;
if ($httpstatus == 200) {
self::setBearerToken($reply->access_token);
@@ -490,7 +491,7 @@ class CodebirdSN
/**
* Generates a (hopefully) unique random string
*
- * @param int optional $length The length of the string to generate
+ * @param int $length The optional length of the string to generate
*
* @return string The random string
*/
@@ -505,9 +506,9 @@ class CodebirdSN
/**
* Generates an OAuth signature
*
- * @param string $httpmethod Usually either 'GET' or 'POST' or 'DELETE'
- * @param string $method The API method to call
- * @param array optional $params The API call parameters, associative
+ * @param string $httpmethod Usually either 'GET' or 'POST' or 'DELETE'
+ * @param string $method The API method to call
+ * @param array $params optional The API call parameters, associative
*
* @return string Authorization HTTP header
*/
@@ -871,12 +872,12 @@ class CodebirdSN
/**
* Calls the API using cURL
*
- * @param string $httpmethod The HTTP method to use for making the request
- * @param string $method The API method to call
- * @param string $method_template The templated API method to call
- * @param array optional $params The parameters to send along
- * @param bool optional $multipart Whether to use multipart/form-data
- * @param bool optional $app_only_auth Whether to use app-only bearer authentication
+ * @param string $httpmethod The HTTP method to use for making the request
+ * @param string $method The API method to call
+ * @param string $method_template The templated API method to call
+ * @param array $params optional The parameters to send along
+ * @param bool $multipart optional Whether to use multipart/form-data
+ * @param bool $app_only_auth optional Whether to use app-only bearer authentication
*
* @return mixed The API reply, encoded in the set return_format
*/
@@ -959,6 +960,7 @@ class CodebirdSN
$httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$reply = $this->_parseApiReply($method_template, $reply);
if ($this->_return_format == CODEBIRD_RETURNFORMAT_OBJECT) {
+ /** @var object $reply */
$reply->httpstatus = $httpstatus;
} elseif ($this->_return_format == CODEBIRD_RETURNFORMAT_ARRAY) {
$reply['httpstatus'] = $httpstatus;
diff --git a/statusnet/library/statusnetoauth.php b/statusnet/library/statusnetoauth.php
index c9bb0163..c32b2b4f 100644
--- a/statusnet/library/statusnetoauth.php
+++ b/statusnet/library/statusnetoauth.php
@@ -52,11 +52,6 @@ class StatusNetOAuth extends TwitterOAuth
*
* Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
*
- * @param string $method
- * @param string $host
- * @param string $path
- * @param array $parameters
- *
* @return array|object API results
*/
function http($url, $method, $postfields = NULL)
diff --git a/statusnet/library/twitteroauth.php b/statusnet/library/twitteroauth.php
index b33b5f9d..bf413d23 100644
--- a/statusnet/library/twitteroauth.php
+++ b/statusnet/library/twitteroauth.php
@@ -93,7 +93,7 @@ class TwitterOAuth
/**
* Get a request_token
*
- * @param callback $oauth_callback
+ * @param callable $oauth_callback
* @return array
*/
function getRequestToken($oauth_callback = null)
@@ -112,8 +112,6 @@ class TwitterOAuth
/**
* Get the authorize URL
*
- * @param array $token
- * @param bool $sign_in_with_tumblr
* @return string
*/
function getAuthorizeURL($token, $sign_in_with_twitter = TRUE)
From fff140ad4360376df6b2e9cb58ac4d2986baee73 Mon Sep 17 00:00:00 2001
From: Art4
Date: Mon, 9 Dec 2024 23:08:31 +0000
Subject: [PATCH 34/34] Fix last 3 errors
---
showmore/showmore.php | 2 +-
statusnet/library/codebirdsn.php | 2 ++
tesseract/tesseract.php | 3 ++-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/showmore/showmore.php b/showmore/showmore.php
index 8e85925a..e326aa98 100644
--- a/showmore/showmore.php
+++ b/showmore/showmore.php
@@ -8,7 +8,6 @@
*
*/
-use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@@ -79,6 +78,7 @@ function get_body_length($body)
* Checking any possible syntax of the style attribute with xpath is impossible
* So we just get any element with a style attribute, and check them with a regexp
*/
+ /** @var DOMNodeList $xr */
$xr = $xpath->query('//*[@style]');
foreach ($xr as $node) {
if (preg_match('/.*display: *none *;.*/',$node->getAttribute('style'))) {
diff --git a/statusnet/library/codebirdsn.php b/statusnet/library/codebirdsn.php
index 70743356..9807d97f 100644
--- a/statusnet/library/codebirdsn.php
+++ b/statusnet/library/codebirdsn.php
@@ -54,6 +54,8 @@ unset($id);
*
* @package codebird
* @subpackage codebird-php
+ *
+ * @method object statuses_update(array $postdata)
*/
class CodebirdSN
{
diff --git a/tesseract/tesseract.php b/tesseract/tesseract.php
index b3e1feb6..4c630dbb 100644
--- a/tesseract/tesseract.php
+++ b/tesseract/tesseract.php
@@ -26,6 +26,7 @@ function tesseract_ocr_detection(&$media)
try {
$languages = $ocr->availableLanguages();
if ($languages) {
+ /** @phpstan-ignore-next-line ignore call of \thiagoalessio\TesseractOCR\Option::lang() */
$ocr->lang(implode('+', $languages));
}
$ocr->tempDir(System::getTempPath());
@@ -33,5 +34,5 @@ function tesseract_ocr_detection(&$media)
$media['description'] = $ocr->run();
} catch (\Throwable $th) {
Logger::info('Error calling TesseractOCR', ['message' => $th->getMessage()]);
- }
+ }
}