Commit Graph

195 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
fdf474abf9
Merge pull request #17981 from kamil-tekiela/getTables-investigation
Improve some type inference in various places

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-12-24 13:44:45 -03:00
Kamil Tekiela
6264f6f1ea
Various refactorings 2 (#17965)
* Remove extra blank lines
* Remove useless param annotations
* Refactor Index::singleton
* Refactor Config.php
* Refactor Header::addRecentTable()
* Collapse return statement into a single line
* Refactor Message.php
* Convert $getUniqueCondition into a scalar
* Code style
* Fix invalid return phpdoc
* Remove unused variable
* Remove redundant empty array checks
* Refactor Export::closeFile()
* Simplify else statement
* Remove redundant else
* Refactor TablePartitionDefinition::getDetails
* Simpler returns
* Add types for getCellContent()
* Remove useless method mngInsideStructComm

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-24 12:54:23 -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
Maurício Meneghini Fauth
08a27b8b7e
Merge pull request #17959 from kamil-tekiela/various-refactorings
Various refactorings
2022-12-14 23:10:11 -03:00
Maurício Meneghini Fauth
55e95ccd09
Fix type error when copying tables
Related to 873eb098b9 and
a84cae6c2d.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-12-14 18:24:11 -03:00
Kamil Tekiela
1bb0e830c0 Remove temporary variables from Table
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-14 17:23:44 +00:00
Kamil Tekiela
0ae0516084 Refactor Table::countRecords()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-14 17:23:44 +00:00
Kamil Tekiela
a84cae6c2d
Refactor ExportSql - part 1 (#17955)
* Add getTableStatus method

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

* Remove unused $errorUrl parameter

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

* Remove unused parameter $table

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

* Add string return types

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

* Refactor exportUseStatement

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

* Specify param types for exportConfigurationMetadata

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

* param types for getTableDefForView

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

* Param types for getTableComments

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

* Small fixes

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

* Extract addCompatOptions() method

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

* Remove no longer needed suppress

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

* Merge if statements by SonarLint

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

* Update phpstan-baseline.neon

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

* Specify param types for exportRoutineSQL

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

* Specify param types for generateComment

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

* Specify param types for replaceWithAliases

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>
2022-12-14 11:56:22 -03: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
ca489f3b41
Improve type of DatabaseInterface::getLowerCaseNames()
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-19 15:50:14 -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
Maurício Meneghini Fauth
c337b72d56
Replace escapeString in Table::getColumnGenerationExpression
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-09 13:31:31 -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
Kamil Tekiela
1f4f414b40 Fix wrong type for keyBlockSizes
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-08 00:32:09 +00:00
Kamil Tekiela
91aad40948 Refactor isEngine() method
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-07 22:38:12 +00:00
Kamil Tekiela
95a93ba909
Minor stylistic changes (#17865)
* Stylistic changes to make refactoring easier
* Parameter $where was unnecessarily nullable
* Refactor Routines::getDetails()
* Refactor Events::getDetails()
* Refactor Triggers::getDetails()
* Split up QueryGenerator::getInformationSchemaColumnsFullRequest

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-05 12:55:44 -03: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
3890d11dd8
Fix some coding style issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-10-16 17:18:54 -03:00
Maurício Meneghini Fauth
478b1c03a7
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-10-16 13:52:33 -03:00
Maurício Meneghini Fauth
4d1546f7c5
Fix indentation issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-10-16 13:41:31 -03: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
9d2350d28c
Extract dbi global variable from Index::loadIndexes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-09-07 21:59:03 -03:00
Maurício Meneghini Fauth
7576d5cf86
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-07-19 13:10:34 -03:00
atomu330
6957064cea
replace isset to empty
IF statement ! isset($this->uiprefs) was causing issue.

Private property 'uiprefs' is initialized to empty array, so ! isset($this->uiprefs) is always FALSE;
It's not hopefull, so I replace ! isset($this->uiprefs) to empty($this->uiprefs) to fix #17617 bug;

Fixes #17617
Closes #17644

Signed-off-by: Atomu Oku <atomu.work@gmail.com>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-07-19 13:04:59 -03:00
Maurício Meneghini Fauth
5950693fb3
Fix possible undefined globals
Related to https://github.com/phpmyadmin/phpmyadmin/pull/17427.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-03-10 18:05:21 -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
a74c5aed44 Add few more usages of queryAsControlUser
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:31:27 +00:00
Kamil Tekiela
f5bb90ebb9 Move queryAsControlUser - Dbal refactoring pt.3
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:31:27 +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
feca48cc76
Change return type of DatabaseInterface::getError method
Now, it returns last error message or an empty string instead of false
if no errors occurred.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-27 14:43:14 -03:00
Maurício Meneghini Fauth
d84af02945
Create VO classes for each RelationParameters features
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-26 19:17:58 -03:00
Maurício Meneghini Fauth
4e0141e19f
Merge pull request #17253 from kamil-tekiela/fetchValue
Remove $row_number from DatabaseInterface::fetchValue
2021-12-23 11:40:25 -03:00
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
Kamil Tekiela
70c86f5e21 Remove $row_number from DatabaseInterface::fetchValue
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-21 21:09:38 +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
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