Code Monkey home page Code Monkey logo

Comments (6)

mhsdesign avatar mhsdesign commented on August 17, 2024 1

Edit 4

i think im now pretty sure that we should use the timestamp of the date when the node was first created.

For example its otherwise not possible to pass relative dates into a node property:

PropertyValuesToWrite::fromArray(['myDate' => 'now'])

results in

Property "myDate" cannot be set to a value of type "string", must be of type "DateTimeImmutable"

from neos-development-collection.

ahaeslich avatar ahaeslich commented on August 17, 2024 1

At least i dindt saw the feature being used in any of the starships i came across. Maybe @ahaeslich can confirm this as well?

Uh couldn't find it in our Neos 9 project if that is what you are asking. Not sure if anyone tryed it and didn't raise that it doesn't work. In Neos 8 projects I could find the usage of defaultValue: now.

from neos-development-collection.

mhsdesign avatar mhsdesign commented on August 17, 2024

The cause of this is trusting user input to hard :D We effectively do SerializedPropertyValues::defaultFromNodeType($nodeType) which we merge onto the initialPropertyValues.
That explains why the initialPropertyValues in the commandPayload dont have them, as this modification is not kept for rebases.

We should probably read the properties and let them first be deserialised to ensure all constraints are met. For example an image object should never be written "foo" into.

EDIT 3

we seem to check the default properties here

$this->validateProperties(
$this->deserializeDefaultProperties($command->nodeTypeName),
$command->nodeTypeName
);
but discard the results 🤔 probably that a rebase is not fully deterministic but takes the current default values in consideration?

EDIT 4

so in the end it seems everything does kinda work and there are tests for it :D

but as far as i can tell is now always the current time as its deserialised from symphony not taken the event timestamp into account. Is that correct behaviour?

The serialised properties come back from the projection like this:

 string "now" (3) => Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValue object
   value => string "now" (3)
   type => string "DateTimeImmutable" (17)

and will be unserialized on the fly in PropertyConverter::deserializePropertyValue without further context.

from neos-development-collection.

mhsdesign avatar mhsdesign commented on August 17, 2024

Edit 5

well i think this was an accidental regression from #4251
previously NodeType::getDefaultValuesForProperties also returned actual date time instances but now it returns only raw properties.

That would also explain all the now obsolete instanceof DateTime checks when getDefaultValuesForProperties is used, that i could not explain til now.

from neos-development-collection.

mhsdesign avatar mhsdesign commented on August 17, 2024

We could even provide a migration, but as far as i can see was no one hopefully foolish enough to use this feature. So i would propose to only write a migration if deemed necessary. You can check if your project might be affected by just checking all DateTime properties and see if they have a relative property value.

At least i dindt saw the feature being used in any of the starships i came across. Maybe @ahaeslich can confirm this as well?

from neos-development-collection.

mhsdesign avatar mhsdesign commented on August 17, 2024

Thanks for your insight. That confirms what we thought in our weekly. No migration for this.

from neos-development-collection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.