Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
file system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Jul 2021 at 08:25 UTC
Updated:
12 Aug 2021 at 09:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
longwaveComment #3
daffie commentedComment #4
andypostUsing
git grep -E 'throw new \w+Exception.*NULL'I found 2 more placesRe #3 I see no way to add deprecation message because all exceptions are inherited from
\Exceptionwhich declared aspublic function __construct($message = "", $code = 0, Throwable $previous = null) {}I found few places where it defined asint $code = 0and few places in SF?int $code = 0so probably only static analysis may helpComment #5
daffie commented@andypost: Thank you for the git grep command. Learned something new.
When I use the command
git grep -E 'throw new \w+Exception.*NULL'after applying the patch, I get a number of results.Most of them are fake positives, only 2 are not:
- core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php: throw new CacheableHttpException($cacheability, 501, $message, NULL, []);
- core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php: throw new CacheableHttpException($cacheability, 501, $message, NULL, []);
The last parameter is the one for the variable
$code. Only when calling the parent exception the value of code is put into the variable$headers. The parent isvendor/symfony/http-kernel/Exception/HttpException.php. Not sure if we want to fix it in this issue.All other changes are for me RTBC.
Comment #6
longwave@daffie I think that is a separate bug: #3002352: CacheableHttpException must pass a $headers argument to HttpException
Comment #7
longwaveComment #8
daffie commentedAll changes look good to me.
I could not find any other instances with this problem.
For me it is RTBC.
@longwave: Thanks for the reply.
Comment #9
andypostComment #10
andypostI think it still makes sense to fix broken arguments and decide about headers in related issue because @alexpott suggests to remove it in #3002352-29: CacheableHttpException must pass a $headers argument to HttpException
IMO the fix perfectly fits into scope of this issue
Comment #11
daffie commentedI do not think we can do this change. It now works when you do:
throw new CacheableHttpException($cacheability, 501, $message, NULL, []);. With this change it will be a BC break.Could we change this to:
throw new CacheableHttpException($cacheability, 501, $message, NULL);or maybe even to:throw new CacheableHttpException($cacheability, 501, $message);. We do not need to add the default parameter values.Comment #12
longwave#11.1 can we do something like
However the only uses in core are touched here and the only use in contrib is jsonapi: http://grep.xnddx.ru/search?text=CacheableHttpException&filename=
Comment #13
daffie commentedThe solution from #12 looks good to me. Can we also add a comment with why we have this solution.
Comment #14
andypostAdded workaround with todo but I'm sure as there's no usage in contrib and jsonapi is "fresh" it needs no reason
Comment #15
daffie commentedIt looks good to me now.
Back to RTBC.
Comment #16
alexpottCommitted 65fb382 and pushed to 9.3.x. Thanks!
Comment #18
mondrake