While working on other issue, I noticed a bit of inconsistency in the file_check_directory() function. It may be (optionally) called with a form element name, to file any errors against that element. Currently, there are three instances of form_set_error() inside that code. One of these is called conditionally, only if file_check_directory() is used on a form element, other two are called always (in the independent-of-any-forms usage too).
Currently, this is not causing any trouble, because (luckily) form_set_error() do literally nothing if called with a NULL argument. But it might change in the future. Also the inconsistent code inside file_check_directory() looks quite puzzling at first glance.
So I think that it would be still nice to clean this up, even if it was just for code readability. The attached patch is standardizing on the conditional call method, which I believe is more robust (although currently saves us just a function call with one other conditional inside). Other possibility might be to remove also the existing conditional to standardize on unconditional calls (thus relying on form_set_error() behavior with NULL, which will then need to be documented).
Since nothing is currently broken, this issue is 'minor' ;)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 202935-3-inconsistent-form-element-check.patch | 1.77 KB | pfrenssen |
| file-form-errors.patch | 1.8 KB | JirkaRybka |
Comments
Comment #1
pfrenssenindeed no functional change but a small improvement in code consistency
Comment #3
pfrenssenStrange, the patch applies cleanly here. I rolled a new patch, let's see if this is more appetizing to the test bot. The code has not changed.
Comment #5
pfrenssenI don't see the point in this any more.