TYPO3-Console / TYPO3-Console

Console command for TYPO3 CMS
GNU General Public License v2.0
285 stars 139 forks source link

Empty String Parameter in install:setup fails #463

Closed phifa closed 7 years ago

phifa commented 7 years ago

On Windows, GitBash, Console 4.4.1

this works vendor/bin/typo3cms install:setup --database-user-name="root"

this does not work vendor/bin/typo3cms install:setup --database-user-name="root" --database-socket=""

@mbrodala thinks it is because of this https://github.com/TYPO3-Console/typo3_console/commit/0d5910a6e0f8b1318cda39d27d4aa827e7598050

helhum commented 7 years ago

Thanks for your report. Unfortunately I cannot reproduce this. Maybe this is related to Windows. Can you provide a minimal root composer.json to check and the exact PHP version?

helhum commented 7 years ago

also the full stack trace of the error message could be useful

bnf commented 7 years ago

This may be triggerd by a bug in the argument parsing.

If managed to reproduce that error, though with some other argument combinations. I pushed the composer.json and lock to a github repo: https://github.com/bnf/typo3-console-arguments-bug

I've added the output to the README.md. There you see that --database-socket got the value --site-name when invoked as install:setup --database-socket="" --site-name="Site" --non-interactive

That results in a sub-command execution: install:databaseconnect" "'/usr/bin/php' './vendor/bin/typo3cms' 'install:databaseconnect' '--database-socket' '--site-name' Well, and now it's clear, --database-socket is interpreted as boolean flag as the next argument is another option arg. But the root cause looks like some shifting problem for arguments with empty values.

bnf commented 7 years ago

@phifa wrote on slack that he's using

vendor/bin/typo3cms install:setup --database-user-name="root" --database-host-name="localhost" --database-port="3306" --database-socket="" --site-name="Site" --site-setup-type="no" 

So I guess @phifa dropped --site-name for this exampe, without testing whether removing that actually still triggers the error. Can you confirm you really get that error (which you missed to include here btw) with the commands listed above?

For the record, the original error as posted on slack by @phifa

 #1485130941: Executing "install:databaseconnect" failed (exit code: "1") with message:

"                                                                               
 [ TYPO3\CMS\Extbase\Property\Exception ]                                       
 #1297759968: Exception while property mapping at property path "": No converter found which can be used to convert from "boolean" to "string".
 thrown in file ...\vendor\typo3\cms\typo3\sysext\extbase\Classes\Property\PropertyMapper.php
 in line 127                                                                    :
helhum commented 7 years ago

Thanks for the very detailed analysis so far. However, I still cannot reproduce this.

This may be triggerd by a bug in the argument parsing.

Yes, but strange, that it won't happen on my system (BSD).

Argument parsing btw. happens in TYPO3. Console is just using the RequestBuilder

I would be interested in the value of $rawCommandLineArguments on affected systems.

bnf commented 7 years ago

I would be interested in the value of $rawCommandLineArguments on affected systems.

array(4) {
  [0]=>
  string(13) "install:setup"
  [1]=>
  string(18) "--database-socket="
  [2]=>
  string(16) "--site-name=Site"
  [3]=>
  string(17) "--non-interactive"
}

Added that to above mentioned test repo as well: https://github.com/bnf/typo3-console-arguments-bug/commit/47adb7c3ab5d4d4e4362d3a99826765e0dd4de96#diff-04c6e90faac2675aa89e2176d2eec7d8R14

bnf commented 7 years ago

Yes, but strange, that it won't happen on my system (BSD).

Yes, strange. "Luckily" it fails on travis as well: https://travis-ci.org/bnf/typo3-console-arguments-bug/builds/221539104

So some random Linux should suffice to reproduce.

phifa commented 7 years ago

@bnf thanks for posting the error message. Also sorry about the wrong line above:

this does not work vendor/bin/typo3cms install:setup --database-user-name="root" --database-socket=""

it actually works this way.

@helhum What does not work is what I had originally posted in slack: vendor/bin/typo3cms install:setup --database-user-name="root" --database-host-name="localhost" --database-port="3306" --database-socket="" --site-name="Site" --site-setup-type="no"

I assumed wrongly that I can trim it down to a simpler case.

helhum commented 7 years ago

"Luckily" it fails on travis as well:

@bnf cool! Thanks for your investigation. I would be thankful for your help to track this bugger down.

Can you have a look into it and find out the root cause? That would be awesome!

helhum commented 7 years ago

ok, I was able to reproduce it now. conclusion @bnf and we came up with is, that argument parsing in TYPO3 (and Flow) is broken beyond repair.

Empty values must be passed without equal sign: typo3cms install:setup --database-socket ''

Values with = must be passed with equal sign:

typo3cms install:setup --database-user-password='foo=bar'

The bug is within TYPO3, so it is not a console bug.

Fixing this would break things like typo3cms install:setup --database-user-password = value so not sure if it can be fixed within current TYPO3 releases.

This will be fixed in console with #269 anyway, so I will close this here within the next days

helhum commented 7 years ago

this will be fixed in TYPO3