[phpMyAdmin Git] [phpmyadmin/phpmyadmin] 56a832: Refactor DatabaseInterface.php (#17209)
Kamil Tekiela
tekiela246 at gmail.com
Sat Nov 27 00:17:49 CET 2021
Branch: refs/heads/master
Home: https://github.com/phpmyadmin/phpmyadmin
Commit: 56a832948c06032237ea2c34d76691289159b499
https://github.com/phpmyadmin/phpmyadmin/commit/56a832948c06032237ea2c34d76691289159b499
Author: Kamil Tekiela <tekiela246 at gmail.com>
Date: 2021-11-26 (Fri, 11 November 2021) -03:00
Changed paths:
M libraries/classes/Bookmark.php
M libraries/classes/Controllers/Server/Variables/GetVariableController.php
M libraries/classes/Controllers/Server/Variables/SetVariableController.php
M libraries/classes/Controllers/Table/FindReplaceController.php
M libraries/classes/Database/CentralColumns.php
M libraries/classes/Database/Designer/Common.php
M libraries/classes/Database/Routines.php
M libraries/classes/DatabaseInterface.php
M libraries/classes/Dbal/DbalInterface.php
M libraries/classes/Normalization.php
M libraries/classes/Plugins/Export/ExportMediawiki.php
M libraries/classes/Plugins/Import/ImportCsv.php
M libraries/classes/Profiling.php
M libraries/classes/Relation.php
M libraries/classes/Server/Privileges.php
M libraries/classes/StorageEngine.php
M libraries/classes/Table.php
M libraries/classes/UserPreferences.php
M psalm-baseline.xml
M test/classes/Plugins/Export/ExportXmlTest.php
M test/classes/TableTest.php
M test/classes/UserPreferencesTest.php
Log Message:
-----------
Refactor DatabaseInterface.php (#17209)
* Use str_starts_with()
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Remove redundant !empty()
!empty() on a declared variable is redundant.
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Replace loop with array_column()
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Simpify assignment by removing temporary variable
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Remove redundant if statements and array_merge
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Remove temporary variable
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Unindent code
Signed-off-by: Kamil Tekiela <tekiela246 at 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 at 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 at gmail.com>
* Add NULL to phpdoc for the two parameters that can be null
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Simplify return statement
Signed-off-by: Kamil Tekiela <tekiela246 at 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 at gmail.com>
* Inline value defaulting
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Remove redundant check
Signed-off-by: Kamil Tekiela <tekiela246 at 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 at gmail.com>
* Refactor getColumnMapFromSql and add type hint
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Refactor getVirtualTables
Signed-off-by: Kamil Tekiela <tekiela246 at gmail.com>
* Remove redundant loop
Signed-off-by: Kamil Tekiela <tekiela246 at 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 at 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 at gmail.com>
* Update psalm-baseline.xml
Signed-off-by: Kamil Tekiela <tekiela246 at 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 at 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 at gmail.com>
More information about the Git
mailing list