Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19497 from MauricioFauth/csv-excel-expo…
Browse files Browse the repository at this point in the history
…rt-plugin

Remove excel_* and csv_* global variables
  • Loading branch information
MauricioFauth authored Jan 6, 2025
2 parents ef9ecd7 + 6e8e98c commit a6350ad
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 381 deletions.
81 changes: 33 additions & 48 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11428,35 +11428,11 @@ parameters:
path: src/Plugins/Export/ExportCodegen.php

-
message: '#^Binary operation "\." between mixed and \(list\<string\>\|string\) results in an error\.$#'
message: '#^Binary operation "\." between non\-empty\-string and \(list\<string\>\|string\) results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/Plugins/Export/ExportCsv.php

-
message: '#^Binary operation "\." between mixed and mixed results in an error\.$#'
identifier: binaryOp.invalid
count: 4
path: src/Plugins/Export/ExportCsv.php

-
message: '#^Binary operation "\." between mixed and string results in an error\.$#'
identifier: binaryOp.invalid
count: 2
path: src/Plugins/Export/ExportCsv.php

-
message: '#^Binary operation "\." between non\-empty\-string and mixed results in an error\.$#'
identifier: binaryOp.invalid
count: 3
path: src/Plugins/Export/ExportCsv.php

-
message: '#^Binary operation "\." between string and mixed results in an error\.$#'
identifier: binaryOp.invalid
count: 2
path: src/Plugins/Export/ExportCsv.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
Expand Down Expand Up @@ -11487,56 +11463,65 @@ parameters:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 2
count: 1
path: src/Plugins/Export/ExportCsv.php

-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Plugins/Export/ExportCsv.php

-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
message: '#^Binary operation "\." between non\-empty\-string and \(list\<string\>\|string\) results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/Plugins/Export/ExportExcel.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
Use dependency injection instead\.$#
'''
identifier: staticMethod.deprecated
count: 2
path: src/Plugins/Export/ExportCsv.php
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#'
identifier: booleanAnd.rightNotBoolean
count: 3
path: src/Plugins/Export/ExportCsv.php
message: '#^Cannot access offset ''columns'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Parameter \#1 \$search of function str_replace expects array\<string\>\|string, mixed given\.$#'
identifier: argument.type
count: 4
path: src/Plugins/Export/ExportCsv.php
message: '#^Cannot access offset ''tables'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Parameter \#1 \$separator of function implode expects array\|string, mixed given\.$#'
identifier: argument.type
message: '#^Cannot access offset string on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: src/Plugins/Export/ExportCsv.php
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Parameter \#1 \$string of function mb_strtolower expects string, mixed given\.$#'
identifier: argument.type
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 1
path: src/Plugins/Export/ExportCsv.php
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, mixed given\.$#'
identifier: argument.type
count: 3
path: src/Plugins/Export/ExportCsv.php
count: 1
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, string\|null given\.$#'
identifier: argument.type
count: 3
path: src/Plugins/Export/ExportCsv.php
path: src/Plugins/Export/ExportExcel.php

-
message: '#^Binary operation "\." between ''\<html xmlns\:o\="urn…'' and mixed results in an error\.$#'
Expand Down
84 changes: 16 additions & 68 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1418,17 +1418,6 @@
<MixedAssignment>
<code><![CDATA[$GLOBALS['charset']]]></code>
<code><![CDATA[$GLOBALS['compression']]]></code>
<code><![CDATA[$GLOBALS['csv_columns']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_null']]]></code>
<code><![CDATA[$GLOBALS['csv_removeCRLF']]]></code>
<code><![CDATA[$GLOBALS['csv_separator']]]></code>
<code><![CDATA[$GLOBALS['csv_terminated']]]></code>
<code><![CDATA[$GLOBALS['excel_columns']]]></code>
<code><![CDATA[$GLOBALS['excel_edition']]]></code>
<code><![CDATA[$GLOBALS['excel_null']]]></code>
<code><![CDATA[$GLOBALS['excel_removeCRLF']]]></code>
<code><![CDATA[$GLOBALS['knjenc']]]></code>
<code><![CDATA[$GLOBALS['maxsize']]]></code>
<code><![CDATA[$GLOBALS['save_filename']]]></code>
Expand Down Expand Up @@ -6730,53 +6719,32 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['csv_null']]]></code>
<code><![CDATA[$GLOBALS['csv_removeCRLF']]]></code>
<code><![CDATA[$GLOBALS['excel_columns']]]></code>
<code><![CDATA[$GLOBALS['excel_null']]]></code>
<code><![CDATA[$GLOBALS['excel_removeCRLF']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$colAs]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$insertFields]]></code>
<code><![CDATA[$insertValues]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$colAs]]></code>
<code><![CDATA[$insertFields[]]]></code>
<code><![CDATA[$insertValues[]]]></code>
</MixedAssignment>
<PossiblyNullArgument>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_separator']]]></code>
</PossiblyNullArgument>
<PossiblyNullOperand>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_escaped']]]></code>
<code><![CDATA[$GLOBALS['csv_terminated']]]></code>
<code><![CDATA[$GLOBALS['csv_terminated']]]></code>
</PossiblyNullOperand>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($GLOBALS['csv_terminated'])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Plugins/Export/ExportExcel.php">
<DeprecatedMethod>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<MixedArgument>
<code><![CDATA[$colAs]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$insertFields]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$colAs]]></code>
<code><![CDATA[$insertFields[]]]></code>
</MixedAssignment>
</file>
<file src="src/Plugins/Export/ExportHtmlword.php">
<DeprecatedMethod>
Expand Down Expand Up @@ -12741,26 +12709,6 @@
<code><![CDATA[providerForTestValidPlugins]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/unit/Plugins/Export/ExportExcelTest.php">
<DocblockTypeContradiction>
<code><![CDATA[assertSame]]></code>
</DocblockTypeContradiction>
<RedundantCondition>
<code><![CDATA[assertFalse]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertTrue]]></code>
</RedundantCondition>
<RedundantConditionGivenDocblockType>
<code><![CDATA[assertFalse]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertSame]]></code>
<code><![CDATA[assertSame]]></code>
</RedundantConditionGivenDocblockType>
</file>
<file src="tests/unit/Plugins/Export/ExportHtmlwordTest.php">
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
Expand Down
6 changes: 0 additions & 6 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,9 @@
complete_query: string,
compression: 'none'|'zip'|'gzip',
conn_error: string,
csv_columns: bool,
csv_enclosed: string,
csv_escaped: string,
csv_separator: string,
csv_terminated: string,
display_query: string,
errno: int,
error: bool,
excel_edition: 'win'|'mac_excel2003'|'mac_excel2008',
file_handle: resource|null,
from_cookie: bool,
hostname: string,
Expand Down
49 changes: 3 additions & 46 deletions src/Controllers/Export/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,53 +489,10 @@ private function setGlobalsFromRequest(array $postParams): void
$GLOBALS['knjenc'] = $postParams['knjenc'];
}

if (isset($postParams['xkana'])) {
$GLOBALS['xkana'] = $postParams['xkana'];
if (! isset($postParams['xkana'])) {
return;
}

if (isset($postParams['excel_null'])) {
$GLOBALS['excel_null'] = $postParams['excel_null'];
}

if (isset($postParams['excel_removeCRLF'])) {
$GLOBALS['excel_removeCRLF'] = $postParams['excel_removeCRLF'];
}

if (isset($postParams['excel_columns'])) {
$GLOBALS['excel_columns'] = $postParams['excel_columns'];
}

if (isset($postParams['excel_edition'])) {
$GLOBALS['excel_edition'] = $postParams['excel_edition'];
}

if (isset($postParams['csv_separator'])) {
$GLOBALS['csv_separator'] = $postParams['csv_separator'];
}

if (isset($postParams['csv_enclosed'])) {
$GLOBALS['csv_enclosed'] = $postParams['csv_enclosed'];
}

if (isset($postParams['csv_escaped'])) {
$GLOBALS['csv_escaped'] = $postParams['csv_escaped'];
}

if (isset($postParams['csv_terminated'])) {
$GLOBALS['csv_terminated'] = $postParams['csv_terminated'];
}

if (isset($postParams['csv_null'])) {
$GLOBALS['csv_null'] = $postParams['csv_null'];
}

if (isset($postParams['csv_removeCRLF'])) {
$GLOBALS['csv_removeCRLF'] = $postParams['csv_removeCRLF'];
}

// phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
if (isset($postParams['csv_columns'])) {
$GLOBALS['csv_columns'] = $postParams['csv_columns'];
}
$GLOBALS['xkana'] = $postParams['xkana'];
}
}
Loading

0 comments on commit a6350ad

Please sign in to comment.