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

[#5404] Undef Kernel.open before creating open scope #6228

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

garethrees
Copy link
Member

All Ruby objects inherit from Object, which includes the Kernel module,
which in turn, has an open method. Redefining .open was creating lots
of WARN level messages in the logs:

W, [2019-10-10T14:17:40.179390 #30917]  WARN -- : Creating scope
:open. Overwriting existing method PublicBodyChangeRequest.open

Since we're not using Kernel.open, we can explicitly undefine it prior
to defining our own .open in the form of a scope.

Fixes #5405.

@garethrees
Copy link
Member Author

Blocked by #5222/#5223, will be mergeable after #6052.

@mysociety-pusher mysociety-pusher force-pushed the 5405-public-body-change-request-open-scope branch from 38b480a to 9600dcf Compare May 19, 2021 12:01
All Ruby objects inherit from Object, which includes the Kernel module,
which in turn, has an open method. Redefining `.open` was creating lots
of WARN level messages in the logs:

    W, [2019-10-10T14:17:40.179390 #30917]  WARN -- : Creating scope
    :open. Overwriting existing method PublicBodyChangeRequest.open

Since we're not using `Kernel.open`, we can explicitly undefine it prior
to defining our own `.open` in the form of a `scope`.

Fixes #5405.
@mysociety-pusher mysociety-pusher force-pushed the 5405-public-body-change-request-open-scope branch from 9600dcf to a175a9b Compare May 19, 2021 12:02
Copy link
Member

@gbp gbp left a comment

Choose a reason for hiding this comment

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

Nice, I always wondered why these were appearing.

I don't really understand why we need to call undef_method on the singleton_class instead of calling as a class method but this certainly works.

@gbp gbp assigned garethrees and unassigned gbp May 28, 2021
@garethrees
Copy link
Member Author

I don't really understand why we need to call undef_method on the singleton_class instead of calling as a class method but this certainly works.

Ah, I left some earlier investigation in #5405 (comment). I don't fully understand it either tbh. I assume it's something to do with being explicit about removing the open method of PublicBodyChangeRequest rather than the open of Kernel.

@gbp gbp merged commit eff27a3 into develop Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overridden scope PublicBodyChangeRequest.open
2 participants