Description
Preconditions (*)
2.3.3-p1
- Have products created with the
Generate "category/product" URL Rewrites
config set toYes
in Stores->Config->Catalog->SEO. - Set
Generate "category/product" URL Rewrites
toNo
in Stores->Config->Catalog->SEO, which will clear a lot of rows in theurl_rewrite
table, but not all. - Ensure there is at least one
url_rewrite.request_path
with acategory/product
URL. That will need to be visited after performing the below.
Steps to reproduce (*)
- Use category suffixes, like
.html
in the admin forcatalog/seo/category_url_suffix
. - Save.
- Note that the value in
core_config_data
at pathcatalog/seo/category_url_suffix
is a string:.html
. - Empty the value and save, effectively meaning there should be no suffix.
- Save.
- Note that the value in
core_config_data
at pathcatalog/seo/category_url_suffix
is of typeNULL
, instead of string. - Clear cache. Visit a product page that has or used to have a category path in the URL, using the long URL.
Expected result (*)
- Product page should load with a 404.
Actual result (*)
- A blank page and 500 HTTP error code loads instead.
- See this error instead when displaying errors:
Fatal error: Uncaught TypeError: Return value of Magento\CatalogUrlRewrite\Model\Storage\DynamicStorage::getCategoryUrlSuffix() must be of the type string, null returned in /Users/danemacmillan/projects/linusshops/storefront233/releases/20200729133910803462/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php:150
Stack trace:
#0 /Users/danemacmillan/projects/linusshops/storefront233/releases/20200729133910803462/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php(171): Magento\CatalogUrlRewrite\Model\Storage\DynamicStorage->getCategoryUrlSuffix('5')
#1 /Users/danemacmillan/projects/linusshops/storefront233/releases/20200729133910803462/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php(102): Magento\CatalogUrlRewrite\Model\Storage\DynamicStorage->findProductRewriteByRequestPath(Array)
#2 /Users/danemacmillan/projects/linusshops/storefront233/releases/20200729133910803462/app/code/Magento/UrlRewrite/Model/Storage/AbstractStorage.php(66): Magento\CatalogUrlRewrite\Model\Storag in /Users/danemacmillan/projects/linusshops/storefront233/releases/20200729133910803462/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php on line 150
The reason this happens is due to the declared return type, which only expects and allows string
, while saving that configuration through the admin to an empty value will actually set NULL
instead of just an empty string. Regardless of one's ability to reproduce this issue, it is a clear, logical problem.
The offending code and commit, which just randomly declared return types by @slopukhov:
f70f1b2#diff-eb1d8c6c0059c0e71a5cbdc544a4558fR144
Insight: simply because return types can be declared does not mean that they should be declared. It is not as benign a change as perceived.
Workaround
Manually go to the catalog/seo/category_url_suffix
config in the DB and ensure that it contains an empty string instead of NULL
. Clear the cache, and suddenly those pages will load.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status