Skip to content

Commit dc2afa7

Browse files
authored
Merge pull request #197 from mihdan/v7.0.2
V7.0.2
2 parents dfd8879 + cdff68b commit dc2afa7

13 files changed

Lines changed: 792 additions & 130 deletions

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
= 7.0.2 (24.05.2026) =
2+
* Fixed legacy WooCommerce local variation attributes with punctuation in attribute names after upgrading from versions before 7.0.
3+
14
= 7.0.1 (20.05.2026) =
25
* Changed legacy sanitize_title bridge diagnostics to use the dedicated CYR_TO_LAT_DEBUG_LEGACY_SANITIZE_TITLE_BRIDGE constant instead of WP_DEBUG.
36
* Fixed legacy WooCommerce local variation attributes, including `Any` variations, after upgrading from versions before 7.0.

cyr-to-lat.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Cyr-To-Lat
1111
* Plugin URI: https://kagg.eu/cyr-to-lat/
1212
* Description: Convert Non-Latin characters in post and term slugs to Latin characters. Useful for creating human-readable URLs. Based on the original plugin by Anton Skorobogatov.
13-
* Version: 7.0.1
13+
* Version: 7.0.2
1414
* Requires at least: 6.0
1515
* Requires PHP: 7.4
1616
* Author: Sergey Biryukov, Mikhail Kobzarev, Igor Gergel
@@ -37,7 +37,7 @@
3737
/**
3838
* Plugin version.
3939
*/
40-
const CYR_TO_LAT_VERSION = '7.0.1';
40+
const CYR_TO_LAT_VERSION = '7.0.2';
4141

4242
/**
4343
* Path to the plugin dir.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Ручное воспроизведение WooCommerce legacy local attributes
2+
3+
## До фикса, на 7.0.1 / 7.0.2
4+
5+
1. Включить WooCommerce.
6+
2. Переключить Cyr-To-Lat на `6.8.0`.
7+
3. Создать вариативный товар.
8+
4. Добавить локальный пользовательский атрибут с кириллицей и пунктуацией, например `Арт.`.
9+
5. Значения атрибута: `00074-1 | 00074-2 | 00074-3`.
10+
6. Использовать атрибут для вариаций.
11+
7. Создать несколько вариаций и назначить им конкретные значения:
12+
- `00074-1`
13+
- `00074-2`
14+
- `00074-3`
15+
8. Сохранить товар.
16+
9. Проверить на `6.8.0`:
17+
- во вкладке **Вариации** у каждой вариации выбрано свое значение атрибута;
18+
- на фронтенде значения доступны в выпадающем списке;
19+
- вариацию можно выбрать и добавить в корзину.
20+
10. Переключить Cyr-To-Lat на версию до фикса: `7.0.1` или старую `7.0.2`.
21+
11. Открыть тот же товар в админке.
22+
12. Проверить вкладку **Вариации**.
23+
24+
Ожидаемая проблема до фикса:
25+
26+
- вместо конкретных значений WooCommerce показывает `Арт. с любым значением`;
27+
- на фронтенде варианты могут не отображаться или не выбираться;
28+
- старые meta keys остаются в виде `attribute_%d0%b0%d1%80%d1%82`, а новый код частично ожидает `attribute_art`.
29+
30+
## После фикса
31+
32+
1. Оставить тот же товар, созданный на `6.8.0`.
33+
2. Переключить Cyr-To-Lat на версию с фиксом.
34+
3. Открыть товар в админке.
35+
4. Проверить вкладку **Вариации**.
36+
5. Открыть товар на фронтенде.
37+
38+
Ожидаемое поведение после фикса:
39+
40+
- во вкладке **Вариации** у каждой вариации снова выбрано конкретное значение: `00074-1`, `00074-2`, `00074-3`;
41+
- на фронтенде атрибут `Арт.` отображается и значения можно выбрать;
42+
- добавление выбранной вариации в корзину работает;
43+
- данные старого товара не мигрируются автоматически, но runtime-нормализация приводит legacy key `%d0%b0%d1%80%d1%82` к каноническому key `art`.
44+
45+
## Контрольный признак
46+
47+
Кейс должен обязательно использовать атрибут с пунктуацией в имени, например `Арт.`. Атрибуты без пунктуации, например `Цвет`, могли проходить проверку даже до этого фикса и не ловили проблему.

readme.txt

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: transliteration, cyrillic, slugs, translation, multilingual
44
Requires at least: 6.0
55
Tested up to: 7.0
66
Requires PHP: 7.4
7-
Stable tag: 7.0.1
7+
Stable tag: 7.0.2
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -268,6 +268,9 @@ We will review your report and respond as quickly as possible.
268268

269269
== Changelog ==
270270

271+
= 7.0.2 (24.05.2026) =
272+
* Fixed legacy WooCommerce local variation attributes with punctuation in attribute names after upgrading from versions before 7.0.
273+
271274
= 7.0.1 (20.05.2026) =
272275
* Changed legacy sanitize_title bridge diagnostics to use the dedicated CYR_TO_LAT_DEBUG_LEGACY_SANITIZE_TITLE_BRIDGE constant instead of WP_DEBUG.
273276
* Fixed legacy WooCommerce local variation attributes, including `Any` variations, after upgrading from versions before 7.0.
@@ -281,101 +284,4 @@ We will review your report and respond as quickly as possible.
281284
* Documented that existing WooCommerce attributes are not automatically migrated in 7.0; future migration work must be a separate dry-run-first workflow.
282285
* Documented the backend-first testing strategy without required Codeception or Playwright release dependencies.
283286

284-
= 6.8.0 (10.05.2026) =
285-
* Fixed returning unexpected results by REST API in some cases.
286-
* Fixed import of WooCommerce products.
287-
* Fixed transliteration of product categories, brands, and tags.
288-
289-
= 6.7.0 (01.04.2026) =
290-
* The minimum required PHP version is now 7.4.
291-
* The minimum required WordPress version is now 6.0.
292-
* Fixed a fatal error occurred with WP-CLI in a rare case.
293-
* Fixed transliteration of WC local attributes.
294-
* Tested with WordPress 7.0.
295-
296-
= 6.6.0 (30.11.2025) =
297-
* Fixed the deprecated function message in Main.php with WordPress 6.9.
298-
* Tested with PHP 8.4.
299-
* Tested with WordPress 6.9.
300-
* Tested with WooCommerce 10.3.
301-
302-
= 6.5.0 (24.10.2025) =
303-
* Fixed transliteration of tags during editing.
304-
305-
= 6.4.1 (03.05.2025) =
306-
* Fixed the layout of messages on the Tables page.
307-
* Tested with WordPress 6.8.
308-
* Tested with WooCommerce 9.8.
309-
310-
= 6.3.0 (22.12.2024) =
311-
* Added a warning message on the Tables page when the active table does not match the site locale.
312-
* Removed fix for translation after WordPress 6.5+ due to performance issues.
313-
314-
= 6.2.3 (24.11.2024) =
315-
* Fixed the deprecation error with PHP 8.4.
316-
* Tested with PHP 8.4.
317-
318-
= 6.2.2 (15.11.2024) =
319-
* Fixed _load_textdomain_just_in_time notice with WordPress 6.7.
320-
* Some translations were empty with WordPress 6.5+.
321-
322-
= 6.2.1 (13.11.2024) =
323-
* Fixed the layout of the Converter page.
324-
* Fixed issues reported by Plugin Check Plugin.
325-
326-
= 6.2.0 (13.11.2024) =
327-
* Dropped support for PHP 7.0 and 7.1. The minimum required PHP version is now 7.2.
328-
* The minimum required WordPress version is now 5.3.
329-
* Fixed the notice about the _load_textdomain_just_in_time function being called incorrectly.
330-
* Tested with WordPress 6.7.
331-
* Tested with WooCommerce 9.4.
332-
333-
= 6.1.0 (09.03.2024) =
334-
* Tested with WordPress 6.5.
335-
* Tested with WooCommerce 8.6.
336-
* Fixed the error on the System Info tab when post types or post statuses are not set.
337-
338-
= 6.0.8 (14.02.2024) =
339-
* Improved detection of the Gutenberg editor.
340-
* Fixed processing of product attributes.
341-
342-
= 6.0.7 (11.02.2024) =
343-
* Tested with WooCommerce 8.5.
344-
* Added redirect from the cyrillic post title when creating a new post.
345-
* Added description of post types and post statuses on the Converter page.
346-
* Fixed displaying all file descriptions in the Theme Editor in the current locale.
347-
* Fixed PHP warning in the SettingsBase.
348-
* Fixed the output of variable product attributes.
349-
350-
= 6.0.6 (14.01.2024) =
351-
* Tested with WordPress 6.4.
352-
* Tested with WooCommerce 8.4.
353-
* Tested with PHP 8.3.
354-
* Fixed documentation on ctl_allow filter.
355-
* Fixed the improper display of the "rate plugin" message on options.php.
356-
357-
= 6.0.5 (09.10.2023) =
358-
* Fixed displaying file descriptions in the Theme Editor; now in the current locale.
359-
360-
= 6.0.4 (23.09.2023) =
361-
* Fixed disappeared file descriptions on the Theme File Editor page.
362-
363-
= 6.0.3 (29.07.2023) =
364-
* Fixed the fatal error with Jetpack sync.
365-
366-
= 6.0.2 (26.07.2023) =
367-
* Fixed the fatal error in admin_footer_text().
368-
369-
= 6.0.1 (26.07.2023) =
370-
* Fixed the fatal error on the System Info page with empty options.
371-
372-
= 6.0.0 (26.07.2023) =
373-
* Dropped support of PHP 5.6. The Minimum required PHP version is 7.0 now.
374-
* Tested with WordPress 6.3.
375-
* Tested with WooCommerce 7.9.
376-
* Added System Info tab.
377-
* Added filter 'ctl_allow'
378-
* Fixed the console error when saving table data.
379-
* Fixed the current table setting on the Tables page with WPML.
380-
381287
[See changelog for all versions](https://plugins.svn.wordpress.org/cyr2lat/trunk/changelog.txt).

src/php/Main.php

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ protected function init_hooks(): void {
280280
add_filter( 'woocommerce_available_variation', [ $this, 'normalize_wc_available_variation_attributes' ], 10, 3 );
281281
add_filter( 'woocommerce_cart_item_data_to_validate', [ $this, 'normalize_wc_cart_item_data_to_validate' ], 10, 2 );
282282
add_filter( 'woocommerce_add_cart_item', [ $this, 'normalize_wc_cart_item_variation_attributes' ] );
283+
add_action( 'woocommerce_product_read', [ $this, 'normalize_wc_read_product_attribute_keys' ], 10, 2 );
284+
add_filter( 'woocommerce_product_get_attributes', [ $this, 'normalize_wc_product_get_attribute_keys' ], 10, 2 );
285+
add_filter( 'woocommerce_product_object_query', [ $this, 'normalize_wc_product_object_query_variation_attributes' ], 10, 2 );
283286
add_action( 'wp_loaded', [ $this, 'normalize_wc_add_to_cart_request_attributes' ], 15 );
284287

285288
if ( ! $this->request->is_allowed() ) {
@@ -297,8 +300,6 @@ protected function init_hooks(): void {
297300
add_filter( 'post_updated', [ $this, 'check_for_changed_slugs' ], 10, 3 );
298301
add_action( 'woocommerce_before_product_object_save', [ $this, 'normalize_wc_product_attribute_keys' ] );
299302
add_action( 'woocommerce_product_attributes_updated', [ $this, 'normalize_wc_product_attribute_meta' ] );
300-
add_action( 'woocommerce_product_read', [ $this, 'normalize_wc_read_product_attribute_keys' ], 10, 2 );
301-
add_filter( 'woocommerce_product_get_attributes', [ $this, 'normalize_wc_product_get_attribute_keys' ], 10, 2 );
302303

303304
add_action( 'before_woocommerce_init', [ $this, 'declare_wc_compatibility' ] );
304305

@@ -424,6 +425,7 @@ public function normalize_wc_product_attribute_meta( object $product ): void {
424425
*/
425426
public function normalize_wc_read_product_attribute_keys( int $product_id, object $product ): void {
426427
$this->local_attribute_service()->normalize_read_product_attributes( $product );
428+
$this->variation_attribute_service()->normalize_read_variation_attributes( $product );
427429
}
428430

429431
/**
@@ -440,7 +442,36 @@ public function normalize_wc_product_get_attribute_keys( $attributes, object $pr
440442
return $attributes;
441443
}
442444

443-
return $this->local_attribute_service()->normalize_product_attribute_array( $attributes );
445+
$attributes = $this->local_attribute_service()->normalize_read_product_attribute_array( $product, $attributes );
446+
447+
if ( method_exists( $product, 'get_type' ) && 'variation' === $product->get_type() ) {
448+
return $this->variation_attribute_service()->normalize_read_variation_attribute_array( $product, $attributes );
449+
}
450+
451+
return $attributes;
452+
}
453+
454+
/**
455+
* Normalize WooCommerce variation attribute keys in product object query results.
456+
*
457+
* @param array|mixed $products Products.
458+
* @param array $query_vars Query vars.
459+
*
460+
* @return array|mixed
461+
* @noinspection PhpUnusedParameterInspection
462+
*/
463+
public function normalize_wc_product_object_query_variation_attributes( $products, array $query_vars ) {
464+
if ( ! is_array( $products ) ) {
465+
return $products;
466+
}
467+
468+
foreach ( $products as $product ) {
469+
if ( is_object( $product ) && method_exists( $product, 'get_type' ) && 'variation' === $product->get_type() ) {
470+
$this->variation_attribute_service()->normalize_read_variation_attributes( $product );
471+
}
472+
}
473+
474+
return $products;
444475
}
445476

446477
/**

0 commit comments

Comments
 (0)