Commit Graph

354 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
6a2c12bdc8
Add missing traversable type hints
Replace array type hint with mixed[] type hint, since it means the same.
This way it's possible to require traversable type hint for new code.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-04-02 01:32:12 -03:00
Maurício Meneghini Fauth
4b1593bc1f
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-30 11:51:53 -03:00
Kamil Tekiela
ef0ea05a8f Measure time only for user queries
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-30 00:41:38 +01:00
Maurício Meneghini Fauth
dd885dc7b8
Use single-line arrays when possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-27 17:39:17 -03:00
Maurício Meneghini Fauth
e5698c85e9
Require single line for function calls
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-26 23:10:10 -03:00
Maurício Meneghini Fauth
437215cab2
Rename variables to use camel case format
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-26 21:47:50 -03:00
Kamil Tekiela
7c53199702
Fix merge issues (#18289)
* Fix type issues after merge

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

* Update DbiDummy.php

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

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-25 22:53:14 -03:00
Maurício Meneghini Fauth
8972c0ec22
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-24 18:15:47 -03:00
Maurício Meneghini Fauth
0301e48a27
Add ChangeLog entry for #17702
- Closes #17702

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-03-24 16:35:15 -03:00
Nicolas Hervouet
e4d9a1a66a
Fix for handle large number of tables in a single database (more than 10k)
getTablesFull was taking too much time, because MySQL do not have a real table where it stores all tables information.
So when it runs a query like select * from information_schema.TABLES ORDER BY Name limit 250 offset 0, MySQL has to read information about all tables to build his in memory table, then sort it by name, and then return 250 first tables.
But reading information about one table takes time, and that's why the query is very slow when you have a lot of tables.
Note that the problem is the same with 'SHOW TABLE STATUS'.

So, in order to speed up this query, we have to limit it to a small list of tables, as it, MySQL has to read table information only for few tables.
Note that SHOW TABLES is not that long, even with a large amount of tables.

The idea here is to use the result of SHOW TABLES query, to apply paging on this table list, and then to run the query on information_schema.TABLES only on tables we want.

Signed-off-by: Nicolas Hervouet <github@pico12.fr>
2023-03-24 11:55:30 -03:00
Kamil Tekiela
74c48a499b Fix error in normalization
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-19 21:56:01 +00:00
Kamil Tekiela
fce745a874 Fix #18275
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-19 10:04:49 +00:00
Kamil Tekiela
c0b367cc57 Create Tracking namespace
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-17 22:35:32 +00:00
Kamil Tekiela
555c6798eb Add native param types
Includes TypeHints.UnionTypeHintFormat

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-17 12:45:18 +00:00
Kamil Tekiela
e9b9c120af Fix getTablesFull() and related tests
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-15 19:59:35 +00:00
Kamil Tekiela
3db245f462 Optimize export of many tables
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-15 19:59:35 +00:00
Kamil Tekiela
d7f599df00 Accept table with name 0 in getTablesFull
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-14 22:11:05 +00:00
Kamil Tekiela
282dc9a27e Fix a bug with numerical table name
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-03-14 21:35:10 +00:00
Maurício Meneghini Fauth
342ab3f67a
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-27 14:36:32 -03:00
Kamil Tekiela
0bdcaba2d2
Add native property types (#18143)
* Add native property types

Includes TypeHints.UnionTypeHintFormat

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

* Set some default values for properties

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

* Format and promote properties

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

* Remove redundant asserts

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

* Redundant cast

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

* $tmanager->theme is never null

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

* Redundant variable

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

* Fix empty on $statementInfo bool

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

* Redundant casts

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

* Redundant issets

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

* getPacked() returns nullable string

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

* Redundant if

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

* $this->content can be null

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

* Simplify ThemeManager::getInstance()

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

* Use isset for checking if property is initialized

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

* Use nullable instead of uninitialized property

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

* password is no longer nullable

I can't verify that none of the globals ever tried to set it to null, but the variable should never be nullable.

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

* Update baselines

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

* $same_wide_width param can be float or int

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

* Update Message.php

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

* Cast Sub_part to int

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

* Fix one line doc comments

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

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-26 23:30:41 -03:00
Maurício Meneghini Fauth
556594b4cd
Fix coding standard spacing issues
- Fixes one line doc comments
- Fixes parent call spacing
- Fixes constant spacing

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-24 21:06:17 -03:00
Maurício Meneghini Fauth
77957a69a5
Add trailing comma for multi-line functions
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-24 20:48:46 -03:00
Kamil Tekiela
902d1a1e77
Add native return type hints (#18126)
* Add remaining native return type hints to flush out bugs

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

* Cast the mixed value to int

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

* Fix tests

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

* getAutoIncrement() is supposed to return string

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

* Cast values to string in DummyResult

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

* Make getCollation() return non-nullable string

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

* Cast seqInIndex to int

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

* Cast $cardinality to int

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

* createFile may return false

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

* Remove redundant cast

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

* Update baselines

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

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-23 15:43:36 -03:00
Kamil Tekiela
aa63c6821a Fix bug related to tables with numerical names
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-22 13:18:06 +00:00
Maurício Meneghini Fauth
4ff3724c3f
Use union with null instead of short nullable type
Since union type are now possible, using union with null makes more
clear that it is a union type.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-20 21:48:19 -03:00
Kamil Tekiela
cfe54a501b Add union types
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-15 15:23:28 +00:00
Kamil Tekiela
164bf08f4c Move getColumnMapFromSql() to SystemDatabase
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-15 12:41:47 +00:00
Kamil Tekiela
2b35303aae
Remove redundant code (#18063)
PHPStorm has been a little annoying with showing all these code issues. I took some time to analyse most of them and fix whichever were easy to fix. This kind of change should improve future maintenance as developers do not need to wonder what a line of code does. Code that has no impact on functionality should be removed.

* Remove redundant variables
* Invert condition for better clarity
* Remove some of the redundant casts
* Replace switch with an if
* Fix foreach variable
* Remove redundant variable concat
* Remove redundant concats
* Replace for loop with str_repeat
* Remove always true param
* Turn property $position into local var
* Turn Pdf properties into local vars
* Remove unused properties in Pdf
* Change ternary into condition
* Remove redundant assignments
   They are immediately overwritten with a different value.
* Redundant array append
* Collapse if statements into assignments
* Use boolean constants instead of variables
* Remove unneeded parameter
* Remove null-coalesce
* Unnecessary assignment
* Remove redundant isset
* Remove readOnly flag for InsertEdit fields
* Remove function_exists and $mode var
* Remove duplicate condition
* Remove redundant elseif
* Remove redundant isset
* Use hasBodyParam()
* Simplify isRoutesCacheFileValid()
   Psalm complains but is wrong.

https://github.com/phpmyadmin/phpmyadmin/pull/18063

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-15 09:11:05 -03:00
Maurício Meneghini Fauth
e854e79d3b
Merge pull request #18086 from kamil-tekiela/Replace-switch-with-match
Replace switch with match
2023-02-14 20:04:17 -03:00
Maurício Meneghini Fauth
26b5860484
Merge pull request #18089 from kamil-tekiela/first-class-callable
Convert to first class callables
2023-02-14 17:36:13 -03:00
Kamil Tekiela
b6f0da1c09 Convert to first class callables
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-14 14:18:23 +00:00
Kamil Tekiela
87e42d591c Use short closures where possible
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-14 13:44:42 +00:00
Kamil Tekiela
69f8d9f85c Replace switch with match
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-14 13:07:00 +00:00
Kamil Tekiela
8a1d6f1eaa Convert var annotations to typed properties
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2023-02-12 21:31:04 +00:00
Maurício Meneghini Fauth
4129bfe23e
Create Dbal/Statement interface
Wraps mysqli_stmt class with the Dbal\MysqliStatement class.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-01-20 00:36:01 -03:00
Maurício Meneghini Fauth
41dec1effc
Extract connection type constants to the Connection class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-01-17 02:21:27 -03:00
Maurício Meneghini Fauth
a6bdf8a811
Create Dbal\Connection class
Wraps the connection object with the Connection class.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-01-16 15:31:02 -03:00
Maurício Meneghini Fauth
591bc50e22
Extract method to get warning count from DatabaseInterface
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-01-16 14:03:21 -03:00
Maurício Meneghini Fauth
fdf474abf9
Merge pull request #17981 from kamil-tekiela/getTables-investigation
Improve some type inference in various places

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-12-24 13:44:45 -03:00
Maurício Meneghini Fauth
d5f3c91b29
Merge pull request #17979 from kamil-tekiela/Optimize-fetchResult
Microoptimization of fetchResult()

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-12-24 13:32:45 -03:00
Kamil Tekiela
6264f6f1ea
Various refactorings 2 (#17965)
* Remove extra blank lines
* Remove useless param annotations
* Refactor Index::singleton
* Refactor Config.php
* Refactor Header::addRecentTable()
* Collapse return statement into a single line
* Refactor Message.php
* Convert $getUniqueCondition into a scalar
* Code style
* Fix invalid return phpdoc
* Remove unused variable
* Remove redundant empty array checks
* Refactor Export::closeFile()
* Simplify else statement
* Remove redundant else
* Refactor TablePartitionDefinition::getDetails
* Simpler returns
* Add types for getCellContent()
* Remove useless method mngInsideStructComm

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-24 12:54:23 -03:00
Kamil Tekiela
bc6fb312db Improve type inference in getTables()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-19 23:29:25 +00:00
Kamil Tekiela
fd52b85eed Microoptimization of fetchResult()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-19 19:30:13 +00:00
Kamil Tekiela
dd699f348d Clean up LIKE escaping
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-25 00:06:52 +00:00
Maurício Meneghini Fauth
e194eb3961
Improve type DatabaseInterface's $link params
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-21 14:50:52 -03:00
Maurício Meneghini Fauth
ca489f3b41
Improve type of DatabaseInterface::getLowerCaseNames()
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-19 15:50:14 -03:00
Maurício Meneghini Fauth
219a665c8f
Improve type of DatabaseInterface::getCurrentUserGrants()
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-19 15:50:14 -03:00
Maurício Meneghini Fauth
3ec0a92a0b
Improve type inference of getCurrentUserAndHost()
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-19 13:05:23 -03:00
Maurício Meneghini Fauth
3c26a938cb
Add better type inference for DatabaseInterface::$links
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-18 21:36:38 -03:00
Maurício Meneghini Fauth
d0d90551c3 Remove the dblist global variable
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-13 21:08:00 -03:00