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

Syntax error in URL encoding regex in 3.5.10 #1560

Closed
jonnykates opened this issue Jan 9, 2025 · 5 comments
Closed

Syntax error in URL encoding regex in 3.5.10 #1560

jonnykates opened this issue Jan 9, 2025 · 5 comments
Labels

Comments

@jonnykates
Copy link

Describe the bug

Upgrading from 3.5.9 => 3.5.10 introduces an parsing error exception at UrlHelper.php:290:

ParseError: syntax error, unexpected ':', expecting ')' in /var/www/html/vendor/nystudio107/craft-seomatic/src/helpers/UrlHelper.php:290
Stack trace:
#0 /var/www/html/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/var/www/html/v...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('nystudio107\\seo...')
#2 /var/www/html/vendor/nystudio107/craft-seomatic/src/services/FrontendTemplates.php(96): spl_autoload_call('nystudio107\\seo...')
#3 /var/www/html/vendor/nystudio107/craft-seomatic/src/Seomatic.php(888): nystudio107\seomatic\services\FrontendTemplates->loadFrontendTemplateContainers()
#4 /var/www/html/vendor/nystudio107/craft-seomatic/src/Seomatic.php(481): nystudio107\seomatic\Seomatic->installCpEventListeners()
#5 /var/www/html/vendor/nystudio107/craft-seomatic/src/Seomatic.php(291): nystudio107\seomatic\Seomatic->installEventListeners()
#6 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): nystudio107\seomatic\Seomatic->init()
#7 /var/www/html/vendor/yiisoft/yii2/base/Module.php(161): yii\base\BaseObject->__construct(Array)
#8 /var/www/html/vendor/craftcms/cms/src/base/Plugin.php(115): yii\base\Module->__construct('seomatic', Object(craft\web\Application), Array)
#9 /var/www/html/vendor/nystudio107/craft-seomatic/src/services/ServicesTrait.php(91): craft\base\Plugin->__construct('seomatic', Object(craft\web\Application), Array)
#10 [internal function]: nystudio107\seomatic\Seomatic->__construct('seomatic', Object(craft\web\Application), Array)
#11 /var/www/html/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#12 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('nystudio107\\seo...', Array, Array)
#13 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('nystudio107\\seo...', Array, Array)
#14 /var/www/html/vendor/craftcms/cms/src/Craft.php(66): yii\BaseYii::createObject(Array, Array)
#15 /var/www/html/vendor/craftcms/cms/src/services/Plugins.php(942): Craft::createObject(Array, Array)
#16 /var/www/html/vendor/craftcms/cms/src/services/Plugins.php(232): craft\services\Plugins->createPlugin('seomatic', Array)
#17 /var/www/html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1520): craft\services\Plugins->loadPlugins()
#18 /var/www/html/vendor/craftcms/cms/src/web/Application.php(101): craft\web\Application->_postInit()
#19 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\web\Application->init()
#20 /var/www/html/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#21 [internal function]: yii\base\Application->__construct(Array)
#22 /var/www/html/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#23 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\\web\\Appli...', Array, Array)
#24 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\web\\Appli...', Array, Array)
#25 /var/www/html/vendor/craftcms/cms/src/Craft.php(66): yii\BaseYii::createObject(Array, Array)
#26 /var/www/html/vendor/craftcms/cms/bootstrap/bootstrap.php(236): Craft::createObject(Array)
#27 /var/www/html/vendor/craftcms/cms/bootstrap/web.php(51): require('/var/www/html/v...')
#28 /var/www/html/web/index.php(25): require('/var/www/html/v...')
#29 {main}

Versions

  • Plugin version: 3.9.10
  • Craft version: 3.9.14
  • PHP version: 7.4.33 (this could be the culprit perhaps)
@jonnykates jonnykates added the bug label Jan 9, 2025
@espensgr
Copy link

espensgr commented Jan 9, 2025

Was going to report the same thing.
it seems to be the preg_split in the craft-seomatic/src/helpers/UrlHelper.php file.

$parts = preg_split('/([:\/?#\[\]@!$&\'()*+,;=%])/', $url, flags: PREG_SPLIT_DELIM_CAPTURE);
Just remove the flags: i guess?

@oranges13
Copy link

Parameter identification like that is only valid in PHP 8+, so if you're on PHP 7 that's why.

Looks like version 3.9.10 is not compatible with PHP 7 given this change.

oranges13 added a commit to oranges13/craft-seomatic that referenced this issue Jan 9, 2025
Version 3.9.10 contained php8 only code, so this will fix it for everyone still using PHP 7 - fixes nystudio107#1560
khalwat added a commit that referenced this issue Jan 9, 2025
@oranges13
Copy link

@khalwat I fixed the issue which was causing the PHPstan failure if you want to remerge

@khalwat
Copy link
Collaborator

khalwat commented Jan 9, 2025

@oranges13 Not seeing that change here, but I fixed it myself via: af2dac9

Released version 3.5.11 which fixes this issue.

Thanks for the PR @oranges13

@khalwat khalwat closed this as completed Jan 9, 2025
@khalwat
Copy link
Collaborator

khalwat commented Jan 9, 2025

Okay, I see what you mean @oranges13 -- the flags parameter in the initial PR should be -1 and not null.

Fixed and released in SEOmatic version 5.5.12 https://github.com/nystudio107/craft-seomatic/releases/tag/3.5.12

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

No branches or pull requests

4 participants