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

FIX getRegionObj syntax error exception #84

Closed
wants to merge 2 commits into from

Conversation

IgorNadj
Copy link

@IgorNadj IgorNadj commented Apr 7, 2015

When you try to call getRegionObj with a string starting with a number, e.g. "60 NZ Minutes", the getRegionObj function will fail with a syntax exception, and not fall back to looking at the data-title attribute as designed.

Stack trace of the exception thrown:

| #0 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(281): Symfony\Component\CssSelector\Exception\SyntaxErrorException::unexpectedToken('selector', Object(Symfony\Component\CssSelector\Parser\Token))
| #1 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(140): Symfony\Component\CssSelector\Parser\Parser->parseSimpleSelector(Object(Symfony\Component\CssSelector\Parser\TokenStream))
| #2 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(116): Symfony\Component\CssSelector\Parser\Parser->parserSelectorNode(Object(Symfony\Component\CssSelector\Parser\TokenStream))
| #3 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(51): Symfony\Component\CssSelector\Parser\Parser->parseSelectorList(Object(Symfony\Component\CssSelector\Parser\TokenStream))
| #4 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php(299): Symfony\Component\CssSelector\Parser\Parser->parse('60 NZ Minutes')
| #5 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php(123): Symfony\Component\CssSelector\XPath\Translator->parseSelectors('60 NZ Minutes')
| #6 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php(65): Symfony\Component\CssSelector\XPath\Translator->cssToXPath('60 NZ Minutes', 'descendant-or-s...')
| #7 /var/www/public/vendor/behat/mink/src/Behat/Mink/Selector/CssSelector.php(35): Symfony\Component\CssSelector\CssSelector::toXPath('60 NZ Minutes')
| #8 /var/www/public/vendor/behat/mink/src/Behat/Mink/Selector/SelectorsHandler.php(111): Behat\Mink\Selector\CssSelector->translateToXPath('60 NZ Minutes')
| #9 /var/www/public/vendor/behat/mink/src/Behat/Mink/Element/Element.php(159): Behat\Mink\Selector\SelectorsHandler->selectorToXpath('css', '60 NZ Minutes')
| #10 /var/www/public/vendor/behat/mink/src/Behat/Mink/Element/Element.php(140): Behat\Mink\Element\Element->findAll('css', '60 NZ Minutes')
| #11 /var/www/public/vendor/silverstripe/behat-extension/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php(148): Behat\Mink\Element\Element->find('css', '60 NZ Minutes')

Thanks,
Igor

When you try to call getRegionObj with a string starting with a number, e.g. "60 NZ Minutes", the getRegionObj function will fail with a syntax exception, and not fall back to looking at the data-title attribute as designed.

Stack trace of the exception thrown:

|  #0 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(281): Symfony\Component\CssSelector\Exception\SyntaxErrorException::unexpectedToken('selector', Object(Symfony\Component\CssSelector\Parser\Token))
|  silverstripe#1 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(140): Symfony\Component\CssSelector\Parser\Parser->parseSimpleSelector(Object(Symfony\Component\CssSelector\Parser\TokenStream))
|  silverstripe#2 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(116): Symfony\Component\CssSelector\Parser\Parser->parserSelectorNode(Object(Symfony\Component\CssSelector\Parser\TokenStream))
|  silverstripe#3 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(51): Symfony\Component\CssSelector\Parser\Parser->parseSelectorList(Object(Symfony\Component\CssSelector\Parser\TokenStream))
|  silverstripe#4 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php(299): Symfony\Component\CssSelector\Parser\Parser->parse('60 NZ Minutes')
|  silverstripe#5 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php(123): Symfony\Component\CssSelector\XPath\Translator->parseSelectors('60 NZ Minutes')
|  silverstripe#6 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php(65): Symfony\Component\CssSelector\XPath\Translator->cssToXPath('60 NZ Minutes', 'descendant-or-s...')
|  silverstripe#7 /var/www/public/vendor/behat/mink/src/Behat/Mink/Selector/CssSelector.php(35): Symfony\Component\CssSelector\CssSelector::toXPath('60 NZ Minutes')
|  silverstripe#8 /var/www/public/vendor/behat/mink/src/Behat/Mink/Selector/SelectorsHandler.php(111): Behat\Mink\Selector\CssSelector->translateToXPath('60 NZ Minutes')
|  silverstripe#9 /var/www/public/vendor/behat/mink/src/Behat/Mink/Element/Element.php(159): Behat\Mink\Selector\SelectorsHandler->selectorToXpath('css', '60 NZ Minutes')
|  silverstripe#10 /var/www/public/vendor/behat/mink/src/Behat/Mink/Element/Element.php(140): Behat\Mink\Element\Element->findAll('css', '60 NZ Minutes')
|  silverstripe#11 /var/www/public/vendor/silverstripe/behat-extension/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php(148): Behat\Mink\Element\Element->find('css', '60 NZ Minutes')

Thanks,
Igor
@IgorNadj
Copy link
Author

IgorNadj commented Apr 7, 2015

bah looks like this may not work....

@IgorNadj
Copy link
Author

IgorNadj commented Apr 7, 2015

Ok, that seems to be a good way of fixing it. No idea why those Expcetions are uncatchable...

chillu added a commit that referenced this pull request Apr 7, 2015
The dual use of regions (CSS selector and natural language name)
causes some difficulties in processing. Since the CSS selector
is tried first, we need to ensure the underlying logic
doesn't bail on invald selector syntax.

See #84
@chillu
Copy link
Member

chillu commented Apr 7, 2015

Hey Igor, as discussed, I've fixed this by catching the exception: 0cdfb2e. Tried it on the project you were working on yesterday, and it seems to do the job consistently. I've also added some unit tests to the project, yay! If you're keen to check them out, they're in tests/

@chillu chillu closed this Apr 7, 2015
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.

2 participants