Commit Graph

261 Commits

Author SHA1 Message Date
Maurício Meneghini Fauth
551c317aee
Merge pull request #17982 from kamil-tekiela/Elvis
Remove usage of elvis operator

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-12-24 13:46:33 -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
9a8dc40ae9 Remove usage of elvis operator
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-12-20 19:50:58 +00:00
Kamil Tekiela
3b49a5bedb Implement quoteString()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-06 19:06:48 +00:00
Mo Sureerat
15e629c9c1 [ISSUE-17793] UUID - Fix insert error
Signed-off-by: Mo Sureerat <sureemo@gmail.com>
2022-11-03 05:55:37 +07:00
Mo Sureerat
ddf928e6f3 [ISSUE-17793] Revert previous change + Fix default selection of uuid in alter table
Signed-off-by: Mo Sureerat <sureemo@gmail.com>
2022-11-03 05:25:14 +07:00
Mo Sureerat
f8bee4cd5d [ISSUE-17793] Insert record - fix null not selected if nullable UUID + insert error
Signed-off-by: Mo Sureerat <sureemo@gmail.com>
2022-11-03 05:25:04 +07:00
William Desportes
25c13d667b
Merge branch 'QA_5_2'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-10-26 12:22:38 +02:00
Mo Sureerat
aeab8a1c41
Fix #17793 - insert UUID (#17797)
* Add/Change table schema - Add UUID in default options
* Insert/Update - Generate uuid only not defined and not check null option
* Add/Change table schema - Hide UUID from default options if database not support & add unit test

Fix #17793

Signed-off-by: Mo Sureerat <sureemo@gmail.com>
2022-10-20 15:57:53 -03:00
Liviu-Mihail Concioiu
5ab43f618d
Adds support for SHA2 function (#17809)
* Adds support for SHA2 function

Fixes #17760

Signed-off-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
2022-10-18 16:12:06 -03:00
Kamil Tekiela
f2a83311ae Simplify onchange in InsertEdit.php
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-10-17 21:28:57 +01:00
Jesper Skytte Marcussen
23995b3c73
Adding inputmode numeric to integer fields (#17753)
* Adding inputmode numeric to integer fields

To easier use phpMyAdmin on touch devices with virtual keyboards, adding the inputmode ensures that the correct virtual keyboard is shown per default when focusing the field.

See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode for more information.

Related to #17745.

Signed-off-by: Jesper Skytte <jesper@skytte.it>
2022-10-09 15:26:32 -03:00
Kamil Tekiela
f7f8722e1f
Refactor insert edit (#17684)
This is a major redesign of the code that handles these four actions: in-place edit(AJAX), edit of multiple rows, copying of rows, and insertion of new rows. The goal is to make the code easier to read and more understandable.

    I introduced a new DTO for better readability.
    Some of the methods were made private to the model
    The controller has access to two methods for getting the value for INSERT and for UPDATE
    Unfortunately, I have introduced method envy on EditField, but I do not want to move the functionality away from InsertEdit.php
    Unit tests have not improved in readability but I added helpful comments explaining what we are testing. There's probably a way to improve it too.

I will probably merge all commits once I decide it's ready for review.


Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-08-22 22:39:53 -03:00
Maurício Meneghini Fauth
0b2ab57ea2
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-08-19 00:31:22 -03:00
Kamil Tekiela
fc932a9a8f Allow fields to be set to NULL
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-08-15 14:35:21 +01:00
Maurício Meneghini Fauth
f57ea10921
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-08-12 21:13:24 -03:00
Kamil Tekiela
06d58c9662 Fix bug #17663
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-08-08 14:41:51 +01:00
Kamil Tekiela
1e70bba883 Fix bug not allowing insertion of set values
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-08-08 14:33:50 +01:00
Kamil Tekiela
6d0a30a391 Fix errors in InsertEdit
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-06-04 19:06:16 +01:00
Kamil Tekiela
b82027ef6d Redesign function fields in insert
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-06-03 20:15:58 +01:00
Maurício Meneghini Fauth
d104e8b1bb
Fixed some issues reported by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-06-02 22:36:55 -03:00
Maurício Meneghini Fauth
27bdd0d64d
Extract InsertEdit dependencies to constructor params
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-06-01 23:42:47 -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
20ebad0ec5
Merge pull request #17410 from kamil-tekiela/pr/17211
transfer the HTML content in InsertEdit.php for a twig file
2022-03-04 12:24:03 -03:00
Kamil Tekiela
aa9c6d7b3a Apply code style and fix issues
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-02-20 16:35:49 +00:00
Kamil Tekiela
848c4ef172 Fix broken Insert page
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-02-18 14:14:22 +00:00
Isaac Bennetch
985912f58f Fix merge conflicts from security branch
Signed-off-by: Isaac Bennetch <bennetch@gmail.com>
2022-01-20 12:28:17 -05:00
Maurício Meneghini Fauth
0bee94b27e
Merge branch 'QA_5_1-security' into master-security
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-11 14:31:56 -03:00
Maurício Meneghini Fauth
02e8588404
Merge branch 'QA_4_9-security' into QA_5_1-security
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-10 18:39:23 -03:00
Maurício Meneghini Fauth
0b575ff2e9
Fix URL encryption for Util::linkOrButton method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-10 12:19:44 -03:00
Maurício Meneghini Fauth
6f0d19f394
Do not encrypt params if used in data-post attribute
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-01-10 12:19:43 -03: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
4c22cf1f13 Remove pass-by-ref
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-01-06 19:38:21 +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
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
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
Pedro Henrique F. Pimentel
cf96392b05 fixed errors with phpcbf
Signed-off-by: Pedro Henrique F. Pimentel <pedrohfpimentel@gmail.com>
2021-11-28 11:14:43 -03:00
Pedro Henrique F. Pimentel
e2991a31bd transfer the HTML content in InsertEdti.php to the value_column_for_other_datatype.twig file
Signed-off-by: Pedro Henrique F. Pimentel <pedrohfpimentel@gmail.com>
2021-11-27 22:50:11 -03:00
Maurício Meneghini Fauth
400c9e1d93
Merge pull request #17204 from kamil-tekiela/Refactor-DatabaseInterface-getColumns()
Refactor DatabaseInterface::getColumns()
2021-11-26 15:07:20 -03:00
Maurício Meneghini Fauth
8b2286bdc9
Fix some failing tests
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-11-26 15:02:28 -03:00
Kamil Tekiela
22a6fc9045
Minor refactoring of InsertEdit.php (#17199)
* Simplify condition

isset is not needed since the variable is set and we check explicitely for an array so it cannot be null either.
!empty is not needed because the variable is set, so we just need to check if it has non-empty value

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

* Reduce indentation thanks to early returns

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

* Collapse isset check

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

* Remove redundant variable assignments

$specialCharsEncoded is immediately overwritten in if/else.
$noSupportTypes is always empty and never used in this code.

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

* Remove redundant !empty() checks on parameters and defined variables

if(!empty($var)) on defined variables is redundant and equivalent to if($var)

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

* Remove redundant ternary

$dispval is declared to be a string so the ternary is redundant

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

* Refactor showEmptyResultMessageOrSetUniqueCondition

Replace boolean variable with returns, which leads to redundant else
block. Remove redundant unset, which leads to redundant variable assignment.
The return statement can be replaced with a boolean cast.

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

* Remove redundant unset at the end of the method

When a variable leaves scope it is automatically unset

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

* [RISKY] Remove temporary var and error supression

It's risky because I was not able to determine the purpose of the error
suppression. In case of error, the function seems to return -1, but that
has not been checked here either. It was possible to silence undefined
global variable, but in that case, why was it not done only on that one
line?

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

* Remove redundant condition

The variable is declared as int|false so if it is not false and not 0,
the only logical choice is a non-zero integer, which is always true.

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

* Misleading type hint leading to invalid unit tests

According to DbiMysqli the first argument should be mysqli_result.
The correct type hint cannot be array. It can be object though.
Tested with a debugger that the passed value is really mysqli_result.

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

* Remove dead code

Remove $inputType. I left the comemnt for posterity, but the variable is
dead. If in the future someone decides to implement it again, then
introducing the variable will not be a problem.

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

* Move block of code to where it should be

I am not sure about this block of code. I don't fully understand what
it is supposed to do. However, making the query at the start of the
function doesn't make sense to me.

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

* Use array_keys instead of foreach with dummy variable

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

* Use is_null instead of isset

True conditions are easier to read than inverted conditions.

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

* Remove redundant variable and break

When the loop breaks then the variable is true.
When the loop finishes then the variable is false.
We can simply replace it with return true/false to make it simpler.

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

* Add type declarations

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

* Refactor getEnumSetAndTimestampColumns

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

* Remove redundant condition

According to searchColumnInForeigners $foreigner is dependant on values
from $foreigners which makes this check redundant.

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

* Refactor getColumnEnumValues

Simplify parameter list, add psalm types, and simplify code

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

* Refactor getColumnSetValueAndSelectSize

Unfortunately, I cannot type hint the return value as then I would have
to type-hint the param as well.

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

* Remove ternary operator

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

* Refactor getSelectOptionForUpload

Added types, removed NULL return (it is only outputted in Twig as
HTML string so NULL made no sense), and simpified parameters.

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

* Refactor getMaxUploadSize

According to getMaxUploadSize the value can only be int.
Comparisons of numerical strings should be avoided. Psalm return type
can be added with the exact types.

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

* Refactor getColumnSize

It takes a string as a second parameter now.
The reason for this is that during normal execution, the value comes
from column specifier e.g. VARCHAR(255), which is a string. The value
in spec_in_brackets could also represent ENUM/SET values, so it can't be
forced as an int.
This change required changing tests to pass a string instead of an array
with an int.
The behaviour should remain the same thanks to the (int) cast (previously
implicit, now explicit).

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

* Remove parameter $realNullValue

This parameter was always false. Instead define it as false inside
each method. The methods are private, so this should not cause any problems.

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

* Add psalm-return

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

* Add an early return and clarify return type

This function should never return false

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

* Change return type to multidimensional array

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

* Refactor getCommentsMap

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

* Type hint $tableColumns as multidimensional array

This simplifies static analysis a little bit

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

* Update phpstan baseline

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

* Fix invalid unit test

The method getTableColumns should return a multidimensional array always.
Added proper type hint to avoid further mistakes and changed mock.
According to my analysis this method should always return a
multidimensional array because parameter $column to getColumns() is null.
Also, this test is pretty useless as it just seems to test the bahaviour
of array_values which behaves as an identity function right now.

Note: The DBAL needs urgent refactoring too. I imagine array_values is
redundant at the moment. The getColumns should only return a list or
columns or a single column. There's no need to reindex the list. I think
Psalm should have picked it up, but I didn't check.

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

* Remove redundant call to Util::extractColumnSpec()

Warning! There is no coverage in unit tests for this piece of code.
While I have analysed the code flow manually, it is possible the
duplicated call had some unknown to me purpose.

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>

* Revert "Remove ternary operator"

This reverts commit 3cbec2cebb.

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

* Rename $field_MD5 to $fieldHashMd5

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

* Exclude string '0' from comparison and invert the order of operation

This helps with readability and it's unlikely that we would want to
check for string '0' here.

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

* Rename $spec_in_brackets to $specInBrackets

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

* Remove else statements

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

* Introduce array_key_exists() and a local variable

We also add phpdoc comment telling static analysis that the value should
be a string. This is what the current code expects already.

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

* Remove object parameter type declaration

Upon further inspection I realize this was wrong. The unit tests rely
on the parameter type being an integer and so we cannot force it to be
only an object. I leave the type hint as object as array was probably
never the right type.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-26 14:19:04 -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
Rodrigo Wanderley de Melo Cardoso
7f7a234e20
Changing HTMLOutput to Twig (#17160)
Signed-off-by: Rodrigo Pokemaobr <contato@pokemaobr.dev>
2021-10-21 15:31:22 -03:00
Rodrigo Wanderley de Melo Cardoso
f4d52552be
Changing HTMLOutput to Twig Templates (#17159)
Signed-off-by: Rodrigo Pokemaobr <contato@pokemaobr.dev>
2021-10-21 14:48:00 -03:00
Maurício Meneghini Fauth
c1e864b1d7
Add Warning value object for SHOW WARNINGS rows
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-10-09 00:09:01 -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
f00d70cccb
Remove useless whitespaces
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-15 17:05:40 -03:00