This won't help if you only want ASCII letters in your URLs. But if you prefer cleaner URLs and keep transliteration working for non-Japanese URLs, you can use something like this (it's important to turn off transliteration in settings when using this):
/**
* Deal with Japanese and other non-Latin characters in Pathauto aliases.
*
* Unicode ranges taken from here and converted to PHP:
* @see https://gist.github.com/ryanmcgrath/982242
*
* Implements hook_pathauto_alias_alter().
*/
function pathauto_cjk_pathauto_alias_alter(&$alias, array &$context) {
// If the alias contains CJK characters, clean up punctuation but do not
// transliterate because Japanese gets transliterated as Chinese.
// @see https://www.drupal.org/project/drupal/issues/2984977
if (preg_match('/[\x{3000}-\x{303F}]|[\x{3040}-\x{309F}]|[\x{30A0}-\x{30FF}]|[\x{FF00}-\x{FFEF}]|[\x{4E00}-\x{9FAF}]|[\x{2605}-\x{2606}]|[\x{2190}-\x{2195}]|\x{203B}/u', $alias)) {
// Cleanup fullwidth characters.
$alias = mb_convert_kana($alias, 'KVrn');
// Replace punctuation with hyphens.
$alias = preg_replace('/[\x{3000}-\x{303F}]|[\x{2605}-\x{2606}]|[\x{2190}-\x{2195}]|[\x{203B}\x{30FB}]|[ \t]/u', '-', $alias);
// Replace remaining special characters with hyphens.
$alias = preg_replace('/[^\p{Han}\p{Katakana}\p{Hiragana}\p{Latin}\d\/]+/u', '-', $alias);
} else {
// Transliterate the alias.
$alias = \Drupal::transliteration()->transliterate($alias, $context['language'] ?? 'en');
}
$alias = \Drupal::service('pathauto.alias_cleaner')->cleanAlias($alias, $context['source'], $context['language']);
}
This might need more polishing and testing, so any suggestions and improvements are welcome.
@fabianderijk Thanks for creating the MR. I never go around doing it myself. Also, our website no longer needs the destination parameter to work so desperately. Still, I've applied the patch on our site and can confirm that it is working locally on my machine. At least I can help others, and it will be working if our site ever requires it.
As I'm changing roles soon, my focus is going to shift, and I'm probably no longer able to help you guys, sorry. But I hope I can continue to contribute in some ways in the future. In the meantime, keep up the good work!
I'm marking this as RTBC, but feel free to change it back if you want someone else to test it.
hi @shubham_jain. I've not done exessive testing on it yet, but you can use either method. Both should produce the same effect, but may have different side effects depending on your installation.
Thanks @catch. I can confirm that this approach works. I didn't realise the hook is being executed again during aggregation.
See patch attached for a quick fix. Probably needs more thought on what we check and some cleanup.
I was trying to get gin_lb to work on our site. But going to 10.1 and enabling aggregation caused the core CSS to reapply which resulted in a rather messy output.
I did some debugging and hook_css_alter does still run. But it seems like aggregation relies on the libraries more than the individual files. As a workaround, I managed to disable the libraries using libraries-override
. Just paste the code below into your theme's info file. Refactoring is probably a good idea. Unfortuantly, those libraries overrides only work for themes. But maybe we can use hook_libraries_info_alter
instead?
libraries-override:
layout_builder/drupal.layout_builder:
css:
theme:
css/layout-builder.css: false
core/drupal.dialog.off_canvas:
css:
base:
misc/dialog/off-canvas/css/reset.css: false
misc/dialog/off-canvas/css/base.css: false
misc/dialog/off-canvas/css/utility.css: false
component:
misc/dialog/off-canvas/css/button.css: false
misc/dialog/off-canvas/css/drupal.css: false
misc/dialog/off-canvas/css/form.css: false
misc/dialog/off-canvas/css/table.css: false
misc/dialog/off-canvas/css/details.css: false
misc/dialog/off-canvas/css/messages.css: false
misc/dialog/off-canvas/css/tabledrag.css: false
misc/dialog/off-canvas/css/throbber.css: false
misc/dialog/off-canvas/css/dropbutton.css: false
misc/dialog/off-canvas/css/titlebar.css: false
misc/dialog/off-canvas/css/wrapper.css: false
core/drupal.autocomplete:
css:
theme:
assets/vendor/jquery.ui/themes/base/theme.css: false
core/drupal.dialog:
css:
component:
assets/vendor/jquery.ui/themes/base/dialog.css: false
system/base:
css:
component:
css/components/tabledrag.module.css: false
Thank you. Closing this as a duplicate of 📌 Prepare Smart IP for Drupal 10 Needs review .
When can we expect a release for this fix?
Ended up here for the same reason. Looks like a regression which was fixed here, but hasn't been released yet: https://git.drupalcode.org/project/search_api/-/commit/9faec4590e48d8add...
It seems to get worse if you have data in the field. I'm not sure where the constraint comes from, because either of these can be NULL.
[error] SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'parent_id' cannot be null: INSERT INTO "field_deleted_data_d0a1ee0c5e" ("bund
le", "entity_id", "revision_id", "langcode", "parent_menu_name", "parent_id", "deleted", "delta") SELECT "entity_table"."bundle" AS "bundle", "entity_t
able"."id" AS "entity_id", "entity_table"."id" AS "revision_id", "entity_table"."langcode" AS "langcode", "entity_table"."parent__menu_name" AS "parent
_menu_name", "entity_table"."parent__id" AS "parent_id", :deleted AS "deleted", :delta AS "delta"
> FROM
> "group_content_menu_field_data" "entity_table"
> WHERE ("entity_table"."parent__menu_name" IS NOT NULL) OR ("entity_table"."parent__id" IS NOT NULL) FOR UPDATE; Array
> (
> [:deleted] => 1
> [:delta] => 0
> )
Re-roll of #44 for 2.1.x
I've run into a similar problem where the block_content entity has translations (because of core patch which adds symmetric translations to layouts). The media library widget was unable to update the media file once a translation was created. It would only work for the translation, but not the original language.
Checking block usage with latest revision ID of the block_content entity won't work, because the section storage stores the latest translation affected revision ID in the layout. I'm not sure if this is a problem which should be taken into account here or solved elsewhere. But considering that layout_builder_st should at some point, it might be worth fixing it here.
I've attached a patch which uses getLatestTranslationAffectedRevisionId on the entity storage to work around this (requires changes from the MR to be applied first). I can push it to the MR if this is useful, but since it needs entityTypeManager I wanted to check first if there is a better solution to the problem.
This patch takes both, query length and language into account.
Same problem here and your solution works, thanks. The only downside is that it's MySQL specific. It's not an issue for us, but it might be for those using PostgreSQL.
So we could use ORDER BY CASE instead to ensure that 'und' comes last:
$rid = $this->connection->query('SELECT rid FROM {redirect} WHERE hash IN (:hashes[]) ORDER BY CASE language when :not_specified then 0 else 1 end DESC',
[
':hashes[]' => $hashes,
':not_specified' => LanguageInterface::LANGCODE_NOT_SPECIFIED
])->fetchField();
Using the patch I'm getting
Uncaught Error: Class "Drupal\s3fs_file_proxy_to_s3\S3fsFileProxyToS3Stream" not found in /var/www/html/w
eb/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php:154
Looks like S3fsFileProxyToS3ServiceProvider.php
is missing a use statement. Also, use Symfony\Component\DependencyInjection\Reference;
can be removed.
I checked my patch again in a clean Drupal 9.5.x installation with only langauge_herarchy 2.x-dev enabled and can confirm that the bug is both present and fixed by the patch I've provided.
As why the special casing, I don't know. It has to do how Drupal deals with language configuration. If I remove it, language_hiearchy wrongly assumes there is no current translation and always uses the fallback instead of the default translation, which is wrong.
#17 fixes the issue for me also. I agree that ajax_query should not include the base path in the first place. But with 🐛 Facets with AJAX not working in most of situations Needs review not yet fixed, it's nice to have a minimal solution which does not interfere.
phma → created an issue.
Thanks arpeggio for your work on getting smart_ip ready for Drupal 10. Installing 5.0.0-alpha2 still fails though, because it has a dependency to drupal/core ^9 in composer.json
. Is this dependency even necessary?
],
"require": {
"drupal/core": "^8.7.7 || ^9",
"geoip2/geoip2": "~2.0",
"ip2location/ip2location-php": "~8.0"
},
]
Looks like rector missed this particular one.
To my knowledge this is still broken due to 🐛 RuntimeException: Failed to start the session because headers have already been sent Fixed . The session for the anonymous user is being destored, so the destination is lost.
Fixing code styling issue and using the latest branch.
The media widget discards any classes added by CKEditor on 'downcasting'. That's why using a custom module like in #6 doesn't work.
This patch should fix this.