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

Draft: Add processing directives without namespace and with empty namespace #6262

Conversation

cbravobernal
Copy link

POC after this conversation:
#5795 (comment)

cc: @felixarntz

Trac ticket:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@@ -491,7 +491,7 @@ private function data_wp_interactive_processor( WP_Interactivity_API_Directives_
* independently of whether the previous `data-wp-interactive` definition
* contained a valid namespace.
*/
$new_namespace = null;
$new_namespace = 'WP';
Copy link
Member

Choose a reason for hiding this comment

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

Can you clarify how this change fixes the problem? Difficult to understand from looking at the surrounding code, and it seems such a simple change. To be fair, I'm not very familiar with the underlying code :)

Copy link
Member

Choose a reason for hiding this comment

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

How does this change impact accessing the context on the client?

Copy link
Author

Choose a reason for hiding this comment

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

It should change the impact, rather than anyone can access namespaces not defined with this default one.

Copy link
Author

Choose a reason for hiding this comment

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

Can you clarify how this change fixes the problem? Difficult to understand from looking at the surrounding code, and it seems such a simple change. To be fair, I'm not very familiar with the underlying code :)

The directives were not being processed cause they expected non empty string as a namespace. While reading the data-wp-interactive attribute, we are returning a boolean in case is not defined data-wp-interactive or an empty string.

Adding a default one would fix it (my tests are running OK in local, not here 🤔 ), but it is not a good solution. That's why I wanted to check with @DAreRodz too 😅

@luisherranz
Copy link
Member

Hey @c4rl0sbr4v0, thanks for catching this and working on a fix 🙂

This bug is definitely my fault, but I don't think using WP is a proper solution and it would cause a divergence between how the server and client work, which will lead to other bugs.

The server directive processing should work without a default namespace. If this is failing because the functions/helpers are not expecting namespace to be null, we should fix that.

@cbravobernal
Copy link
Author

Let's close this one and work on a proper solution.

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