Commit Graph

161 Commits

Author SHA1 Message Date
Kamil Tekiela
d043ceedc6 Refactor $sql_data
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-17 20:46:27 +00:00
Kamil Tekiela
c2edf8534c Change empty for stricter comparison
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-17 20:45:31 +00:00
Kamil Tekiela
ad0acda8b2 Remove parameter
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-17 20:23:25 +00:00
Kamil Tekiela
009a92c545 Set parameter type
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-17 20:23:25 +00:00
Kamil Tekiela
b3759ba7e4 Remove count()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-17 20:23:25 +00:00
Kamil Tekiela
5c8a4e90a0 Remove pass-by-ref
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-17 20:23:25 +00: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
William Desportes
65c9f49c1e
Merge branch 'QA_5_1' into QA_5_2
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-02-06 15:45:57 +01:00
William Desportes
cba530070f
Fix #17298 - Import of email-addresses from ods results in empty contents
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-02-06 14:19:01 +01:00
William Desportes
838ac24897
Fix #17344 - type error with values that are not strings in ODS sheets
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-02-06 14:18:47 +01:00
Maurício Meneghini Fauth
feda222da9
Fix failing tests
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-26 10:02:26 -03:00
Maurício Meneghini Fauth
8fa99a3363
Add stub file for uploadprogress_get_info function
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-19 14:49:12 -03:00
Kamil Tekiela
47a039d70c Implement ResultInterface & MysqliResult
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-31 23:59:24 +00: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
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
98e70c6ae6
Suppress some Psalm errors in ImportXml plugin class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-15 16:06:05 -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
e96b75bb92
Replace class strings with the ::class constant
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-27 19:17:45 -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
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
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
b72f941167
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-23 20:35:42 +02:00
William Desportes
90018d5626
Fix #16942 - auto-detection for "LOAD DATA LOCAL INFILE" LOCAL option
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-23 20:03:41 +02:00
William Desportes
fa88ce2f00
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-10 15:39:23 +02:00
Lukas Bixen
b615dc9450 CSV import: fix column names in top row
Signed-off-by: Lukas Bixen <lrb2_@outlook.com>
2021-08-09 00:23:03 -05:00
Maximilian Krög
808cd82780
Use negative length with mb_substr where possible
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
2021-07-18 23:59:46 +02:00
Maurício Meneghini Fauth
1835ebb4fc
Replace mb_strpos !== false with str_contains
See: https://wiki.php.net/rfc/str_contains#case-insensitivity_and_multibyte_strings

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-10 13:43:40 -03: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
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
a49ea14515
Fix "Undefined array key "ods_recognize_currency" on ImportOds
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 12:51:55 +02:00
William Desportes
5c19230a66
Fix warning "Undefined index: ods_recognize_percentages" on ImportOds
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 12:50:04 +02: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
William Desportes
38448a1ad6
Fix missing "use function" for apc and uploadprogress extensions
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-22 00:29:32 +02:00
William Desportes
4747955500
Add missing "use function uploadprogress_get_info;" on UploadProgress class
Seems like no dev had uploadprogress installed so it did not show as a phpcs error until now

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-15 21:51:34 +02:00
Maurício Meneghini Fauth
6989d615a5
Fix some errors found by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-09 13:07:40 -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
William Desportes
f5f636ef3b
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-05-28 21:43:28 +02:00
William Desportes
a8e56bf3a9
Fix #16926 - Warning in ./libraries/classes/Plugins/Import/ImportOds.php#377 Undefined array key "ods_empty_rows"
Fixes: #16926

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-05-28 21:36:39 +02: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
William Desportes
d005ea8041
Remove some else conditions by using early exits or moving code
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-29 01:30:25 +02:00
William Desportes
dda3ef4a43
Fix #16382 - remove apc extension code
Fixes: #16382
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-04-28 21:05:06 +02:00
Maurício Meneghini Fauth
8d0c2a339c
Move both operands of an assignment to the same line
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-04-20 22:35:21 -03:00
Maurício Meneghini Fauth
91bd0df2e5
Rename $err_url global to $errorUrl
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-24 19:39:28 -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
7e33d227f5
Rename the PMA_Config global variable to config
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-08 15:03:12 -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