Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

PHP 7.3 incompatibility #2320

Closed
rrelmy opened this issue Jan 4, 2019 · 4 comments
Closed

PHP 7.3 incompatibility #2320

rrelmy opened this issue Jan 4, 2019 · 4 comments

Comments

@rrelmy
Copy link

rrelmy commented Jan 4, 2019

Describe the bug
Statamic is not compatible with php 7.3 because of some regex in the Stringy dependency.
Details about the breaking changes

Was discussed before in the discord channel

To Reproduce
Steps to reproduce the behavior:

  1. Open a frontend template with a PHP 7.3 installation

Expected behavior
Everything works 🦄🌈

Screenshots
If applicable, add screenshots to help explain your problem.

Environment details (please complete the following information):

  • Statamic Version: 2.11.3
  • Web Server: nginx (valet)
  • PHP Version: 7.3 😱

Additional context

Full log message
1/1 ErrorException in Stringy.php line 819:
preg_replace(): Compilation failed: invalid range in character class at offset 12

in Stringy.php line 819
at HandleExceptions->handleError('2', 'preg_replace(): Compilation failed: invalid range in character class at offset 12', '/Users/remy/projects/web/fairtiq/statamic/vendor/danielstjules/stringy/src/Stringy.php', '819', array('replacement' => '-', 'stringy' => object(Stringy), 'quotedReplacement' => '\-', 'pattern' => '/[^a-zA-Z\d\s-_\-]/u'))
at preg_replace('/[^a-zA-Z\d\s-_\-]/u', '', object(Stringy)) in Stringy.php line 819
at Stringy->slugify('-') in StaticStringy.php line 383
at StaticStringy::slugify('events') in helpers.php line 542
at slugify('events') in Term.php line 127
at Term::normalizeSlug('events') in Term.php line 55
at Term->slug() in TermsDriver.php line 29
at TermsDriver->Statamic\Stache\Drivers\{closure}(array('item' => object(Term), 'path' => 'taxonomies/blog_categories/events.yaml', 'taxonomy' => 'blog_categories'), '0') in Collection.php line 135
at Collection->each(object(Closure)) in TermsDriver.php line 30
at TermsDriver->Statamic\Stache\Drivers\{closure}(object(Collection), 'blog_categories') in Collection.php line 135
at Collection->each(object(Closure)) in TermsDriver.php line 31
at TermsDriver->getModifiedItems(object(Collection)) in Updater.php line 270
at Updater->updateAggregate() in Updater.php line 142
at Updater->updateDefault() in Updater.php line 110
at Updater->update() in UpdateManager.php line 60
at UpdateManager->Statamic\Stache\{closure}(object(TermsDriver), 'terms') in Collection.php line 135
at Collection->each(object(Closure)) in UpdateManager.php line 68
at UpdateManager->update() in Manager.php line 88
at Manager->doUpdate() in Manager.php line 77
at Manager->update() in StacheServiceProvider.php line 173
at StacheServiceProvider->boot(object(Request))
at call_user_func_array(array(object(StacheServiceProvider), 'boot'), array(object(Request))) in Container.php line 507
at Container->call(array(object(StacheServiceProvider), 'boot')) in Application.php line 734
at Application->bootProvider(object(StacheServiceProvider)) in Application.php line 717
at Application->Illuminate\Foundation\{closure}(object(StacheServiceProvider), '30')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(ControllerServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FormRequestServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ValidationServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(CollectionsServiceProvider), object(ServiceProvider), object(DataServiceProvider), object(FilesystemServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(BladeServiceProvider), object(FetchServiceProvider), object(LocaleRedirectServiceProvider), object(SpockServiceProvider), object(AddonServiceProvider), object(EmailServiceProvider), object(ValidationServiceProvider), object(ServiceProvider), object(CacheServiceProvider), object(StacheServiceProvider), object(GlideServiceProvider), object(ServiceProvider), object(TranslationServiceProvider)), object(Closure)) in Application.php line 718
at Application->boot() in BootProviders.php line 17
at BootProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Statamic\Bootstrap\UpdateConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 222
at Kernel->bootstrap() in Kernel.php line 117
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 156
at require('/Users/remy/projects/web/fairtiq/public/de-ch/index.php') in server.php line 151
@jackmcdade
Copy link
Member

I'm hoping to get an official fix on the Stringy library (pull request here: danielstjules/Stringy#192) but it seems the maintainer has gone dark. Will likely need to fork and wangjangle it.

@jackmcdade
Copy link
Member

Fixed and released as 2.11.5.

@simonhamp
Copy link

simonhamp commented Apr 3, 2019

This fix doesn't actually work if, like us, you choose to install dependencies via Composer rather than the ones bundled with Statamic. It seems in that case laravel/[email protected] still loads danielstjules/stringy so both copies of Stringy sit side by side and the original version takes precedence.

We managed to workaround this with the following in statamic/composer.json:

"autoload": {
    "psr-4": {
        ...
        "Stringy\\": "vendor/statamic/stringy/src"
    }
}

@peschee
Copy link

peschee commented Nov 2, 2019

@jackmcdade @simonhamp Craft CMS had a similar issue, they seem to have swapped the Stringy implementation for https://github.com/voku/Stringy (see craftcms/cms#4753)

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

No branches or pull requests

4 participants