Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Add support for mysql 5.6.x. #107

Merged
merged 7 commits into from
Oct 18, 2016
Merged

Add support for mysql 5.6.x. #107

merged 7 commits into from
Oct 18, 2016

Conversation

yamilovs
Copy link
Contributor

It will fix this warning: "Warning: Using a password on the command line interface can be insecure."

It will fix this warning: "Warning: Using a password on the command line interface can be insecure."
Copy link
Collaborator

@Nyholm Nyholm left a 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']
)
);
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Owner

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

Copy link
Contributor Author

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

@yamilovs
Copy link
Contributor Author

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.
@yamilovs
Copy link
Contributor Author

Hello!
I made some changes in MySQL dump structure. Some constructor refactoring, and now removing file with connect requsites from database dump. Can u check it?

@yamilovs
Copy link
Contributor Author

yamilovs commented Oct 6, 2016

@Nyholm
Hello, Tobias. Do u have any progress on this PR? Thanks in advance.
PS. We want to use this bundle on our PHP7 project, but it doesn't work correctly on MySQL 5.6. Of course i can create a fork, but i think it is not a good idea =)

@Nyholm
Copy link
Collaborator

Nyholm commented Oct 11, 2016

Sorry for being slow on getting back on this PR. I'll test and review it this week.

PS. We want to use this bundle on our PHP7 project, but it doesn't work correctly on MySQL 5.6. Of course i can create a fork, but i think it is not a good idea =)

Please make PRs and I (or someone) will review it. We want to support PHP7.

@dizda
Copy link
Owner

dizda commented Oct 11, 2016

Hello, personally we don't have any problems with PHP7+MariaDB and this bundle.
The issue might be related directly to MySQL5.6.

Just one question, why do you have the mysql.cnf in your backup files? I don't get it.

@yamilovs
Copy link
Contributor Author

yamilovs commented Oct 11, 2016

Hello, @dizda. mysql.cnf was in 60af855 commit. I fixed this issue in 8e231ee.

$this->execute($this->getCommand());
$this->removeConfigurationFile();
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey, good.

@Nyholm
Copy link
Collaborator

Nyholm commented Oct 12, 2016

Could you rebase on master so Travis will have a change to show green?

"host" => $this->params['db_host'],
"port" => $this->params['db_port']
);
}
Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

@Nyholm Nyholm Oct 12, 2016

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'];
  }
}

Copy link
Collaborator

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)) {

Copy link
Contributor Author

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.

@yamilovs
Copy link
Contributor Author

Ok, guys, all done!

Copy link
Collaborator

@Nyholm Nyholm left a 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!

@dizda
Copy link
Owner

dizda commented Oct 17, 2016

Ok, much more clear and secure! Thanks.

Last thought, do you remove the file mysql.cnf in the case when an Exception happened?
Because that would be un-secure to leave this file on the server.

@yamilovs
Copy link
Contributor Author

yamilovs commented Oct 18, 2016

If exception occurs, it will be handle with execute() function in manager/BackupManager, that remove all backup directory with mysql.cnf file too.

@dizda
Copy link
Owner

dizda commented Oct 18, 2016

Sweet, let's do it then!

@dizda dizda merged commit 2762587 into dizda:master Oct 18, 2016
@dizda
Copy link
Owner

dizda commented Oct 18, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants