Commit Graph

47 Commits

Author SHA1 Message Date
William Desportes
b9c593c67d
Fix #17766 - Allow to open in a new tab copy and edit row actions
Signed-off-by: William Desportes <williamdes@wdes.fr>
2022-11-25 19:55:53 +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
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
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
488e7cb5bf Use array_keys whenever only keys are needed in foreach
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-29 20:37:39 +00: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
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
bfaf16f56b
Use only callable controllers
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-09-11 15:20:46 -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
William Desportes
1c9c4b183a
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-08-20 02:45:54 +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
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
Maurício Meneghini Fauth
8e4d6229a9
Fix some errors found by Psalm
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-07-06 00:37:27 -03: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
William Desportes
6996e8dd28
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 19:01:02 +02:00
William Desportes
535b374163
Fix "Undefined index: clause_is_unique" on replace value in cell
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-27 18:27:38 +02:00
William Desportes
300e835edb
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-16 01:10:11 +02:00
William Desportes
f09ead5e07
Fix code using relative path
if (chdir('/tmp') === false) {
    die('Could not change dir');
}

Signed-off-by: William Desportes <williamdes@wdes.fr>
2021-06-15 22:24:30 +02:00
Maurício Meneghini Fauth
1c084de30b
Fix coding standard errors
Related to 62f142c9fa.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-03 16:50:33 -03:00
Maurício Meneghini Fauth
8d0c2a339c
Move both operands of an assignment to the same line
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-04-20 22:35:21 -03:00
Maurício Meneghini Fauth
44bdd1d390
Rename $url_params global to $urlParams
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-24 22:48:14 -03:00
Maurício Meneghini Fauth
91bd0df2e5
Rename $err_url global to $errorUrl
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-24 19:39:28 -03:00
Maurício Meneghini Fauth
d83abf63e7
Use PSR-12 for control structures spacing
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-05 15:27:03 -03:00
Maurício Meneghini Fauth
0b8edc5bde
Use PSR-12 for namespace use statements
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-03-05 14:18:35 -03:00
Maurício Meneghini Fauth
601ed4649e Remove DBI dep from Table\AbstractController
Moves the DatabaseInterface class dependency to the classes that use it.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-10-12 12:53:03 -03:00
Maurício Meneghini Fauth
bb32ba6d9c Fix some coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-10-04 12:31:43 -03:00
William Desportes
aecdfc80cb
Merge branch 'QA_5_0'
Signed-off-by: William Desportes <williamdes@wdes.fr>
2020-10-04 00:29:04 +02:00
Maurício Meneghini Fauth
1dccc10493 Extract method for adding script files
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-12 16:58:33 -03:00
Maurício Meneghini Fauth
3b285ff17e Use identical operator for non-empty strings
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-10 18:06:29 -03:00
Maurício Meneghini Fauth
a3147c26e1 Extract exit; from Core::previewSQL method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-09 16:20:41 -03:00
Maurício Meneghini Fauth
05c62ad1a8 Fix some PHPStan errors
Fixes "Cannot access offset on array" errors.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-02 16:12:07 -03:00
Maurício Meneghini Fauth
f4582e083e Use early exit when possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-27 00:35:24 -03:00
Maurício Meneghini Fauth
bd979dd1ff Remove useless elseif with if
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-26 22:53:44 -03:00
Maurício Meneghini Fauth
94955f187a Fix function call signatures indentation
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-26 04:22:02 -03:00
Maurício Meneghini Fauth
3baad2eb1c Fix some coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-25 22:42:37 -03:00
Maurício Meneghini Fauth
a64393e7f5 Fix some coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-05-13 00:23:28 -03:00
Maurício Meneghini Fauth
676f48349a Reference global funcs and consts via use statement
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-21 22:13:36 -03:00
Maurício Meneghini Fauth
f80d3e3bd4 Remove unnecessary annotations
@package, @subpackage and others.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-20 17:35:56 -03:00
Maurício Meneghini Fauth
50bc4ab37f Remove useless PHP docs for functions
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-20 13:20:01 -03:00
Maurício Meneghini Fauth
8ec4209002 Fix some coding standard issues
- Inverts yoda comparisons
- Removes parentheses from return
- Removes useless ternary operators
- Adds paretheses to new instances
- Adds trailing array comma

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-20 00:38:34 -03:00
Maurício Meneghini Fauth
7837ab81f2 Remove the table sql entry point file
Directly calls the controller instead of including the file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-06 23:15:26 -03:00
Maurício Meneghini Fauth
634c9f38e9 Remove the table replace entry point file
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-06 23:15:26 -03:00
Maurício Meneghini Fauth
d190c82f1e Remove the table change entry point file
Directly calls the controller instead of including the file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-06 23:15:26 -03:00
Maurício Meneghini Fauth
42468cb033 Remove the database sql entry point file
Directly calls the controller instead of including the file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-06 23:15:26 -03:00
Maurício Meneghini Fauth
cbce3a66e3 Remove the sql entry point file
Directly calls the controller instead of including the entry point file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-06 23:15:26 -03:00
Maurício Meneghini Fauth
fc9fcd1550 Create Table\ReplaceController controller
Extracts the table replace entry point logic to the controller.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-01-04 13:27:48 -03:00