Commit Graph

234 Commits

Author SHA1 Message Date
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
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
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
William Desportes
1c9c4b183a
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-20 02:45:54 +02:00
William Desportes
028d52f130
Merge #17074 - Fix #17018 - Cannot save data from gis editor for spatial column insert
Pull-request: #17074
Fixes: #17018

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-18 02:40:41 +02:00
William Desportes
75eacc7697
Fix #14502 - Uncheck the "ignore" checkbox on GIS modal save value
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-18 02:18:02 +02:00
Maximilian Krög
93c8a9e505
Fix inserting spatial data
Fix inserting geometries with MySQL < 5.6
Fix wkb functions for inserting
Fix selecting default function in insert form

Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
2021-08-14 20:12:14 +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
William Desportes
d7c9ed73e6
Fix #17020 - "Notice Undefined index: sql_query"
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-21 01:19:19 +02:00
William Desportes
1645ee38fb
Remove InsertEdit::getUrlParameters
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-20 16:12:30 +02:00
William Desportes
814da7d73d
Fix #17020 - "Notice Undefined index: sql_query"
It was reported and reproduced on 5.2 but anyway I fix it on 5.1 in case

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-20 01:30:36 +02:00
William Desportes
fcd0a2393a
Fix coding standard issues
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-15 02:44:05 +02:00
William Desportes
8f77a9f29d
Ref #15247 - Remove defined('TESTSUITE') from ReplaceController and remove an exit
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-15 02:39:14 +02:00
William Desportes
c830c1e93a
Merge branch 'origin/QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-15 02:34:29 +02:00
William Desportes
f490ee8867
Fix a coding standard mistake
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-15 00:49:21 +02:00
William Desportes
8500a6c5a1
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-07-13 22:43:26 +02:00
Fawzi E. Abdulfattah
90793f6e88 Fixing the null issue with datetime in insert mode
Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
2021-07-13 03:03:49 +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
6ae07c96fb
Replace strpos !== false with str_contains
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-09 22:30:42 -03:00
Maurício Meneghini Fauth
e8c28d1883
Remove some globals from Config::enableBc method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-08 19:49:26 -03:00
Liviu-Mihail Concioiu
7c0d82d363
Fix table width on Insert page
Pull-request: #16986

Signed-off-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
2021-07-08 15:40:38 +02:00
Maurício Meneghini Fauth
9adaa912e1
Rename Response class to ResponseRenderer
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-30 12:35:22 -03:00
Maurício Meneghini Fauth
21431578db
Fix some errors found by PHPStan and Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-24 18:03:14 -03:00
William Desportes
0a1f083990
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-23 20:36:21 +02:00
William Desportes
6e5432d2d1
Merge #16949 - Fix #16935 - Remove hardcoded row length
Fixes: #16935
Pull-request: #16949
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-21 23:45:27 +02:00
Saksham Gupta
05587f29bd Fix #16935 Remove hardcoded row length
Signed-off-by: Saksham Gupta <shucontech@gmail.com>

Make changes in default file and docs

Signed-off-by: Saksham Gupta <shucontech@gmail.com>
2021-06-20 16:41:23 +05:30
William Desportes
300e835edb
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-16 01:10:11 +02:00