Commit Graph

104 Commits

Author SHA1 Message Date
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
4c3bf41d56
Use DatabaseName for RelationParameters::db instead of string
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-11 08:10:40 -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
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
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
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
9adaa912e1
Rename Response class to ResponseRenderer
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-30 12:35:22 -03:00
William Desportes
6996e8dd28
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 19:01:02 +02:00
William Desportes
6a7230cb8c
Fix #16982 - do not try to delete internal relations if they are not configured
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 16:23:34 +02:00
William Desportes
ab6fedbd5c
Backquote phpMyAdmin table name on internal relation delete query
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 16:00:31 +02: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
caa3337411
Extract FK related methods from Util class
Creates the PhpMyAdmin\Utils\ForeignKey class.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-21 15:25:45 -03:00
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
fb5d6159af
Fix Doctum reported phpdoc errors
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-12-18 22:01:51 +01:00
William Desportes
70320f256b
Fix a "PHP Fatal error: Uncaught TypeError: rawurlencode" using sakila database
NOTICE: PHP message: PHP Fatal error:  Uncaught TypeError: rawurlencode(): Argument #1 ($string) must be of type string, int given in libraries/classes/Database/Designer/Common.php:141
Stack trace:
#0 libraries/classes/Database/Designer/Common.php(141): rawurlencode(1)
#1 libraries/classes/Controllers/Database/DesignerController.php(203): PhpMyAdmin\Database\Designer\Common->getScriptContr(Array)
#2 libraries/classes/Routing.php(92): PhpMyAdmin\Controllers\Database\DesignerController->index(Array)
#3 index.php(18): PhpMyAdmin\Routing::callControllerForRoute('/database/desig...', Object(FastRoute\Dispatcher\GroupCountBased), Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#4 {main}
  thrown in libraries/classes/Database/Designer/Common.p...

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-12-07 01:20:53 +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
3b285ff17e Use identical operator for non-empty strings
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-10 18:06:29 -03:00
Maurício Meneghini Fauth
05c62ad1a8 Fix some PHPStan errors
Fixes "Cannot access offset on array" errors.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-02 16:12:07 -03:00
William Desportes
5d933e03b9
Merge branch 'QA_5_0'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-06-07 23:40:25 +02:00
William Desportes
1eb7c00c1c
Fix #16157 - relations of tables having spaces or special chars where not showing in the Designer
We where comparing encoded strings with non encoded ones, that could not work.

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-06-07 23:29:37 +02:00
William Desportes
4820175b8a
Fix php error when browsing the designer
The condition was not right, shorten to check only table

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-06-03 16:03:04 +02:00
William Desportes
7e9d2ae4f9
Move more SQL queries into Query\Generator
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-05-31 02:16:02 +02:00
Maurício Meneghini Fauth
f4582e083e Use early exit when possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-27 00:35:24 -03:00
Maurício Meneghini Fauth
3ae05c785d Use short list syntax and single line arrays
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-26 03:32:59 -03:00
Maurício Meneghini Fauth
3baad2eb1c Fix some coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-25 22:42:37 -03:00
Maurício Meneghini Fauth
80a45fa0ae Break too long lines
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-16 18:08:20 -03:00
Maurício Meneghini Fauth
a64393e7f5 Fix some coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-13 00:23:28 -03:00
Maurício Meneghini Fauth
6584b01824 Use short versions of scalar types in PHP docs
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-23 12:20:04 -03:00
Maurício Meneghini Fauth
676f48349a Reference global funcs and consts via use statement
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-21 22:13:36 -03:00
Maurício Meneghini Fauth
42166cac37 Remove use statements within the same namespace
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-21 19:47:56 -03:00
Maurício Meneghini Fauth
f80d3e3bd4 Remove unnecessary annotations
@package, @subpackage and others.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-20 17:35:56 -03:00
Maurício Meneghini Fauth
6283caaabf Use one line for comments with a single line
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-20 16:04:09 -03:00
Maurício Meneghini Fauth
8ec4209002 Fix some coding standard issues
- Inverts yoda comparisons
- Removes parentheses from return
- Removes useless ternary operators
- Adds paretheses to new instances
- Adds trailing array comma

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-20 00:38:34 -03:00
Maurício Meneghini Fauth
c5481acebf Merge branch 'QA_5_0'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-14 18:54:02 -03:00
Tabraiz
c6206a301d
Fix for page name already existing in designer page names
Signed-off-by: Tabraiz Malik <tabraizmalik96@gmail.com>
2020-01-12 21:35:05 +01:00
William Desportes
4512ada9eb
Fix php error when creating a relation between a table and a view in Designer
Yes, that does not make sense but it should not throw and error
"Uncaught TypeError: mb_strtoupper() expects parameter 1 to be string"

Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-01-12 18:29:34 +01:00
Maurício Meneghini Fauth
39f42f848b Remove some useless docblock comments
Fixes docblock spacing

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2019-12-13 21:15:00 -03:00
Maurício Meneghini Fauth
dd2b05330a Remove useless parentheses
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2019-12-12 00:18:01 -03:00
Maurício Meneghini Fauth
77518d341e Remove unused use statements
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2019-12-11 21:20:58 -03:00
Maurício Meneghini Fauth
f6a17433a2 Use null coalesce operator when possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2019-12-11 20:16:58 -03:00
William Desportes
5f13152857
Fix some PHPStan level 3 errors
Signed-off-by: William Desportes <williamdes@wdes.fr>
2019-12-06 09:02:41 +01:00
Maurício Meneghini Fauth
dd06cd38f8 Defines rules for double quote usage
Makes sure that any use of double quotes strings are warranted.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2019-12-01 14:10:07 -03:00
William Desportes
4e4670e9c2
Merge branch 'QA_5_0'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2019-11-23 00:08:27 +01:00
William Desportes
293d273632
Merge branch 'QA_4_9' into QA_5_0
Signed-off-by: William Desportes <williamdes@wdes.fr>
2019-11-23 00:06:39 +01:00
William Desportes
3f9ac1dc98
Fix engine can be null
Signed-off-by: William Desportes <williamdes@wdes.fr>
2019-11-23 00:05:55 +01:00