Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psalm fixes 3 #17221

Merged
merged 7 commits into from Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/classes/Controllers/Export/ExportController.php
Expand Up @@ -286,15 +286,15 @@ public function __invoke(ServerRequest $request): void
$buffer_needed = true;
}

if (($quick_export && ! empty($quickExportOnServer)) || (! $quick_export && ! empty($onServerParam))) {
if (($quick_export && $quickExportOnServer) || (! $quick_export && $onServerParam)) {
if ($quick_export) {
$onserver = $quickExportOnServer;
} else {
$onserver = $onServerParam;
}

// Will we save dump on server?
$save_on_server = ! empty($cfg['SaveDir']) && $onserver;
$save_on_server = ! empty($cfg['SaveDir']);
}
}

Expand Down
18 changes: 9 additions & 9 deletions libraries/classes/Database/Qbe.php
Expand Up @@ -231,7 +231,7 @@ class Qbe
* Current search
*
* @access private
* @var SavedSearches
* @var SavedSearches|null
*/
private $currentSearch = null;

Expand All @@ -245,12 +245,12 @@ class Qbe
public $template;

/**
* @param Relation $relation Relation object
* @param Template $template Template object
* @param DatabaseInterface $dbi DatabaseInterface object
* @param string $dbname Database name
* @param array $savedSearchList List of saved searches
* @param SavedSearches $currentSearch Current search id
* @param Relation $relation Relation object
* @param Template $template Template object
* @param DatabaseInterface $dbi DatabaseInterface object
* @param string $dbname Database name
* @param array $savedSearchList List of saved searches
* @param SavedSearches|null $currentSearch Current search id
*/
public function __construct(
Relation $relation,
Expand Down Expand Up @@ -293,7 +293,7 @@ private function loadCriterias()
/**
* Getter for current search
*
* @return SavedSearches
* @return SavedSearches|null
*/
private function getCurrentSearch()
{
Expand Down Expand Up @@ -1709,7 +1709,7 @@ private function getSavedSearchesField()
$currentSearch = $this->getCurrentSearch();
$currentSearchId = null;
$currentSearchName = null;
if ($currentSearch != null) {
if ($currentSearch !== null) {
$currentSearchId = $currentSearch->getId();
$currentSearchName = $currentSearch->getSearchName();
}
Expand Down
7 changes: 3 additions & 4 deletions libraries/classes/Database/Triggers.php
Expand Up @@ -267,7 +267,7 @@ public function handleEditor(): void
$mode = 'edit';
}

$this->sendEditor($mode, $item, $title, $db);
$this->sendEditor($mode, $item, $title, $db, $table);
}

/**
Expand Down Expand Up @@ -449,11 +449,10 @@ private function checkResult($result, $createStatement, array $errors)
* @param array|null $item Data necessary to create the editor
* @param string $title Title of the editor
* @param string $db Database
* @param string $table Table
*/
private function sendEditor($mode, ?array $item, $title, $db): void
private function sendEditor($mode, ?array $item, $title, $db, $table): void
{
global $db, $table;

if ($item !== null) {
$editor = $this->getEditorForm($db, $table, $mode, $item);
if ($this->response->isAjax()) {
Expand Down
3 changes: 0 additions & 3 deletions libraries/classes/Display/Results.php
Expand Up @@ -1061,7 +1061,6 @@ private function getTableHeadersForColumns(
$fieldsMeta[$i],
$sortExpression,
$sortExpressionNoDirection,
$i,
$unsortedSqlQuery,
$sessionMaxRows,
$comments,
Expand Down Expand Up @@ -1575,7 +1574,6 @@ private function getCommentForRow(array $commentsMap, FieldMetadata $fieldsMeta)
* @param FieldMetadata $fieldsMeta set of field properties
* @param array $sortExpression sort expression
* @param array $sortExpressionNoDirection sort expression without direction
* @param int $columnIndex the index of the column
* @param string $unsortedSqlQuery the unsorted sql query
* @param int $sessionMaxRows maximum rows resulted by sql
* @param string $comments comment for row
Expand All @@ -1591,7 +1589,6 @@ private function getOrderLinkAndSortedHeaderHtml(
FieldMetadata $fieldsMeta,
array $sortExpression,
array $sortExpressionNoDirection,
$columnIndex,
$unsortedSqlQuery,
$sessionMaxRows,
$comments,
Expand Down
4 changes: 1 addition & 3 deletions libraries/classes/Plugins/Export/ExportSql.php
Expand Up @@ -1865,7 +1865,6 @@ public function getTableDef(
*
* @param string $db database name
* @param string $table table name
* @param string $crlf end of line sequence
* @param bool $doRelation whether to include relation comments
* @param bool $doMime whether to include mime comments
* @param array $aliases Aliases of db/table/columns
Expand All @@ -1875,7 +1874,6 @@ public function getTableDef(
private function getTableComments(
$db,
$table,
$crlf,
$doRelation = false,
$doMime = false,
array $aliases = []
Expand Down Expand Up @@ -2076,7 +2074,7 @@ public function exportStructure(
);
$dump .= $this->exportComment();
$dump .= $this->getTableDef($db, $table, $crlf, $errorUrl, $dates, true, false, true, $aliases);
$dump .= $this->getTableComments($db, $table, $crlf, $relation, $mime, $aliases);
$dump .= $this->getTableComments($db, $table, $relation, $mime, $aliases);
break;
case 'triggers':
$dump = '';
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Server/Privileges.php
Expand Up @@ -2038,7 +2038,7 @@ public function getHtmlForAllTableSpecificRights(
* Get HTML for display the users overview
* (if less than 50 users, display them immediately)
*
* @param array $result ran sql query
* @param object $result ran sql query
* @param array $dbRights user's database rights array
* @param string $textDir text directory
*
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Utils/HttpRequest.php
Expand Up @@ -98,7 +98,7 @@ private function handleContext(array $context)
];
if (strlen($this->proxyUser) > 0) {
$auth = base64_encode($this->proxyUser . ':' . $this->proxyPass);
$context['http']['header'] .= 'Proxy-Authorization: Basic '
$context['http']['header'] = 'Proxy-Authorization: Basic '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already reviewed this while checking code mistakes
I am not sure it should be changed
There was something that made this concat sill have some sense
Not sure what

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will check it more carefully. I wasn't actually bothered to set up an environment for this to test as I need to disable CURL and enable allow_url_fopen. Let me see if it really throws an error as I'd expect it to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked it and when using concatenation it throws Undefined array key "header" error. Maybe in the past the code looked different and the concatenation made sense. As of now, I can't see any possibility that the code does not throw a warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

If I remember maybe this code is a bug because it would erase all the other headers
Not sure anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this looks like a bug. But if it is a bug then I do not know what was the desired behaviour. The name of the method is handleContext which doesn't tell us much about what the method should do. Let's remove the concatenation for now, and if someone wants to study this code in the future, they can fix the logic.

. $auth . "\r\n";
}
}
Expand Down
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Expand Up @@ -310,11 +310,6 @@ parameters:
count: 1
path: libraries/classes/Database/Qbe.php

-
message: "#^Property PhpMyAdmin\\\\Database\\\\Qbe\\:\\:\\$currentSearch \\(PhpMyAdmin\\\\SavedSearches\\) does not accept PhpMyAdmin\\\\SavedSearches\\|null\\.$#"
count: 1
path: libraries/classes/Database/Qbe.php

-
message: "#^Property PhpMyAdmin\\\\Database\\\\Qbe\\:\\:\\$formAndOrCols \\(array\\) in isset\\(\\) is not nullable\\.$#"
count: 1
Expand Down Expand Up @@ -1140,16 +1135,6 @@ parameters:
count: 1
path: libraries/classes/Server/Privileges.php

-
message: "#^Parameter \\#1 \\$result of method PhpMyAdmin\\\\DatabaseInterface\\:\\:fetchAssoc\\(\\) expects object, array given\\.$#"
count: 1
path: libraries/classes/Server/Privileges.php

-
message: "#^Parameter \\#1 \\$result of method PhpMyAdmin\\\\DatabaseInterface\\:\\:freeResult\\(\\) expects object, array given\\.$#"
count: 1
path: libraries/classes/Server/Privileges.php

-
message: "#^Parameter \\#1 \\$result of method PhpMyAdmin\\\\DatabaseInterface\\:\\:freeResult\\(\\) expects object, array\\|float\\|int\\|string\\|false\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -1355,11 +1340,6 @@ parameters:
count: 1
path: libraries/classes/Util.php

-
message: "#^Offset 'header' does not exist on array\\{proxy\\: non\\-empty\\-string, request_fulluri\\: true\\}\\.$#"
count: 1
path: libraries/classes/Utils/HttpRequest.php

-
message: "#^Variable \\$http_response_header in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
Expand Down