Commit Graph

288 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
d760df02dd
Move DBI getEvents method into the Events class
DatabaseInterface::getEvents -> Database\Events::getDetails

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-09-10 12:48:44 -03:00
Maurício Meneghini Fauth
81192a142b
Move DBI getRoutines method to the Routines class
DatabaseInterface::getRoutines -> Database\Routines::getDetails

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-09-09 23:29:26 -03:00
Maurício Meneghini Fauth
9d2350d28c
Extract dbi global variable from Index::loadIndexes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-09-07 21:59:03 -03:00
Maurício Meneghini Fauth
bc4fa31a06
Add better type description for Dbal\DbalInterface::getTableIndexes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-09-07 16:14:04 -03:00
Maurício Meneghini Fauth
d3a267fdfc
Refactor DbiMysqli::connect to use Server value object
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-08-29 18:19:38 -03:00
Maurício Meneghini Fauth
a5d60f5698
Refactor the Server\PrivilegesTest test class
Removes the class properties to better isolate the test.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-07-07 16:19:01 -03:00
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
92457c1607
Fix an issue detected by Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-05-03 15:59:29 -03:00
Kamil Tekiela
116708ffd4 Microoptimize escapeString
Technically, it's less opcode :)

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-03-15 16:39:29 +00:00
Maurício Meneghini Fauth
c0941401c1
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-03-11 14:26:19 -03:00
Maurício Meneghini Fauth
2653b2942b
Merge branch 'QA_5_1' into QA_5_2
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-03-11 13:02:15 -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
f8bba12d61
Rename DatabaseInterface variables to use camel case
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-03-01 14:30:01 -03:00
Kamil Tekiela
7be18653aa Fix broken column edit
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-02-13 18:03:34 +00:00
Maurício Meneghini Fauth
a57102412c
Merge branch 'QA_5_1' into QA_5_2
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-26 10:42:45 -03: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
6177f83b03
Merge pull request #17279 from kamil-tekiela/Dbal-pt.4
Major Dbal refactoring pt.4
2022-01-19 12:16:14 -03:00
Maurício Meneghini Fauth
813ffbf562
Merge branch 'QA_4_9-security' into QA_5_1-security
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-13 17:20:04 -03:00
William Desportes
ca54f1db05
security - Fix - 2FA/U2F can be disabled without any code change
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-01-13 19:07:34 +01:00
Kamil Tekiela
b8f6fce3ef Fix parameter types
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-09 23:09:56 +00:00
Kamil Tekiela
86031d2bf6 Deimplement fetchAssoc() helper
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-09 22:44:53 +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
3e6e4fffbc Expose execution time as public property
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-09 21:21:55 +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
2edc9da063 Deimplement dataSeek() 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:22:49 +00:00
Maurício Meneghini Fauth
290f026a02
Merge pull request #17272 from kamil-tekiela/queryAsControlUser
Query as control user
2022-01-06 21:32:46 -03:00
Kamil Tekiela
5883ca608e Add param and return type
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:38:21 +00:00
Kamil Tekiela
d5dbc316c0 Remove matching default values
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:38:20 +00:00
Kamil Tekiela
415eb2c8d7 Convert ternary to boolean expression
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:37:35 +00:00
Kamil Tekiela
a4cb49080a Extract common part from if
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:37:35 +00:00
Kamil Tekiela
01438e9d7a Update docblocks for nullable parameters
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:37:34 +00: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
f38d3baa31 Remove $options parameter from fetchResult
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-01 01:46:17 +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
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
995ec44d13
Move DatabaseInterface::initRelationParamsCache method to Relation class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-12-17 12:09:13 -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
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
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
89fa3d2aea
Merge pull request #17205 from kamil-tekiela/Fix-tryMultiQuery-signature
Fix tryMultiQuery signature
2021-11-26 15:11:50 -03:00
Kamil Tekiela
3a3bb2dc29 Fix tryMultiQuery signature
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-25 13:45:56 +00: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
43867f262d
Fix some errors errors found by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-11 11:16:13 -03:00
Maurício Meneghini Fauth
e8f57353f5
Merge branch 'QA_5_1'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-10-28 14:10:04 -03:00
Maurício Meneghini Fauth
7bcccf7bdc
Remove connection parameter from getClientInfo
Related to #16911

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-10-28 13:53:15 -03:00
Maurício Meneghini Fauth
b188b1fda0 Remove exception throw from Dbal\Warning class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-10-10 18:39:43 -03:00