Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-29279: Script converting ezdate & ezdatetime timestamps to UTC #2499

Merged
merged 6 commits into from
Mar 11, 2019

Conversation

mateuszbieniek
Copy link
Contributor

@mateuszbieniek mateuszbieniek commented Dec 11, 2018

Question Answer
JIRA issue EZP-29279
Bug/Improvement yes
New feature no
Target version 6.13

This PR is followup for ezsystems/ezpublish-legacy#1401 and implements migration script for the legacy to convert stored ezdate & ezdatetime timestamps into UTC.

@mateuszbieniek mateuszbieniek changed the title Added script converting ezdate timestamps to UTC EZP-29279: Script converting ezdate & ezdatetime timestamps to UTC Dec 11, 2018
@ezsystems ezsystems deleted a comment from ezrobot Dec 17, 2018
{
$fields = [];

if ($this->mode == 'date' || $this->mode == 'all') {
Copy link
Member

Choose a reason for hiding this comment

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

...and use these constants here afterward 😄

->addArgument(
'timezone',
InputArgument::OPTIONAL,
'Original timestamp TimeZone',
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick:
Original timestamp TimeZone -> Original timestamp's TimeZone

$progressBar->start();

for ($offset = 0; $offset < $count; $offset += $iterationCount) {
$processBuilder = new ProcessBuilder(
Copy link
Contributor

Choose a reason for hiding this comment

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

*/
protected function processTimestamps($offset, $limit)
{
$ezDateObjectAttributes = $this->getEzDateObjectAttributes($offset, $limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

terminology: Fields is the word for Attributes in eZ Platform

Also you can drop the use of "Ez" in methods, looks strange, and can be omitted if we are specific as this is anyway inside eZ Platform.

example $dateFields = $this->getDateFields($offset, $limit);

And then adapt the rest of the method and other places for the simpler naming ;)


$progressBar->finish();
$output->writeln(
[
Copy link
Contributor

Choose a reason for hiding this comment

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

This goes for several places here, but you can safely place the array start on line of the call when it's the only argument.

Double check with php-cs-fixer but at least before I don't think it minds.

so:

            $output->writeln([
                '',// Empty newline
                sprintf('Done: %d', $this->done),
            ]);

/**
* @return int
*/
protected function countEzDateObjectAttributes()
Copy link
Contributor

Choose a reason for hiding this comment

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

    /**
     * Counts affected date fields using captured "mode", "from" and "to" command options.
     *
     * @return int
     */
    private function countDateFields()

'only-datetime',
null,
InputOption::VALUE_NONE,
'Only ezdatetime fields will be converted'
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this should be removed as it's not used and is covered by mode

The command <info>%command.name%</info> updates field
data_int in configured Legacy Storage database for a given field type.

Fields will be checked and updated only if not already in UTC timezone.
Copy link
Contributor

Choose a reason for hiding this comment

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

will it detect this by itself? :)

Also, as a second sentence here maybe say something like:
This is to be used either when migrating from eZ Publish to eZ Platform (when using platform backend instead of legacy), or when upgrading legacy to v2019.03 which has been adapted to use UTC.

}

/**
* @return string
Copy link
Contributor

Choose a reason for hiding this comment

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

string[]

const DEFAULT_ITERATION_COUNT = 100;
const EZDATE_ONLY_MODE = 'date';
const EZDATETIME_ONLY_MODE = 'datetime';
const ALL_MODE = 'all';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can do the following:

const MODES = [
    'date' => ['ezdate'],
    'datetime' => ['ezdatetime'],
    'all' => ['ezdate', 'ezdatetime'],
];

Simplifies validation of option, and simplifies mapping in getField[TypeIdentifier]s().
Can even use this as source for help text on the option to solve all open comments ;)

@ezsystems ezsystems deleted a comment from ezrobot Dec 21, 2018
@ezsystems ezsystems deleted a comment from ezrobot Dec 21, 2018
Copy link
Contributor

@andrerom andrerom left a comment

Choose a reason for hiding this comment

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

Big 👍

Tested last version?


This is to be used either when migrating from eZ Publish to eZ Platform
(when using platform backend instead of legacy), or when upgrading legacy
to v2019.03 which has been adapted to use UTC.
Copy link
Contributor

@andrerom andrerom Dec 21, 2018

Choose a reason for hiding this comment

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

Note on MERGE: Depending on when this is merged and when patch releases comes out, we can change this to v2018.12 / 2019.01 / 2019.02 or whatever :)

@mateuszbieniek
Copy link
Contributor Author

mateuszbieniek commented Dec 21, 2018

Tested last version?

Smooth as Butter 😄

@andrerom andrerom merged commit f3a71b8 into ezsystems:6.13 Mar 11, 2019
@mateuszbieniek mateuszbieniek deleted the EZP-29279_migration_script branch November 22, 2021 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants