<commit_before><?php

namespace Oro\Bundle\UserBundle\Migrations\Schema\v1_24;

use Psr\Log\LoggerInterface;

use Doctrine\DBAL\Types\Type;

use Oro\Bundle\MigrationBundle\Migration\ArrayLogger;
use Oro\Bundle\MigrationBundle\Migration\ParametrizedMigrationQuery;

class FillPasswordExpiresAtField extends ParametrizedMigrationQuery
{
    /**
     * @var string
     */
    protected $tableName;

    /**
     * @param string $tableName
     */
    public function __construct($tableName)
    {
        $this->tableName = $tableName;
    }

    /**
     * {@inheritDoc}
     */
    public function getDescription()
    {
        $logger = new ArrayLogger();
        $this->doExecute($logger, true);

        return $logger->getMessages();
    }

    /**
     * {@inheritDoc}
     */
    public function execute(LoggerInterface $logger)
    {
        $this->doExecute($logger);
    }

    /**
     * @param LoggerInterface $logger
     * @param bool $dryRun
     * @throws \Doctrine\DBAL\DBALException
     */
    protected function doExecute(LoggerInterface $logger, $dryRun = false)
    {
        $qb = $this->connection
            ->createQueryBuilder()
            ->update($this->tableName)
            ->set('password_expires_at', ':expiryDate')
            ->setParameter('expiryDate', new \DateTime('now', new \DateTimeZone('UTC')), Type::DATETIME);
        ;

        $this->logQuery($logger, $qb->getSql());
        if (!$dryRun) {
            $qb->execute();
        }
    }
}
<commit_msg>OEE-1063: Periodic password change - adjust initial password expiry period<commit_after><?php

namespace Oro\Bundle\UserBundle\Migrations\Schema\v1_24;

use Psr\Log\LoggerInterface;

use Doctrine\DBAL\Types\Type;

use Oro\Bundle\MigrationBundle\Migration\ArrayLogger;
use Oro\Bundle\MigrationBundle\Migration\ParametrizedMigrationQuery;

class FillPasswordExpiresAtField extends ParametrizedMigrationQuery
{
    /**
     * @var string
     */
    protected $tableName;

    /**
     * @param string $tableName
     */
    public function __construct($tableName)
    {
        $this->tableName = $tableName;
    }

    /**
     * {@inheritDoc}
     */
    public function getDescription()
    {
        $logger = new ArrayLogger();
        $this->doExecute($logger, true);

        return $logger->getMessages();
    }

    /**
     * {@inheritDoc}
     */
    public function execute(LoggerInterface $logger)
    {
        $this->doExecute($logger);
    }

    /**
     * @param LoggerInterface $logger
     * @param bool $dryRun
     * @throws \Doctrine\DBAL\DBALException
     */
    protected function doExecute(LoggerInterface $logger, $dryRun = false)
    {
        $qb = $this->connection
            ->createQueryBuilder()
            ->update($this->tableName)
            ->set('password_expires_at', ':expiryDate')
            ->setParameter('expiryDate', new \DateTime('+30 day', new \DateTimeZone('UTC')), Type::DATETIME);
        ;

        $this->logQuery($logger, $qb->getSql());
        if (!$dryRun) {
            $qb->execute();
        }
    }
}

{'fraction_non_alphanumeric': 0.13768352365415987, 'fraction_numerical': 0.003915171288743882, 'mean_word_length': 2.4488188976377954, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4673323', 'n_tokens_mistral': 939, 'n_tokens_neox': 922, 'n_words': 159}