Commit Graph

138 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
20ebad0ec5
Merge pull request #17410 from kamil-tekiela/pr/17211
transfer the HTML content in InsertEdit.php for a twig file
2022-03-04 12:24:03 -03:00
Kamil Tekiela
aa9c6d7b3a Apply code style and fix issues
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-02-20 16:35:49 +00:00
Kamil Tekiela
848c4ef172 Fix broken Insert page
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-02-18 14:14:22 +00:00
Kamil Tekiela
86031d2bf6 Deimplement fetchAssoc() helper
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-09 22:44:53 +00:00
Kamil Tekiela
83b4dda1a3 Change QUERY_STORE to QUERY_BUFFERED
Set the value to 0 instead of 1 and remove all unnecessary usages of this constant

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-01 01:46:01 +00:00
Kamil Tekiela
47a039d70c Implement ResultInterface & MysqliResult
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-31 23:59:24 +00:00
Maurício Meneghini Fauth
400c9e1d93
Merge pull request #17204 from kamil-tekiela/Refactor-DatabaseInterface-getColumns()
Refactor DatabaseInterface::getColumns()
2021-11-26 15:07:20 -03:00
Kamil Tekiela
22a6fc9045
Minor refactoring of InsertEdit.php (#17199)
* Simplify condition

isset is not needed since the variable is set and we check explicitely for an array so it cannot be null either.
!empty is not needed because the variable is set, so we just need to check if it has non-empty value

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Reduce indentation thanks to early returns

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Collapse isset check

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant variable assignments

$specialCharsEncoded is immediately overwritten in if/else.
$noSupportTypes is always empty and never used in this code.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant !empty() checks on parameters and defined variables

if(!empty($var)) on defined variables is redundant and equivalent to if($var)

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant ternary

$dispval is declared to be a string so the ternary is redundant

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor showEmptyResultMessageOrSetUniqueCondition

Replace boolean variable with returns, which leads to redundant else
block. Remove redundant unset, which leads to redundant variable assignment.
The return statement can be replaced with a boolean cast.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant unset at the end of the method

When a variable leaves scope it is automatically unset

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* [RISKY] Remove temporary var and error supression

It's risky because I was not able to determine the purpose of the error
suppression. In case of error, the function seems to return -1, but that
has not been checked here either. It was possible to silence undefined
global variable, but in that case, why was it not done only on that one
line?

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant condition

The variable is declared as int|false so if it is not false and not 0,
the only logical choice is a non-zero integer, which is always true.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Misleading type hint leading to invalid unit tests

According to DbiMysqli the first argument should be mysqli_result.
The correct type hint cannot be array. It can be object though.
Tested with a debugger that the passed value is really mysqli_result.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove dead code

Remove $inputType. I left the comemnt for posterity, but the variable is
dead. If in the future someone decides to implement it again, then
introducing the variable will not be a problem.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Move block of code to where it should be

I am not sure about this block of code. I don't fully understand what
it is supposed to do. However, making the query at the start of the
function doesn't make sense to me.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use array_keys instead of foreach with dummy variable

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use is_null instead of isset

True conditions are easier to read than inverted conditions.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant variable and break

When the loop breaks then the variable is true.
When the loop finishes then the variable is false.
We can simply replace it with return true/false to make it simpler.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add type declarations

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getEnumSetAndTimestampColumns

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant condition

According to searchColumnInForeigners $foreigner is dependant on values
from $foreigners which makes this check redundant.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getColumnEnumValues

Simplify parameter list, add psalm types, and simplify code

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getColumnSetValueAndSelectSize

Unfortunately, I cannot type hint the return value as then I would have
to type-hint the param as well.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove ternary operator

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getSelectOptionForUpload

Added types, removed NULL return (it is only outputted in Twig as
HTML string so NULL made no sense), and simpified parameters.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getMaxUploadSize

According to getMaxUploadSize the value can only be int.
Comparisons of numerical strings should be avoided. Psalm return type
can be added with the exact types.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getColumnSize

It takes a string as a second parameter now.
The reason for this is that during normal execution, the value comes
from column specifier e.g. VARCHAR(255), which is a string. The value
in spec_in_brackets could also represent ENUM/SET values, so it can't be
forced as an int.
This change required changing tests to pass a string instead of an array
with an int.
The behaviour should remain the same thanks to the (int) cast (previously
implicit, now explicit).

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove parameter $realNullValue

This parameter was always false. Instead define it as false inside
each method. The methods are private, so this should not cause any problems.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add psalm-return

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add an early return and clarify return type

This function should never return false

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Change return type to multidimensional array

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getCommentsMap

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Type hint $tableColumns as multidimensional array

This simplifies static analysis a little bit

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Update phpstan baseline

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Fix invalid unit test

The method getTableColumns should return a multidimensional array always.
Added proper type hint to avoid further mistakes and changed mock.
According to my analysis this method should always return a
multidimensional array because parameter $column to getColumns() is null.
Also, this test is pretty useless as it just seems to test the bahaviour
of array_values which behaves as an identity function right now.

Note: The DBAL needs urgent refactoring too. I imagine array_values is
redundant at the moment. The getColumns should only return a list or
columns or a single column. There's no need to reindex the list. I think
Psalm should have picked it up, but I didn't check.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant call to Util::extractColumnSpec()

Warning! There is no coverage in unit tests for this piece of code.
While I have analysed the code flow manually, it is possible the
duplicated call had some unknown to me purpose.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Update psalm-baseline.xml

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Adhere to the coding standard

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Revert "Remove ternary operator"

This reverts commit 3cbec2cebb.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Rename $field_MD5 to $fieldHashMd5

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Exclude string '0' from comparison and invert the order of operation

This helps with readability and it's unlikely that we would want to
check for string '0' here.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Rename $spec_in_brackets to $specInBrackets

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove else statements

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Introduce array_key_exists() and a local variable

We also add phpdoc comment telling static analysis that the value should
be a string. This is what the current code expects already.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove object parameter type declaration

Upon further inspection I realize this was wrong. The unit tests rely
on the parameter type being an integer and so we cannot force it to be
only an object. I leave the type hint as object as array was probably
never the right type.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-26 14:19:04 -03:00
Kamil Tekiela
58d9bb4a32 Refactor DatabaseInterface::getColumns()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-25 10:28:39 +00:00
Maurício Meneghini Fauth
c1e864b1d7
Add Warning value object for SHOW WARNINGS rows
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-10-09 00:09:01 -03:00
Maurício Meneghini Fauth
67e96cf40c
Get default config values from Config\Settings classes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-30 12:04:47 -03:00
Maurício Meneghini Fauth
3e0856c77b
Remove useless string concatenations
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-27 21:40:22 -03:00
Maurício Meneghini Fauth
f00d70cccb
Remove useless whitespaces
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-15 17:05:40 -03:00
William Desportes
1645ee38fb
Remove InsertEdit::getUrlParameters
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-20 16:12:30 +02:00
William Desportes
8f77a9f29d
Ref #15247 - Remove defined('TESTSUITE') from ReplaceController and remove an exit
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-15 02:39:14 +02:00
Maurício Meneghini Fauth
e8c28d1883
Remove some globals from Config::enableBc method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-08 19:49:26 -03:00
Maurício Meneghini Fauth
9adaa912e1
Rename Response class to ResponseRenderer
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-30 12:35:22 -03:00
Maurício Meneghini Fauth
21431578db
Fix some errors found by PHPStan and Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-24 18:03:14 -03:00
Maurício Meneghini Fauth
f3b79d83c0
Add PHPUnit's Covers annotation on test classes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-04 23:39:26 -03:00
William Desportes
f5f636ef3b
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-05-28 21:43:28 +02:00
dima
822dce2e6e
Fix Uncaught TypeError: array_fill(): Argument #2 ($count) must be of type int, string
Co-Authored-by: William Desportes <williamdes@wdes.fr>
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-05-28 18:00:43 +02:00
Maurício Meneghini Fauth
c3b892f802
Merge branch 'QA_5_1'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-27 18:44:58 -03:00
Saksham Gupta
36fe47f8b9 Fixes #16892: current_timestamp() stringified on INSERT for date field
Signed-off-by: Saksham Gupta <shucon01@gmail.com>

Add tests and fix condition

Signed-off-by: Saksham Gupta <shucon01@gmail.com>

Fix lint

Signed-off-by: Saksham Gupta <shucon01@gmail.com>
2021-05-27 22:33:39 +05:30
Maurício Meneghini Fauth
eff631ac1b
Extract HTML from the InsertEdit::getActionsPanel method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-27 12:06:17 -03:00
Maurício Meneghini Fauth
0cd6cbee13
Remove some .pma-table CSS classes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-14 00:25:41 -03:00
William Desportes
ba35901594
Merge branch 'origin/QA_5_1' into master
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-17 00:53:14 +02:00
Maurício Meneghini Fauth
a3e12976cf
Fix field size for text input
Fixes #16803

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-04-13 14:31:24 -03:00
William Desportes
7a3978a948
Remove useless htmlspecialchars on URL generation
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-13 17:23:12 +02:00
Maurício Meneghini Fauth
a7d6df17d6
Remove warnings from PHPUnit
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-04-09 13:28:47 -03:00
Maurício Meneghini Fauth
1bfaec1351
Extract the HTML from InsertEdit::getValueColumn
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-31 17:21:59 -03:00
Maurício Meneghini Fauth
bbb117b30b
Extract the HTML from InsertEdit::getFunctionColumn
Removes positive tabindex from function and null cells.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-28 17:17:19 -03:00
Maurício Meneghini Fauth
c1489f11a1
Extract HTML from InsertEdit::getHtmlForInsertEditFormColumn
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-27 18:27:16 -03:00
Maurício Meneghini Fauth
cba0ce4722
Extract the HTML for the InsertEdit::getNullColumn method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-27 15:49:55 -03:00
Maurício Meneghini Fauth
9fcb56fd4e
Remove some PHPUnit's at matchers from InsertEditTest
Related to https://github.com/phpmyadmin/phpmyadmin/issues/16332

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-10 14:43:28 -03:00
Maurício Meneghini Fauth
33d711215d
Remove the PMA_VERSION constant
Uses the PhpMyAdmin\Version::VERSION constant instead.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-08 22:22:55 -03:00
Maurício Meneghini Fauth
0b8edc5bde
Use PSR-12 for namespace use statements
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-05 14:18:35 -03:00
William Desportes
76803f9422
Replace deprecated ->setMethods by ->onlyMethods
See: https://github.com/sebastianbergmann/phpunit/pull/3687
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-03-04 23:24:25 +01:00
William Desportes
c5155ecae9
Refactor field flags to use an object an not strpos
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-02-24 23:56:33 +01:00
Maurício Meneghini Fauth
ac4bfaebe7
Remove some custom CSS utilities
Uses Bootstrap equivalents.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-12-26 20:05:03 -03:00
Maurício Meneghini Fauth
db3da81056 Remove some useless comments
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-10-13 19:56:56 -03:00
William Desportes
777dcb2e60
Fix coding standard issues
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-10-11 18:13:35 +02:00
William Desportes
01d8979136
Merge branch 'QA_5_0'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-10-11 18:00:06 +02:00
William Desportes
34a8dfb6b1
Merge branch 'QA_4_9' into QA_5_0
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-10-11 17:56:52 +02:00
William Desportes
b5654b02df
Fix failing tests
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-10-11 17:36:59 +02:00
Maurício Meneghini Fauth
405b6277e7 Merge branch 'QA_5_0'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-10-10 14:16:25 -03:00
Maurício Meneghini Fauth
5aa2856f7f Remove Util::buildActionTitles and the titles global
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-09-12 22:50:08 -03:00
Maurício Meneghini Fauth
ceac762e09 Remove pmaThemePath and pmaThemeImage PHP globals
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-09-02 10:57:57 -03:00
William Desportes
cce4bc993c
Fixes #16278 - Fix tests
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-08-06 15:48:08 +02:00
Maurício Meneghini Fauth
2358b9c4f9 Fix missing property type hints
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-22 21:42:22 -03:00
Maurício Meneghini Fauth
47f0960dce Add return type declaration to test methods
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-07 11:31:33 -03:00