Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substring browser display transformation error "Argument #2 must be of type int" #16704

Closed
ibennetch opened this issue Mar 3, 2021 · 3 comments
Assignees
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
Milestone

Comments

@ibennetch
Copy link
Member

ibennetch commented Mar 3, 2021

Using PMA from the latest master.

When trying to use any values for the Substring transformation, I get the following error message. Mostly my "Browser transformation option" was set to 0,5,'MORE'

PHP Fatal error:  Uncaught TypeError: mb_substr(): Argument #2 ($start) must be of type int, string given in libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php:58
Stack trace:
#0 libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php(58): mb_substr()
#1 libraries/classes/Display/Results.php(5019): PhpMyAdmin\\Plugins\\Transformations\\Abs\\SubstringTransformationsPlugin->applyTransformation()
#2 libraries/classes/Display/Results.php(3796): PhpMyAdmin\\Display\\Results->getRowData()
#3 libraries/classes/Display/Results.php(2938): PhpMyAdmin\\Display\\Results->getDataCellForNonNumericColumns()
#4 libraries/classes/Display/Results.php(2553): PhpMyAdmin\\Display\\Results->getRowValues()
#5 libraries/classes/Display/Results.php(4172): PhpMyAdmin\\Display\\Results->getTableBody()
#6 libraries/classes/Sql.php(1346): PhpMyAdmin\\Display\\Results->getTable()
#7 libraries/classes/Sql.php(1599): PhpMyAdmin\\Sql->getHtmlForSqlQueryResultsTable()
#8 libraries/classes/Sql.php(1828): PhpMyAdmin\\Sql->getQueryResponseForResultsReturned()
#9 libraries/classes/Sql.php(1680): PhpMyAdmin\\Sql->executeQueryAndGetQueryResponse()
#10 libraries/classes/Controllers/SqlController.php(218): PhpMyAdmin\\Sql->executeQueryAndSendQueryResponse()
#11 libraries/classes/Routing.php(186): PhpMyAdmin\\Controllers\\SqlController->index()
#12 index.php(18): PhpMyAdmin\\Routing::callControllerForRoute()
#13 {main}
  thrown in libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php on line 58
@shucon
Copy link
Contributor

shucon commented Mar 5, 2021

Hey @ibennetch, can you please elaborate on the steps to reproduce this?

@ibennetch ibennetch changed the title Substring transformation error "Argument #2 must be of type int" Substring browser display transformation error "Argument #2 must be of type int" Mar 5, 2021
@ibennetch
Copy link
Member Author

Sure!

So the idea of this particular transformation is that it only displays a portion of the result, and can substitute some text when that truncation occurs. It's somewhat useful for forcing browse mode to only display part of a result, for instance if every row of a particular column starts with the same text "The president is:", one could use this transformation to only display the names with 17,all,'...', or if you want to truncate strings longer than 20 characters you could use a setting somewhat like 0,20,'-MORE-'

For my test, I have a table with one VARCHAR column and on that column (either with the Change link or when creating the structure initially) I've set a "Browser display transformation" of Substring and options 0,5,'-MORE-'

image

@ibennetch
Copy link
Member Author

ibennetch commented Mar 5, 2021

I get the same problem when using the substring input transformation instead:

PHP Fatal error:  Uncaught TypeError: mb_substr(): Argument #2 ($start) must be of type int, string given in libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php:61
Stack trace:
#0 libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php(61): mb_substr()
#1 libraries/classes/Controllers/Table/ReplaceController.php(272): PhpMyAdmin\\Plugins\\Transformations\\Abs\\SubstringTransformationsPlugin->applyTransformation()
#2 libraries/classes/Routing.php(186): PhpMyAdmin\\Controllers\\Table\\ReplaceController->index()
#3 index.php(18): PhpMyAdmin\\Routing::callControllerForRoute()
#4 {main}
  thrown in libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php on line 61

@williamdes williamdes added this to the 5.1.1 milestone Mar 6, 2021
@williamdes williamdes self-assigned this Mar 6, 2021
@williamdes williamdes added the Bug A problem or regression with an existing feature label Mar 6, 2021
@williamdes williamdes added this to Needs triage in issues via automation Mar 6, 2021
@williamdes williamdes moved this from Needs triage to ready to merge in issues Mar 6, 2021
shucon added a commit to shucon/phpmyadmin that referenced this issue Mar 6, 2021
@williamdes williamdes added the has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete label Mar 6, 2021
williamdes added a commit that referenced this issue Mar 6, 2021
Signed-off-by: William Desportes <williamdes@wdes.fr>
williamdes added a commit to williamdes/phpmyadmintest that referenced this issue Mar 6, 2021
Signed-off-by: William Desportes <williamdes@wdes.fr>
issues automation moved this from ready to merge to Closed Mar 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
issues
  
Closed
Development

Successfully merging a pull request may close this issue.

3 participants