wpengine / atlas-content-modeler

Content modeling plugin for WordPress
https://developers.wpengine.com/docs/atlas-content-modeler
GNU General Public License v2.0
165 stars 13 forks source link

Rest routes not registered when plural name is equal #637

Closed imjlk closed 6 months ago

imjlk commented 1 year ago

To reproduce

  1. Register New Model which has plural name as example, model ID as one (A)
  2. Register New Model which has plural name as example, model ID as two (B)
  3. Check rest route wp-json/wp/v2/
  4. B Model has no rest endpoint

Expected behavior

It seems to be registered with model's plural name, it's also need to validate when register new model. Maybe model ID based would be better. (user inputted value in Plural name is saved as label)

Version information

Plugin version: 0.23.0 WordPress version: 6.x

Additional context

I think it happens frequently to users who use non-English characters. If register Plural name as {non-english}s and register another model with {another-non-english}s, it's registering rest routes with s (because plural name sanitized?)

Perhaps if the rest route is not registered, it will also affect the graphql query, right?

mindctrl commented 1 year ago

@imjlk can you provide an export of your models from Content Modeler > Tools > Export Models? I'm unable to create two models with the same plural name, as ACM prevents that from happening. It could be related to sanitization like you said. If you can't provide the exported .json file, can you provide the exact text you used for the plural name?

imjlk commented 1 year ago

@mindctrl Sorry, I also try it but fail to reproduce it. Previous site is already deleted. Anyway it seems to be prehibited to create a singular and plural with non-english characters(in my case, Korean). maybe it's affected by updated wpgraphql plugin? below block is an error log after registering non-english Model. (hangul is Model ID)

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught GraphQL\\Error\\UserError: The hangul post_type isn't configured properly to show in GraphQL. It needs a "graphql_single_name" and a "graphql_plural_name" in /var/www/vhosts/{MY_SITE}/wp-content/plugins/wp-graphql/src/WPGraphQL.php:623\nStack trace:\n#0 /var/www/vhosts/{MY_SITE}/wp-content/plugins/wp-graphql/src/Type/ObjectType/RootQuery.php(662): WPGraphQL::get_allowed_post_types()\n#1 /var/www/vhosts/{MY_SITE}/wp-content/plugins/wp-graphql/src/Registry/TypeRegistry.php(298): WPGraphQL\\Type\\ObjectType\\RootQuery::register_post_object_fields()\n#2 /var/www/vhosts/{MY_SITE}/wp-includes/class-wp-hook.php(308): WPGraphQL\\Registry\\TypeRegistry->init_type_registry()\n#3 /var/www/vhosts/{MY_SITE}/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()\n#4 /var/www/vhosts/{MY_SITE}/wp-includes/plugin.php(517): WP_Hook->do_action()\n#5 /var/www/vhosts/{MY_SITE}...', referer: https://stage.{MY_SITE}/wp-admin/admin.php?page=graphiql-ide

mindctrl commented 6 months ago

Closing since we can't reproduce. If this is somehow reproducible via the ACM UI, please feel free to reopen.