Commit Graph

159 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
44fe103b9c
Remove @access annotations
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-22 11:43:45 -03:00
Maurício Meneghini Fauth
c411121fd8
Move Relation classes into the ConfigStorage namespace
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-17 12:09:13 -03:00
Maurício Meneghini Fauth
c4575fd48b
Add methods to check for RelationParameters features
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-11 08:10:40 -03:00
Kamil Tekiela
f446e6da88 Remove unused variables
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-03 15:12:56 +00:00
Kamil Tekiela
488e7cb5bf Use array_keys whenever only keys are needed in foreach
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-29 20:37:39 +00:00
Kamil Tekiela
56a832948c
Refactor DatabaseInterface.php (#17209)
* Use str_starts_with()

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

* Remove redundant !empty()

!empty() on a declared variable is redundant.

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

* Replace loop with array_column()

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

* Simpify assignment by removing temporary variable

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

* Remove redundant if statements and array_merge

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

* Remove temporary variable

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

* Unindent code

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

* Add helper method fetchByMode()

This is done to avoid calling methods through variables. It is the same
in terms of performance.

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

* Move if statements to where they are relevant

I had a choice to either move the while loop out of the if statements
or move the if statements inside. I decided it made more sense to move
them inside.

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

* Add NULL to phpdoc for the two parameters that can be null

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

* Simplify return statement

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

* Improve performance and simplify code

Since we are always using STORE mode then we can use data_seek() method.
This will allow us to get rid of the loop and use fetchByMode() method.

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

* Inline value defaulting

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

* Remove redundant check

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

* [bugfix] getColumnNames() should return an array of strings

There were multiple issues here. If we are selecting only a certain
column from the SQL then let's use the handy function instead of
array_keys. We will never get anything other than an array so checking
if it is not an array makes no sense. Returning null only to cast it to
an array is pointless. If really necessary, we could still check for an
empty array. The ColumnController returned the value without even
casting it to an array. I am not sure how jQuery/JavaScript dealt with it.

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

* Refactor getColumnMapFromSql and add type hint

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

* Refactor getVirtualTables

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

* Remove redundant loop

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

* Remove redundant usage of freeResult()

If there was no chance for the object to leak the scope and it is the
end of the scope then there's no reason to call this method.

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

* Replace dynamic variable with declare one

It's always the same name. If we were creating more than one, we could
use associative array, but in this case there seems to be absolutely no
need for any of this. Dynamic variables make it harder to debug the code.

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

* Update psalm-baseline.xml

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

* Widen the condition per williamdes suggestion

This will allow value such as '' and '0' to pass through. Previously
`if(! empty($database))` and `if($database)` dissallowed them.

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

* fetchResult() should return only arrays

Tests fixed to return arrays. Non-empty in case of true, empty in case
of false.
Fixed a lot of Psalm issues where the condition was always true.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-26 20:17:46 -03:00
Maurício Meneghini Fauth
857a9d3337
Remove unnecessary @var annotations
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-18 12:15:30 -03:00
Maurício Meneghini Fauth
090d2eece7
Fix some issues found by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-16 15:11:57 -03:00
Maurício Meneghini Fauth
7fc8c4bd15
Remove @var annotation in Table::getColumnGenerationExpression
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-15 13:36:47 -03:00
Maurício Meneghini Fauth
b2a51c4d84
Create the RelationParameters value object
Replaces the $cfgRelation array with the RelationParameters value
object.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-14 18:22:36 -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
Maurício Meneghini Fauth
9f3510d11a
Add bool return type where possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-14 20:11:51 -03:00
Maurício Meneghini Fauth
7f6472b2c2
Add void return type where possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-13 15:29:11 -03:00
Maurício Meneghini Fauth
5f4fd07483
Remove some assignments to the $_POST global
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-03 15:49:39 -03:00
William Desportes
72800e2524
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-15 00:52:33 +02:00
William Desportes
d804e60820
Fix broken docs link after FK types mismatch error
See: https://web.archive.org/web/20200921164945/https://dev.mysql.com/doc/refman/8.0/en/innodb-foreign-key-constraints.html

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-14 15:28:55 +02:00
William Desportes
12c390948c
Fix a phpstan reported error
[ci skip] One failing test fixed on next push

And remove an error from the baseline from previous merge

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-20 17:54:04 +02:00
William Desportes
587536b766
Remove non used variables
Running: composer run psalm -- --alter --issues=UnusedVariable
And removing the false positives I reported upstream

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-16 02:13:27 +02:00
William Desportes
d84e3cde28
Fix psalm detected errors
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-13 21:45:34 +02:00
Fawzi E. Abdulfattah
9954c47577
Fix #16138 - ignore the length of integer types, and show a warning
Fixes: #16138

Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
2021-07-13 15:42:57 +02:00
Maurício Meneghini Fauth
ed45c51d59
Add Stringable interface to classes with __toString
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-10 14:11:51 -03:00
Maurício Meneghini Fauth
6ae07c96fb
Replace strpos !== false with str_contains
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-09 22:30:42 -03:00
Maurício Meneghini Fauth
1129b68d29
Refactor PhpMyAdmin\Plugins::getPlugin method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-25 17:40:20 -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
1c084de30b
Fix coding standard errors
Related to 62f142c9fa.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-03 16:50:33 -03:00
Maurício Meneghini Fauth
9928882de3
Fix some errors found by Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-23 00:24:59 -03:00
William Desportes
2204ef77a0
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-30 00:09:21 +02:00
William Desportes
bd7a7efdc7
Ref #16842 - Also check PerconaDB in Table::getColumnGenerationExpression
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-29 23:42:56 +02:00
Maurício Meneghini Fauth
8d0c2a339c
Move both operands of an assignment to the same line
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-04-20 22:35:21 -03:00
William Desportes
41e0d4dfb7
Use the Query\Compatibility class to simply and remove duplicate checks
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-20 20:57:10 +02:00
Maurício Meneghini Fauth
9b95d252fe
Rename variables to use camelCase format in Table class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-25 15:04:12 -03:00
Maurício Meneghini Fauth
91bd0df2e5
Rename $err_url global to $errorUrl
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-24 19:39:28 -03:00
William Desportes
e76c181d87
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-03-24 03:22:25 +01:00
William Desportes
52b872feb8
Merge #16737 - Fix #16728 - Wrong SQL query built on table structure index for new column
Pull-request: #16737
Fixes: #16728

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-03-24 03:09:57 +01:00
Saksham Gupta
b8540bdc3c Fix #16728 - Wrong SQL query built
Signed-off-by: Saksham Gupta <shucon01@gmail.com>
2021-03-16 14:07:18 +05:30
Maurício Meneghini Fauth
d3ce67593d
Fix some errors found by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-09 17:22:03 -03:00
Maurício Meneghini Fauth
d83abf63e7
Use PSR-12 for control structures spacing
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-05 15:27:03 -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
7d3a3cd74c
Add more type casts for #16634
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-02-16 17:59:45 +01:00
peterdd
805ceb08c3
Fix #16575 - move timestamp column with default value
Signed-off-by: Peter Liscovius <ddpm@liscovius.de>
2021-02-16 15:36:54 +01:00
Fawzi E. Abdulfattah
7df23b47c6
Fix #16641 - query generation bug which allowing JSON to have length
Fixes: #16641

Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
2021-02-14 13:06:12 +01:00
William Desportes
f018156de3
Merge #16427 - Fix #16422 - Renaming Database with views throws an error
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-12-07 16:36:38 +01:00
Saksham Gupta
d0be531ede Renaming Database with views error
Fixes: https://github.com/phpmyadmin/phpmyadmin/issues/16422

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

Fixes: https://github.com/phpmyadmin/phpmyadmin/issues/16214

Revert "Add PHP 8 to composer.json"

This reverts commit 64090387f1.

Revert "Renaming Database with views error"

This reverts commit 23ffa730c94c9ed26f0b7f06a853c0e9af0aa637.

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

Remove fix
2020-11-20 20:59:33 +05:30
William Desportes
e4bd8b51aa
Fix #16429 - PHP 8 errors on preg_replace
49) PhpMyAdmin\Tests\Setup\ConfigGeneratorTest::testGetConfigFile
TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, int given

libraries/classes/Setup/ConfigGenerator.php:183
libraries/classes/Setup/ConfigGenerator.php:53
test/classes/Setup/ConfigGeneratorTest.php:55
vendor/phpunit/phpunit/phpunit:61

50) PhpMyAdmin\Tests\TableTest::testGenerateFieldSpec
TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, int given

libraries/classes/Table.php:596
test/classes/TableTest.php:491
vendor/phpunit/phpunit/phpunit:61

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-11-19 18:28:37 +01:00
William Desportes
5abcae9255
Fixed some typos in the code base
I used code spell checker and did all the libraries/classes/*.php files one by one.
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-11-01 22:46:01 +01: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
Maurício Meneghini Fauth
ac9bccf67d Replace $GLOBALS['dbi'] with global $dbi
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-10-11 09:24:21 -03:00
William Desportes
da8230fced
Merge #16368 - Fix #16365 - Foreign keys are not showing
Pull-request: #16368
Fixes: #16365

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-10-06 09:23:35 +02:00
Maurício Meneghini Fauth
e66be179ca Use camel case naming for class members
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-10-05 10:37:07 -03:00