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

Alpine linux incompatibility #966

Closed
enumag opened this issue Jul 12, 2018 · 11 comments
Closed

Alpine linux incompatibility #966

enumag opened this issue Jul 12, 2018 · 11 comments

Comments

@enumag
Copy link
Member

enumag commented Jul 12, 2018

You recently added a FilesystemCacheFactory which uses Strings::webalize(). The problem is that webalize internally calls iconv with ASCII//TRANSLIT//IGNORE which doesn't work on Alpine.

@enumag
Copy link
Member Author

enumag commented Jul 12, 2018

To be more specific it causes a PHP notice:

PHP Notice:  iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT//IGNORE' is not allowed in /usr/app/vendor/nette/utils/src/Utils/Strings.php on line 185

But the worse problem is that aside of throwing this notice webalize can potentially return an empty string even if the input was not empty. Symplify doesn't actually fail, I just see the notice in the log but it is potentially dangerous.

@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 12, 2018

Is that Symplify or Nette?

Solutions?

@enumag
Copy link
Member Author

enumag commented Jul 12, 2018

It's a problem in Nette, unfortunately there is no known solution. Even detecting the issue to throw an exception instead of bad silent behaviour is difficult.

The problem in Symplify is that it should not use a Nette function with such known issues.

As for solution I would simply use md5 instead of webalize in this case. I mean it's just a directory name for cache so the value doesn't matter, right?

@enumag
Copy link
Member Author

enumag commented Jul 12, 2018

If you're asking what to use instead of webalize to generate slugs (which is not the case here) then I can recommend cocur/slugify.

@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 12, 2018

The namespace is easier to debug while human readble.

Could you send slugify PR for all webalize occurrences?

@enumag
Copy link
Member Author

enumag commented Jul 12, 2018

There are only two other occurrences.

  1. In ProcessFactory but that seems to be a similar case as here so md5 should be fine there too.

  2. In MarkdownFileDecorator. In this case you do actually need a slug, but are you sure you want to include another library for a single case? Also note that slugify works differently and in my opinion better - it works well with cyrillic, chinese and many other alphabets.

@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 12, 2018

The namespace is easier to debug while human readble.

Same goes for paths.

I think propper solution is install the PHP extension rather than switching packages due to minor incompatible Linux version.

@enumag
Copy link
Member Author

enumag commented Jul 12, 2018

It's not a question of missing PHP extension, the extension is there but unfortunately works a bit differently than normal. It can't be solved easily.

@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 12, 2018

Still, it's responsbility of Nette or the Linux.
It doesn't make sense to send such issue to every PHP package that uses Nette\Utils\Strings class on Alpine, does it.

Fixing it here is postponing such responsbility with band-aid instead of curing it.
Closing it here.

@enumag
Copy link
Member Author

enumag commented Jul 12, 2018

I agree but unfortunately there is no way to fix it correctly.

@TomasVotruba
Copy link
Member

Related: nette/utils#109

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

No branches or pull requests

2 participants