Commit Graph

287 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
eb3703882b
Move Routing::getCurrentRoute to ServerRequest
The route is retrieved from the request, so it makes sense to move the
method to the Http\ServerRequest class.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-06-06 23:36:57 -03:00
Maurício Meneghini Fauth
d58057daec
Extract Database\PrivilegesController from Server\PrivilegesController
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-05-27 17:13:23 -03:00
Maurício Meneghini Fauth
dc5bf0074c
Extract Table\PrivilegesController from Server\PrivilegesController
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-05-27 16:25:39 -03:00
Maurício Meneghini Fauth
6201c7f2ba
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-05-27 13:27:59 -03:00
Maurício Meneghini Fauth
229d99bb81
Fix checking db and table privileges when case is sensitive
Fixes https://github.com/phpmyadmin/phpmyadmin/issues/17558

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-05-26 16:05:58 -03:00
Maurício Meneghini Fauth
6dc859cbc2
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-04-28 15:56:18 -03:00
Maurício Meneghini Fauth
54df014550
Remove stickyfilljs JavaScript dependency
This polyfill is not needed anymore.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-04-27 19:47:31 -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
Maurício Meneghini Fauth
81cfa99df4
Move Advisor class to PhpMyAdmin\Advisory namespace
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-02-24 13:16:19 -03:00
Maurício Meneghini Fauth
5a34a3bb04
Remove db and table properties from controllers
Replaces them with their respective globals.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-02-02 14:48:43 -03: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
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
fa5c684f27
Replace the master/slave terminology
Replaces master with primary and slave with replica.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-18 14:26:56 -03:00
Maurício Meneghini Fauth
cb3f7fbb16
Move Server\UserGroups to ConfigStorage namespace
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-17 12:09:14 -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
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
945d887a10 Fix var annotation for Charset and Collation
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-09 22:25:58 +00:00
Kamil Tekiela
253b08330d Make $subPart non-nullable and remove redundant ?? when it's not null
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-03 19:36:06 +00:00
Kamil Tekiela
9245cec290 Fix type issues in PrivilegesController
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-12-01 13:20:08 +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
fbd5b0a67c
Redesign the export/import pages to use Bootstrap components
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-25 13:37:47 -03:00
Kamil Tekiela
51f4017b32
Refactor destroy controller (#17194)
* Remove redundant conditions

They were always true. First, the variable is set to -1.
If the variable is -1, then set it to Message.
If the variable is Message then set the JSON array. All of this is
redundant.

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

* $sqlQuery is not used anywhere

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

* Enforce $selected to be an array

I can't remove it as it is a global. Previously, it was set to a POST
variable. Since we validate that the variable is set and is not null,
we can use the value from $params. If we validate that it's also an
array we can replace for loop with foreach.
There is no passing by reference, so this change should be safe.

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

* Replace $rebuildDatabaseList with input validation

The validation message says 'No databases selected.' so I assume that
we should check that we actually got at least one entry in the list.
If that is true, then the $rebuildDatabaseList is not needed and the
condition redundant.

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

* drop_selected_dbs is always set and is redundant

I am not sure if this is necessary. The AJAX request sends a value of "1"
but the code doesn't really do anything with it other than checking if
it is actually set. Is there some other path possible?

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

* Flatten the array with a single element

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

* Remove redundant isset

The variable is set, so !isset === is_null. Why check for null if we can
check just for !is_array.

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

* Update psalm-baseline.xml

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

* Adhere to the coding standard

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-19 14:26:04 -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
7955f7d96d
Replace pow function with the ** operator
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-27 19:12:11 -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
3531775b7c
Add type declarations to the controllers contructors
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-11 17:32:22 -03:00
Maurício Meneghini Fauth
83091680cc
Extract actions from controllers to new controllers
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-10 17:55:05 -03:00
Maurício Meneghini Fauth
38fda677bd
Extract Processes class from ProcessesController
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-10 15:52:48 -03:00
Maurício Meneghini Fauth
94e714a49b
Extract the Server\ShowEngineController class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-09 17:58:00 -03:00
Maurício Meneghini Fauth
e3554879ef
Extract actions from controllers to new controllers
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-07 21:19:43 -03:00
Maurício Meneghini Fauth
8f2f3eff40
Remove the Core::isValid method
This improves the type checking and simplifies the code.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-02 13:20:50 -03:00
Maurício Meneghini Fauth
a2ed4dfe68
Make controllers callable
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-30 13:16:29 -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
Maurício Meneghini Fauth
84d175b282
Extract HTML from Plugins::getChoice method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-25 15:29:43 -03:00
Maurício Meneghini Fauth
7a4536d4d6
Remove PhpMyAdmin\Twig\PluginsExtension class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-25 11:00:21 -03:00
Maurício Meneghini Fauth
f7fc4177af
Add support for account locking
- https://dev.mysql.com/doc/refman/en/account-locking.html
- https://mariadb.com/kb/en/account-locking/

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-21 00:55:33 -03:00
Maurício Meneghini Fauth
04d3c83559
Fix some errors found by PHPStan/Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-08-05 16:09:08 -03:00
William Desportes
8aa4e30512
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-29 03:16:09 +02:00
William Desportes
4b9a9628f3
Merge #17045 - Fix #11834 - Fixing the issues regarding granting/showing priv from priv tab
Pull-request: #17045
Fixes: #11834

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-29 02:52:09 +02:00
Fawzi E. Abdulfattah
3f985e2124 Fixing the issues regarding granting and showing the privileges from the privileges tab
Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
2021-07-28 17:26:01 +02:00
Fawzi E. Abdulfattah
84e9b611a6 fixing the links when granting privileges on tables or routines
Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
2021-07-28 03:42:02 +02:00
William Desportes
c5a1dd2ec7
Merge #16925 - Replace Export privileges group dialog with a modal
Pull-request: #16925

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-27 03:26:32 +02:00
William Desportes
9373c8ec70
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-22 14:51:35 +02:00
William Desportes
d281dcc0bd
Fix #17026 - Handle possible invalid boolean values injected in SaveDir or UploadDir
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-22 12:59:54 +02:00