[2.0.0-alpha2] StreamWrapper: check URL scheme & prop type availiblity

Created on 10 May 2024, about 2 months ago

Problem/Motivation

Until now, we are the only ones using the JSON Schema reference system with SDC prop definitions. But core may introduce a similar mechanism, inspired from ours: ✨ [PP-1] Allow schema references in Single Directory Component prop schemas Postponed

Proposed resolution

So, we need to test if "ui-patterns" is the scheme of the URL before doing any processing.

Also, let's check if the prop type exists.

API changes

This is not a breaking change.

πŸ“Œ Task
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pdureau
  • Assigned to oldeb
  • πŸ‡§πŸ‡ͺBelgium oldeb Brussels
  • Status changed to Closed: works as designed about 2 months ago
  • πŸ‡§πŸ‡ͺBelgium oldeb Brussels

    Check for correct scheme is already done in the ComponentPluginManager::annotateProps/a> method.

    PropType availiblity is done by the PluginManagerBase::createInstance method.

  • πŸ‡«πŸ‡·France pdureau Paris

    Check for correct scheme is already done in the ComponentPluginManager::annotateProps method.

    It is not the same check .Sure, it is technically the same, but not at the same moment for the same purpose.

    Anyway, the check is already done, indeed, by the stream_wrapper service manager, because of the tags from the service definition;

      ui_patterns.schema_stream_wrapper:
        class: Drupal\ui_patterns\SchemaManager\StreamWrapper
        arguments:
          - "@plugin.manager.ui_patterns_prop_type"
        tags:
          - { name: stream_wrapper, scheme: ui-patterns }  
    

    So, instead of doing the check again, maybe a little ocmment to explain why it is not necessary

    PropType availiblity is done by the PluginManagerBase::createInstance method.

    What will happen if we do ui-patterns://this_is_not_a_prop_type?
    Because we have $plugin->getSchema() later in the stream wrapper?

    https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/SchemaMa...

  • πŸ‡§πŸ‡ͺBelgium oldeb Brussels

    When an incorrect scheme is passed : an error is thrown. This should never happen since it's checked by the ComponentPluginManager before calling file_get_contents and, like you said, the streamwrapper is always called with the correct scheme because of the tags in the service definition.

    When an incorrect plugin is passed, the file_get_contents return a string with an empty array : "[]"
    So there is no error, the schema is just empty.

Production build 0.69.0 2024