Skip to content
Advertisement

Symfony 3.4 – cannot load field value

I’m using Symfony 3.4.47 w/ MySQL 8 and getting a field value wasn’t a big thing until today.

I’ve created a migration file to add a new field to an existing entity:

$this->addSql('ALTER TABLE plano ADD cliente_apelido VARCHAR(40) NOT NULL');

And I’ve added the field ‘cliente_apelido’, getter and setter to the ‘Plano.php’ model:

/**
 * @var string
 *
 * @ORMColumn(name="cliente_apelido", type="string", length=40, nullable=false)
 */
private $clienteapelido;

/**
 * @param string $clienteapelido
 */
public function setClienteapelido(string $clienteapelido): void
{
    $this->clienteapelido = $clienteapelido;
}

/**
 * Get clienteapelido.
 *
 * @return string
 */
public function getClienteapelido()
{
    return $this->clienteapelido;
}

It turns that, when I’m trying to use the getClienteapelido() getter, it returns an empty string and I don’t have a clue of what’s going wrong:

$plano = $this->doctrine->getRepository('PlanoBundle:Plano')->find(99); // 99 is just an example of a valid row of 'plano' entity

if ($plano) {
    $this->logger->critical("Found 'plano' id=" . $plano->getCodplano());
    // This prints to the log file:
    // [2021-09-13 09:36:31] app.CRITICAL: Found 'plano' id=99

    $this->logger->critical("apelido=[" . $plano->getClienteapelido() . "]");
    // This prints to the log file:
    // [2021-09-13 09:36:31] app.CRITICAL: apelido=[]
}

Even worse: The code above is working in DEV environment but does not work in production. I know it sounds obviously like an environment issue, but i don’t know where to look for.

Any ideas?

**EDIT: ** The problem was that I had some files/folders with wrong permissions on Symfony’s cache folder, which made my deploy unable to clean it and that bizarre behavior was the consequence.

Advertisement

Answer

The problem was that I had some files/folders with wrong permissions on Symfony’s cache folder, wich made my deploy unable to clean it and that bizarre behavior was the consequence.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement