Commit Graph

151 Commits

Author SHA1 Message Date
Kamil Tekiela
3ac8b6d87b Use short lambdas
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-05-11 23:48:06 +01:00
Maurício Meneghini Fauth
9e53d6914c
Improve array type inference for some tests
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-04-01 20:18:20 -03:00
Maurício Meneghini Fauth
dd885dc7b8
Use single-line arrays when possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-27 17:39:17 -03:00
Maurício Meneghini Fauth
e5698c85e9
Require single line for function calls
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-26 23:10:10 -03:00
Maurício Meneghini Fauth
437215cab2
Rename variables to use camel case format
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-26 21:47:50 -03:00
Maurício Meneghini Fauth
8972c0ec22
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-24 18:15:47 -03:00
Kamil Tekiela
e9b9c120af Fix getTablesFull() and related tests
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-15 19:59:35 +00:00
Kamil Tekiela
f8d6b0a35a
Fix TypeError Table::getLastMessage() (#18166)
* Fix TypeError Table::getLastMessage()

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

* Fix TypeError Table::getLastError()

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

* Update psalm-baseline.xml

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

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-03 21:38:34 -03:00
Maurício Meneghini Fauth
556594b4cd
Fix coding standard spacing issues
- Fixes one line doc comments
- Fixes parent call spacing
- Fixes constant spacing

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-24 21:06:17 -03:00
Maurício Meneghini Fauth
77957a69a5
Add trailing comma for multi-line functions
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-24 20:48:46 -03:00
Kamil Tekiela
902d1a1e77
Add native return type hints (#18126)
* Add remaining native return type hints to flush out bugs

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

* Cast the mixed value to int

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

* Fix tests

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

* getAutoIncrement() is supposed to return string

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

* Cast values to string in DummyResult

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

* Make getCollation() return non-nullable string

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

* Cast seqInIndex to int

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

* Cast $cardinality to int

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

* createFile may return false

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

* Remove redundant cast

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

* Update baselines

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

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-23 15:43:36 -03:00
Kamil Tekiela
c311b9fdcb Fix merge issues
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-20 20:43:12 +00:00
Maurício Meneghini Fauth
2a4803a81b
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-20 15:18:28 -03:00
Kamil Tekiela
fa339143ea
Fix renaming db with a view (#18106)
* Fix renaming DB with a view

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

* Add test for the bug

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

* Update baselines

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

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-20 13:36:46 -03:00
Maurício Meneghini Fauth
0ab9e4ac77
Change PHPUnit data providers to use static methods
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-14 12:42:16 -03:00
Maurício Meneghini Fauth
41dec1effc
Extract connection type constants to the Connection class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-01-17 02:21:27 -03:00
Kamil Tekiela
2bda275524 Add better type inference
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-20 18:55:03 +00:00
Kamil Tekiela
78e3f495cd Replace escapeString with quoteString
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-10 17:56:11 -03:00
Maurício Meneghini Fauth
d0d90551c3 Remove the dblist global variable
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-13 21:08:00 -03:00
Kamil Tekiela
81bc60f7e0 Minor fixes in getSqlQueryForIndexCreateOrEdit()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-08 00:32:10 +00:00
William Desportes
25c13d667b
Merge branch 'QA_5_2'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-10-26 12:22:38 +02:00
Mo Sureerat
aeab8a1c41
Fix #17793 - insert UUID (#17797)
* Add/Change table schema - Add UUID in default options
* Insert/Update - Generate uuid only not defined and not check null option
* Add/Change table schema - Hide UUID from default options if database not support & add unit test

Fix #17793

Signed-off-by: Mo Sureerat <sureemo@gmail.com>
2022-10-20 15:57:53 -03:00
Kamil Tekiela
2c416128e5 Pass as argument to Table
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-10-17 22:30:33 +01:00
Maurício Meneghini Fauth
a8421efd56
Move DBI getTriggers method into the Triggers class
DatabaseInterface::getTriggers -> Database\Triggers::getDetails

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-09-10 16:00:42 -03:00
Maurício Meneghini Fauth
1438cb211e
Replace global keyword with $GLOBALS
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-03-07 17:31:11 -03: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
a4b2d7e524 Deimplement fetchRow() helper
This helper isn't needed anymore.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-09 22:44:53 +00:00
Kamil Tekiela
f38d3baa31 Remove $options parameter from fetchResult
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-01 01:46:17 +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
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
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
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
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
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
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
Maurício Meneghini Fauth
59e4dae52a
Remove invalid inline doc comments
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-04-18 14:49: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
970d28617a
Add tests for #16728
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-03-24 02:59:42 +01: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
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
William Desportes
9754d165fc
Ref #16575 - Add tests to cover the DEFAULT timestamp support
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-02-16 15:36:28 +01:00
William Desportes
50e900a1bf
Remove all @test annotations
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-11-08 23:01:26 +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
William Desportes
ddfdbc2134
Remove some useless doc blocks and fix some coding standard warnings
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-07-18 00:14:32 +02:00
William Desportes
a80153a633
Add typehints using phpcbf on test/*
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-07-17 22:52:42 +02: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
Maurício Meneghini Fauth
dfa5f92c31 Add return type declaration to fetch row methods
DatabaseInterface's fetchArray, fetchAssoc, fetchRow and fetchSingleRow
methods.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-06-29 20:32:04 -03:00