Skip to content

fix: remove unreachable ucwords fallback in GoogleAdwords UppercaseTitle - #40946

Open
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/uppercase-title-mbstring-guard
Open

fix: remove unreachable ucwords fallback in GoogleAdwords UppercaseTitle#40946
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/uppercase-title-mbstring-guard

Conversation

@lbajsarowicz

@lbajsarowicz lbajsarowicz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

Remove the unreachable ucwords() fallback from Magento\GoogleAdwords\Model\Filter\UppercaseTitle::filter().

Problem

The filter guards mb_convert_case() behind a function_exists() check with an ucwords() fallback:

if (function_exists('mb_convert_case')) {
    $value = mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
} else {
    $value = ucwords($value);
}

ext-mbstring is a hard requirement in Magento's root composer.json, so the fallback is unreachable. If it ever ran, ucwords() would also mangle multibyte titles — the fallback is not even behavior-equivalent.

Solution

Call mb_convert_case() directly. A multibyte case ('łukasz ünique title''Łukasz Ünique Title') is added to the unit test data provider to lock in the intended multibyte behavior.

Files Changed

  • app/code/Magento/GoogleAdwords/Model/Filter/UppercaseTitle.php
  • app/code/Magento/GoogleAdwords/Test/Unit/Model/Filter/UppercaseTitleTest.php

Related Pull Requests

Same cleanup pattern as #40686, #40687, #40688.

Manual testing scenarios (*)

  1. Run app/code/Magento/GoogleAdwords/Test/Unit/ — all tests pass, including the new multibyte case.
  2. Configure Google AdWords conversion pages — title-casing of values behaves as before.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] fix: remove unreachable ucwords fallback in GoogleAdwords UppercaseTitle #40952: fix: remove unreachable ucwords fallback in GoogleAdwords UppercaseTitle

Call mb_convert_case() directly because ext-mbstring is a hard Composer
requirement for Magento 2.4-develop.

Add multibyte title-case coverage to preserve the intended behavior.
@m2-assistant

m2-assistant Bot commented Jul 6, 2026

Copy link
Copy Markdown

Hi @lbajsarowicz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@engcom-Hotel

Copy link
Copy Markdown
Contributor

@magento create issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

[Issue] fix: remove unreachable ucwords fallback in GoogleAdwords UppercaseTitle

2 participants