-
Notifications
You must be signed in to change notification settings - Fork 56
Conversation
It will fix this warning: "Warning: Using a password on the command line interface can be insecure."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change. Though, I've not tested it yet. 👍
"host" => $params['db_host'], | ||
"port" => $params['db_port'] | ||
) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be rewritten to avoid array merge. It makes the code easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can rewrite it like
$cnfParams += array('key' => 'value')
but this feature was provided in php 5.4. I should change composer.json to requre new version of php (old configuration is "php": ">=5.3.2") it may cause some problems with BC. If it is not a problem, i'll do this.
PS. i doesn't want to add some params like this:
$cnfParams[key] = "value"; $cnfParams[another_key] = "another_value" // etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, 5.3's support has just been dropped via #109
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok i rewrited it with array addition
And i found one issue, that mysql.cnf configuration file was dumped with all requsites to backup file. I think it is not good. I'll try to fix this soon. |
…authorization, will be removed from backup dump.
Hello! |
@Nyholm |
Sorry for being slow on getting back on this PR. I'll test and review it this week.
Please make PRs and I (or someone) will review it. We want to support PHP7. |
Hello, personally we don't have any problems with PHP7+MariaDB and this bundle. Just one question, why do you have the |
$this->execute($this->getCommand()); | ||
$this->removeConfigurationFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if an exception is thrown somewhere. I do not what to risk that a configuration file is lying around. Let's use a try/catch and make sure 'removeConfigurationFile' always is running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an exeception will be thrown, it will be catched in manager/BackupManager->execute() function
and all backup
folder will be cleared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey, good.
Could you rebase on master so Travis will have a change to show green? |
"host" => $this->params['db_host'], | ||
"port" => $this->params['db_port'] | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about rewriting it to this?
if ($this->params['db_user']) {
if ($this->params['db_password']) {
$cnfParams = array(
"password" => $this->params['db_password'],
"host" => $this->params['db_host'],
"port" => $this->params['db_port']
);
}
$cnfFile = "[client]\n";
$cnfParams['user'] = $this->params['db_user'];
}
This would be easier to read, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is the logic here correct? Should we add host and port only iff we have a password?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic was already there before i started working on it =)
And your version of rewriting is more dificult to read for me =) I think its something minor, but if you insist, I'll rewrite it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about this variant?
$cnfFile = "[client]\n";
$cnfParams = array();
$configurationMapping = array(
'user' => 'db_user',
'password' => 'db_password',
'host' => 'db_host',
'port' => 'db_port',
);
foreach ($configurationMapping as $key => $param) {
if ($this->params[$param]) {
$cnfParams[$key] = $this->params[$param];
}
}
if ($cnfParams) {
foreach ($cnfParams as $key => $value) {
$cnfFile .= "$key = \"$value\"\n";
}
$this->filesystem->dumpFile($this->getConfigurationFilePath(), $cnfFile, 0600);
$this->auth = sprintf("--defaults-extra-file=\"%s\"", $this->getConfigurationFilePath());
}
It's more correct logic, but i think it's also hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah =) okey.
No, I do not insist. I'll want your opinion. I dislike array_merge and the plus operator in this case because it could be avoided.
How about this:
if ($this->params['db_user']) {
$cnfFile = "[client]\n";
$cnfParams['user'] = $this->params['db_user'];
if ($this->params['db_password']) {
$cnfParams['password'] = $this->params['db_password'];
$cnfParams['host'] = $this->params['db_host'];
$cnfParams['uporter'] = $this->params['db_port'];
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Yours is way better. But for clarity I would like if (!empty($cnfParams)) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, ok) I'll do it like this.
Ok, guys, all done! |
…le that some params may be missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dizda Merge at will!
Ok, much more clear and secure! Thanks. Last thought, do you remove the file |
If exception occurs, it will be handle with |
Sweet, let's do it then! |
Thanks, https://github.com/dizda/CloudBackupBundle/releases/tag/3.4.0 released. |
It will fix this warning: "Warning: Using a password on the command line interface can be insecure."