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

Incorrect field type during publishRecursive() #360

Open
mfendeksilverstripe opened this issue May 10, 2022 · 2 comments
Open

Incorrect field type during publishRecursive() #360

mfendeksilverstripe opened this issue May 10, 2022 · 2 comments

Comments

@mfendeksilverstripe
Copy link
Contributor

mfendeksilverstripe commented May 10, 2022

Incorrect field type during publishRecursive()

I noticed an unexpected variable type during the execution of RecursivePublishable::publishRecursive(), tested on 1.x-dev (3c7a1db1d4f1a93c3169cea0175363d1c6e25b6a). $owner->ParentID should be an integer but it's a string instead. Note that we I load the model directly the $model->ParentID is correct as it contains an integer. This may break some features which rely on integer fields always being integers.

Code snippet below is taken directly from RecursivePublishable::publishRecursive() with some extra debug information.

$result = $changeset->publish(true);
if (!$result) {
    return $result;
}

$model = DataObject::get($owner->ClassName)->byID($owner->ID);
var_export($owner->ParentID, true); // yields '1' - string
var_export($model->ParentID, true); // yields 1 - integer
$owner->invokeWithExtensions('onAfterPublishRecursive', $original);

return $result;
@michalkleiner
Copy link
Contributor

That looks like something possibly coming from Extensible trait? Just a guess though.

@kinglozzer
Copy link
Member

I know a while back there was an effort to fix database query return types, and it looks like that’s working as expected at least (as when you re-fetch it, it has the correct type). Could the problem be that wherever ParentID is initially being populated, the value isn’t being cast before it’s set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants