Kroc / NoNonsenseForum

A free, open source, PHP-based simple discussion forum. It favours removing barriers to conversation rather than massaging egos. Download Here: https://github.com/Kroc/NoNonsenseForum/archive/master.zip
http://camendesign.com/nononsense_forum
Other
247 stars 34 forks source link

Handle PHP5.4 but no transliterator #185

Closed Kroc closed 9 years ago

Kroc commented 10 years ago

There's a common situation where a user has PHP5.4, but the transliterator libs are not present and the title transliteration fails. We need to check for error and fall back to the <= PHP5.3 methods.

See: http://forum.camendesign.com/how-to-fix-parse-error-syntax-error-unexpected-t_object_operator-in-index-ph+1#6dbuokoy8g1e

Zegnat commented 10 years ago

I had totally forgotten about this bug, just throwing it out here, but would it work to add the following along with the function_exists ('transliterator_transliterate') check?

in_array ('Any-NFKD', $list = transliterator_list_ids ()) &&
in_array ('Any-Latin', $list) &&
in_array ('Latin-ASCII', $list) &&
in_array ('Any-Remove', $list) &&
in_array ('Any-Lower', $list)

I am using just ASCII here because US-ASCII was not in my local list of IDs. The separate keywords were not available without the Any- prefix. Don’t know how much these differences matter for the transliterator_transliterate string.

We might be able to make this check more compact using some clever array functions. If I can find a server that has this bug I’ll try this out.

Edit:

As a single check, making for less function calls:

count (array_intersect (array ('Any-NFKD', 'Any-Latin', 'Latin-ASCII', 'Any-Remove', 'Any-Lower'), transliterator_list_ids ())) === 5
Kroc commented 10 years ago

We also need to check the transliterator_list_ids function exists too ;) Very nice solution, this will be rolled in as soon as I get back to NNF. I'm just in the process of setting up a new PC and getting my data back into a working state.

Zegnat commented 10 years ago

We also need to check the transliterator_list_ids function exists too ;)

It might be enough to put this check after the function_exists ('transliterator_transliterate'). I don’t think you are likely to run into an environment that supports the one without the other. But for completion sake that would of course be possible :smile:

Do note that I haven’t actually tested if this fixes the bug on affected servers. My server is not affected. Someone else will have to test this when it lands.

Zegnat commented 9 years ago

Over at the forums, Rogue writes in to say the transliterator_list_ids check seems to be working as expected: disabling transliterator_transliterate on his set-up where it wasn’t working.

Zegnat commented 9 years ago

Really happy to see this land, good work everyone who wrote in about this :+1:

Kroc commented 9 years ago

Thank you immensely for your work on this (and the UTF-8 handling), I haven't been able to work so diligently since my son has arrived so I grealty appreciate the motivation you bring to the project.