When I run my Doctrine Migration I get the following error:
Migration 20141217162533 failed during Execution. Error Runtime Notice: Only variables should be passed by reference
[Symfony\Component\Debug\Exception\ContextErrorException] Runtime Notice: Only variables should be passed by reference
on the $this->validateUsername
line. When I comment this out it works fine.
This seems like a very strange runtime error to experience and I cannot see why I am getting this.
public function up(Schema $schema)
{
foreach ($this->old_users as $old_user) {
if ($this->validateUsername($old_user['email']) === false or $this->checkDNSRecord($old_user['email']) === false) {
$this->addSql("INSERT INTO User (email, joined_on, unsubscribed) VALUES ('" . $old_user['email'] . "', '" . $old_user['joined_on'] . "', 0)");
}
}
}
/**
* Validate the username/email address based on the structure (e.g. username@domain.com)
*
* @param $email
*
* @return bool
*/
public function validateUsername($email)
{
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
// email is NOT valid
return false;
} else {
// email is valid
return true;
}
}
/**
* Validate the MX line of the DNS record for the host of the email address (e.g. @aol.co.uk)
*
* @param $email
*
* @return bool
*/
public function checkDNSRecord($email)
{
if (checkdnsrr(array_pop(explode('@', $email)), 'MX')) {
return true;
} else {
return false;
}
}