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
Contradictory conversions in seo_zenphoto extension #1174
Comments
So 1 and 2 I welcome an update to the plugin respectively the array of defines. |
Just curious about Bonus 2. Is your set exclusive to the zenphoto one? If not, at least for the PHP combination there should be no problem with adding it. These transformations are provided by applying a filter. As many filters as you like may be registered to a target. They are applied in priority order, so by an additional plugin would be no issue there. The javascript handling would be a bit more complicated, but also doable. The only thing required would be to remove the $plugin_disable line. |
This reverts commit b239629.
This reverts commit b239629.
No, it's meant to be additive. I was trying to apply locale-specific conversions (replacement of German Umlauts) to the SEO-relevant string. This was before I found the seo_zenphoto extension.
So I can either have my filter applied or have the basic cleanup, but not both. (At least not without pulling a trick like having my extension unregister itself, call Edit: Ideally there would be a way to let extensions decide whether they are additive or exclusive. This could be done using an optional call-by-reference parameter:
|
Yes, since there is only a basic default the plugin takes over or not. But have you tried to call your plugin later in order than the official one? It is certainly possible to attach more than one filter calls to a filter hook. As already mentioned in a later version this will move to core and allow adding directly (since the array is passed through the filter, the function attached can then decided what to do). Meanwhile I would appreciate the update to the conversion array to the plugin since the duplicates are a bug. Edit: I apparently didn't remember that the plugin author had decided back then to allow only one seo filter at the time. Try to remove |
You are correct in observing that the "standard" seo removes non-alphanumeric characters and consolidates spaces into a hyphen. That service could be provided even if a filter is applied. But it is probably inappropriate for the default to be to remove the non-alphanumeric characters. Consolidating spaces into hyphens is ok, though. If you create a filter it needs to replace the non-alphanumeric characters (if that is your desire.) For instance, the seo_null plugin deliberately does not remove them. If you remove the $plugin_disable lines you can use your filter as an additive. If the order of application matters, make sure the filter priorities match your required order. The problem with the current implementation (besides not consolidating the spaces/hyphens centrally) is that the javascript version of the functions creates a function rather than provide an additive set of statements. (this is fixed by netPhotoGraphics/netPhotoGraphics@1f4e621) The javascript code is used only for creating new albums. |
I understand that my filter could be called in addition to other filters, but that wasn't my point. I don't like the idea of copy & pasting code to plugins or redefined functions/methods because that way you wouldn't notice if the original code was changed. Imagine me copy & pasting the following line from Zenphoto to my filter:
Tomorrow someone discovers that this line of code only replaces doubles and triplets of hyphens but not quadruplets and changes Zenphoto to use this improved version:
My filter would now show a different behavior and I have successfully avoided to benefit from improvements to the base code. 😉
🤔 Agreed. |
@kochs-online I do understand. This is why this is currently either/or. The point here was to remove that line and see if it works out calling both together. I'll consider to remove that requirement of one at the them since it does not make sense to limit this.
You can just send it with the pull request for the updated conversion array fixing what you found ;-) In the future when this will be core with some selections we'll consider to provide an additional filter to modify the conversion array itself additionally. |
Working on the updated conversion table. What a snakepit! 😣 As suspected conversions are locale-specific and may differ from language to language. One example would be the Cyrillic letter "ь", that "has no phonetic value of its own and is purely an orthographic device" in Modern Russian according to Wikipedia. As such it is dropped when converting SEO-relevant strings as of now. In Bulgarian however that letter is "representing the mid back unrounded vowel" and should be replaced by the Latin letter "a". I know, the whole topic is rather academic, but nonetheless I wonder what a less error-prone solution would look like. Make it a
At least this would make the code a lot more readable and maintanable while also solving the problem of contradicting conversions. Downside would be that I have no idea how to assign the current replacements to various locales. Another approach would be to use |
Unless I am mistaken iconv() is not always available. I don't think that it is really useful to create a switch. Overcomplicates stuff IMHO. We should generally offer a general clearance to use plain ABC/Numbers for urls like other CMS do it. We will never be able to cover all possible languages and their specialities 100% correctly since you probably have to know those languages to be able to (see the speciality of the cyrillic char). I mean look at the array… If anyone requires specific things really a specific plugin can/needs to be created. Also probably careful with any setlocale usage as it may intefere with other settings unwantedly. |
I analyzed the current array more thoroughly and identified these entries as (possibly) problematic:
For comparison these are ordered by their (hexadecimal) UTF-8 code in order to find duplicates. |
Okay, that is not that much. Feel free to make the changes to the existing array. Users can always manually edit the name/titlelink of items if it does not generate the 100% fitting replacement, too. |
I came back to this age-old thread and tried to write a plugin to change the names of new album folders to lower-case. I also wanted to convert some special characters used in the German language (ß and Umlauts) into their basic Latin alphabet transcriptions (ä → ae, ö → oe, …).
That being said I discovered that there already is an official extension named seo_zenphoto that's supposed to do exactly this. I gave it a test run and noticed that while it replaces "ä" with "ae" and "ö" with "oe", it replaces "ü" with "u" instead of "ue" as expected.
The reason for this is that there are some duplicates in the large replacement array
$specialchars
ofseo_zenphoto.php
. One of these entries replaces "ü" with "ue" and two more entries replace "ü" with "u".Here is a list of the duplicates I found (that comparison wasn't exactly a work of science so there might be more 😉):
Not all of these duplicates are contradictory, but some are.
I don't know the source of the list used for that array, but maybe it was locale-dependent? Should this replacement be locale-aware as well?
Bonus round: The capital ẞ is missing in the list of replacements. Correct replacement would be "SS".
Bonus round number 2: When starting to write my own extension I tried to keep Zenphoto's standard behavior for replacements and just add my own set. Unfortunately this is either/or. So you can either have Zenphoto's set of replacement rules or your own, but cannot combine them and maintaining an extension would require you to check all new versions if Zenphoto's implementation has changed. Any chance to improve this?
The text was updated successfully, but these errors were encountered: