Commit Graph

209 Commits

Author SHA1 Message Date
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
6e1221ce62 Drop stripslashes
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-02-07 18:07:27 +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
bcf2b7b322 Deimplement numFields() helper
There were only two usages remaining. This helper isn't needed anymore.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-07 23:27:37 +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
b1dc03365a
Bump TCPDF version to 6.4.4
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-31 16:58:34 -03:00
Maurício Meneghini Fauth
cb650d2a2d
Merge branch 'QA_5_1'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-29 19:44:12 -03:00
William Desportes
679eca275a
Fix phpdocs after tcpdf update to 6.4.3 (the actual hints where not valid)
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-12-29 01:41:58 +01: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
c4e2582e56
Use TableName for RelationParameters tables
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-26 19:17:57 -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
William Desportes
bc570cb1de
Fix merge 2a4b170a34, remove useless for loop
Ref: 2a4b170a34

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-12-21 17:56:36 +01:00
Maurício Meneghini Fauth
92418f2226
Fix some coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-21 13:39:29 -03:00
Maurício Meneghini Fauth
2a4b170a34
Merge branch 'QA_5_1'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-21 13:13:09 -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
William Desportes
f6b241cf5f
#16005 - performance improvement on the Export page
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-12-12 21:57:42 +01: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
a42803297c
Psalm fixes 3 (#17221)
* Update psalm-baseline.xml

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

* Small bug fixes

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

* non-falsy-string is always true

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

* currentSearch property is nullable

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

* Remove unusued parameter $columnIndex

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

* Use parameters instead of globals in sendEditor()

The two globals in this method are read-only. There is an unused
parameter in the signature. Let's add one more and use them instead of globals.

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

* Remove unusued parameter $crlf

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-03 12:40:19 -03:00
Kamil Tekiela
f446e6da88 Remove unused variables
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-03 15:12:56 +00:00
Maurício Meneghini Fauth
acff73aa24
Merge pull request #17215 from kamil-tekiela/Psalm-fixes-1
Use array_keys whenever only keys are needed in foreach
2021-12-02 18:42:12 -03:00
Kamil Tekiela
1270efc2a9
Refactor util.php (#17212)
* Remove extra space

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

* Remove null checks on properties that cannot be null

The value could be null only if the property exists in stdClass
returned by mysqli but is null. Mysqli doesn't do that. Unless the value
can be null in some other way, this check is redundant.

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

* Add psalm-return

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

* Remove $handle parameter of getUniqueCondition()

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

* Type hint the $row parameter

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

Co-authored-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-02 17:37:09 -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
Kamil Tekiela
58d9bb4a32 Refactor DatabaseInterface::getColumns()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-25 10:28:39 +00: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
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
4834c5fe7d
Remove bypass flag from Util::backquote method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-26 11:51:34 -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
f61d3183fb
Inline some phpcs ignores and remove deprecated annotations
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-12 11:59:39 -03:00
Maurício Meneghini Fauth
53dd6f11b0
Refactor setProperties method of Plugin classes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-28 16:50:08 -03:00
William Desportes
806e2740ba
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-27 22:09:55 +02:00
Maurício Meneghini Fauth
86798ec45e
Refactor PhpMyAdmin\Plugins::getChoice method
Extracts the getDefault method from the getChoice method and adds a
getName method to the Plugin interface.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-27 13:38:01 -03:00
William Desportes
cd4be9ac2c
Check if the column has a name, expression columns do not have a name
Ref: https://github.com/phpmyadmin/sql-parser/pull/350 (this PR documents the real type)

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-26 00:15:09 +02:00
William Desportes
0320dd2a30
Fix types and signatures after tcpdf upgrade
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-21 00:26:11 +02:00
Maurício Meneghini Fauth
92dc790d78
Refactor PhpMyAdmin\Plugins::getPlugins method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-28 23:18:44 -03:00
Maurício Meneghini Fauth
8319f88ecf
Fix some errors found by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-22 17:12:02 -03:00
Maurício Meneghini Fauth
cab899d7b5
Fix some errors found by Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-21 15:58:11 -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
Maurício Meneghini Fauth
cd1b8a9b77
Fix some errors found by PHPStan and Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-22 15:14:24 -03:00
Maurício Meneghini Fauth
95fdd35e2f
Remove the .pma-table CSS class
Replaces with equivalent Bootstrap classes.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-15 17:16:22 -03:00
William Desportes
c4a5a4b256
Update Export plugin template
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-29 01:45:57 +02:00
William Desportes
d82e85f852
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-23 18:46:05 +02:00
William Desportes
cbd35c9fa8
Ref #16847 - Fix JSON export code duplicated and not following rules in raw query export mode
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-23 17:48:14 +02:00