Skip to content

Conversation

@jasonbahl
Copy link
Collaborator

@jasonbahl jasonbahl commented Jan 31, 2024

What does this implement/fix? Explain your changes.

Sets the AppContext class to "allow dynamic properties"

Does this close any currently open issues?

closes #2981

@jasonbahl jasonbahl self-assigned this Jan 31, 2024
@coveralls
Copy link

coveralls commented Jan 31, 2024

Coverage Status

coverage: 84.756%. remained the same
when pulling a3696ff on jasonbahl:fix/2981-php-deprecation-error
into 49e2d5a on wp-graphql:develop.

@jasonbahl jasonbahl marked this pull request as draft February 1, 2024 18:03
@gregrickaby
Copy link

👋🏻 Hey Jason...

This can be squelched by adding the following to the list of properties in AppContext.php. Tested locally with PHP 8.3 and no more deprecation warnings 😄

/**
 * Stores the class to use for the connection query.
 *
 * @var WP_Query|null
 */
public $connection_query_class = null;

@justlevine
Copy link
Collaborator

justlevine commented Feb 2, 2024

👋🏻 Hey Jason...

This can be squelched by adding the following to the list of properties in AppContext.php. Tested locally with PHP 8.3 and no more deprecation warnings 😄

/**
 * Stores the class to use for the connection query.
 *
 * @var WP_Query|null
 */
public $connection_query_class = null;

This might be a "why not both?" situation, since while $connection_query_class is the problem in the core plugin, the current pattern encourages general overloading the AbstractConnectionResolver class with custom properties, so many plugins are triggering similar errors on for other undeclared variables. 🤔
The type will probably need to be broader than ?\WP_Query (while still hopefully avoiding a mixed).

Similarly (more of a note to self), while squelching the deprecation warning is our immediate concern, we do need to think about what the ideal DX should be for overloading the ConnectionResolver in order to reuse an existing one instead of needing to define an entire child class (or even if overloading is the way to do it vs lets say a callable in the $config[] ).

related: #2821

@LondonCityMedia
Copy link

I think this is fixed, now. Thanks!

@jasonbahl
Copy link
Collaborator Author

This might be a "why not both?" situation

@justlevine @gregrickaby ya, I agree with this (and everything @justlevine said after).

We definitely need to shore up some patterns for hooking into AppContext. For now, I think we can do both, and then circle back in the future on what ideal patterns should be if/when AppContext needs to be modified during resolution, etc

- add // @phpcs:ignore to the #[\AllowDynamicProperties] line
@jasonbahl jasonbahl marked this pull request as ready for review February 2, 2024 22:47
- Add php8.0 + wp6.3 to the include list
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit a3696ff and detected 0 issues on this pull request.

View more on Code Climate.

@jasonbahl jasonbahl merged commit 6698982 into wp-graphql:develop Feb 2, 2024
This was referenced Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP deprecated

5 participants