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

Do not dynamically assign modProcessorResponse to modConnectorResponse #16564

Merged
merged 1 commit into from
May 29, 2024

Conversation

opengeek
Copy link
Member

What does it do?

Assign the processor result to a local variable rather than dynamically creating a "response" property on the modConnectorResponse class.

Why is it needed?

In PHP 8.2, dynamically assigning a property to a class is deprecated. When calling runProcessor, the result is only used within the outputContent() method, so there is no need to assign the result from runProcessor to a property of modConnectorResponse dynamically or add a property to modConnectorResponse to hold the result.

How to test

Confirm no deprecated warnings are logged when running a processor in a connector.

Related issue(s)/PR(s)

Port of #16563 to 3.0.x/3.x

Assign the processor result to a local variable rather than dynamically creating a "response" property on the modConnectorResponse class.
@opengeek opengeek added the bug The issue in the code or project, which should be addressed. label Apr 24, 2024
@opengeek opengeek added this to the v3.0.6 milestone Apr 24, 2024
@opengeek opengeek requested a review from Mark-H as a code owner April 24, 2024 15:49
@Mark-H
Copy link
Collaborator

Mark-H commented Apr 24, 2024

I'm kinda worried this introduces a breaking change where people may have relied on $response->response containing the output of the processor, although seeing just the file out of context I'm not 100% sure if that applies here or if that was in one of the other response classes (modProcessorResponse?)

For BCs sake, could we instead define the response as a public property?

It is definitely a good thing to get rid of dynamic variables.

@opengeek
Copy link
Member Author

opengeek commented Apr 24, 2024

I'm kinda worried this introduces a breaking change where people may have relied on $response->response containing the output of the processor, although seeing just the file out of context I'm not 100% sure if that applies here or if that was in one of the other response classes (modProcessorResponse?)

For BCs sake, could we instead define the response as a public property?

It is definitely a good thing to get rid of dynamic variables.

There's nowhere it could be used as far as I can tell. If I'm wrong, I'll be glad to change it, but I don't see any valid way it could be used. The result of modProcessorResponse->getResponse is assigned to the body, which is a public property, in this same block of code if the processor produces an actual modProcessorResponse object.

@opengeek opengeek merged commit 0b4601f into modxcms:3.0.x May 29, 2024
5 of 6 checks passed
@opengeek opengeek deleted the modconnectorresponse-response branch May 29, 2024 14:41
opengeek added a commit that referenced this pull request May 29, 2024
#16564)

### What does it do?
Assign the processor result to a local variable rather than dynamically
creating a "response" property on the modConnectorResponse class.

### Why is it needed?
In PHP 8.2, dynamically assigning a property to a class is deprecated.
When calling runProcessor, the result is only used within the
`outputContent()` method, so there is no need to assign the result from
runProcessor to a property of modConnectorResponse dynamically or add a
property to modConnectorResponse to hold the result.

### How to test
Confirm no deprecated warnings are logged when running a processor in a
connector.

### Related issue(s)/PR(s)
Port of #16563 to 3.0.x/3.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants