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

PHP errors #17

Open
cbrody opened this issue Jun 26, 2018 · 6 comments
Open

PHP errors #17

cbrody opened this issue Jun 26, 2018 · 6 comments

Comments

@cbrody
Copy link

cbrody commented Jun 26, 2018

Hi, I'm having some problems using this module. Visiting /patterns results in an error page beginning:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">InvalidArgumentException</em>: The URI &#039;&#039; is invalid. You must use a valid URI scheme. in <em class="placeholder">Drupal\Core\Url::fromUri()</em> (line <em class="placeholder">281</em> of <em class="placeholder">core/lib/Drupal/Core/Url.php</em>). <pre class="backtrace">Drupal\Core\Template\TwigExtension-&gt;getLink(NULL, NULL, Array) (Line: 64)

Visiting other content pages results in the following notices:

Notice: Only variables should be passed by reference in Drupal\ui_patterns_pattern_lab\Plugin\Deriver\PatternLabDeriver->templateExists() (line 147 of modules/contrib/ui_patterns_pattern_lab/src/Plugin/Deriver/PatternLabDeriver.php).

I'm using Acquia Dev Desktop with php v 7.0.14.

@backlineint
Copy link
Owner

backlineint commented Jun 26, 2018

Hi Chris,

What Pattern Lab instance are you using the module with? Is it something publicly available that I could pull down and try myself, or is it a private repo?

That said, the first error looks similar to something that I saw while testing with the Emulsify theme in #1 For emulsify the error is being caused by /components/_patterns/01-atoms/09-menu/tab/tab.twig

<li{{ attributes }}>
  {# Detect if Drupal #}
  {% if attributes %}
    {{ link(link['#title'], link['#url'], { 'class' : link_classes }) }}
  {% else %}
    <a href="{{ tab_link }}" class="tabs__link tabs__link--local-tasks{% if key == 0 %} is-active{% endif %}">{{ tab_text }}</a>
  {% endif %}
</li>

I think the patterns page passes the if attributes check, but then the pattern doesn't have preview data for the link array, causing the error. If this is the cause in your case, I think it should at least be possible to add the necessary data to the pattern definition file so that the link can at least be rendered.

For debugging purposes it is possible to ignore a pattern by adding the following to the pattern definition file in pattern lab (more info in the docs here):

ui_pattern_definition: ignore: true

So if we think we have it narrowed down to a particular pattern we can ignore it and see if the pattern library page will load without it.

As for the notice, I can dupe that one locally so I should be able to clean it up.

Thanks for submitting this issue - the more issues we can identify and fix by running this with a variety of pattern lab instances the more useful it should end up being for folks.

backlineint added a commit that referenced this issue Jun 29, 2018
Issues/17: resolving php errors and warnings
@backlineint
Copy link
Owner

I was able to duplicate the URI error with a pattern that uses:

{{ link(link['#title'], link['#url'], { 'class' : link_classes }) }}

But doesn't provide data for the link array. If I add the following data in the pattern definition file it resolves the error:

link:
  '#title': "Title"
  '#url': "http://yahoo.com"
link_classes: "myclass"

In PR #19 I also cleaned up the warnings you mentioned. That has been merged into the latest dev version of the module.

@danny-englander
Copy link

I've run into the same issue as well (using the latest dev of this module) using Emulsify when I visit the /patterns page.

@danny-englander
Copy link

Oh I see, the error might be caused by /components/_patterns/01-atoms/09-menu/tab/tab.twig for which I need to ignore I am guessing in my MY_THEME.ui_patterns.yml file?

@backlineint
Copy link
Owner

Hi @danny-englander - you're correct that this is being caused by /components/_patterns/01-atoms/09-menu/tab/tab.twig in Emulisfy. You should be able to work around it by adding one of the following in /components/_patterns/01-atoms/09-menu/tab/tab.yml

link:
  '#title': "Title"
  '#url': "http://yahoo.com"
link_classes: "myclass"

This example data should be enough for UI Patterns to be able to render a preview of the pattern.

Alternatively, you could add

ui_pattern_definition: 
  ignore: true

Which will cause UI Patterns Pattern lab to ignore the pattern.

Testing this module with Emulsify seems like a common starting point for folks, so I'm going to try to do a little more to improve this. More documentation might help, and I also wonder if I could submit a PR against Emulsify that would maintain Emulsify functionality but prevent this hiccup.

There is also a UI Patterns PR around handling missing patterns more gracefully. I'm going to take a closer look at that issue - I wonder if that or a similar fix could help improve this situation as well.

@danny-englander
Copy link

@backlineint yes, I see now, either of those methods work and I can now see my patterns. Thank you!

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

No branches or pull requests

3 participants