Page MenuHomePhabricator

api action sfautoedit / parser function #autoedit unable to clear a field
Closed, ResolvedPublic



When trying to edit an existing page with the api action sfautoedit or the parser function #autoedit there seems no way to clear an existing field. E.g.:

I have the page content

|arrival date=tomorrow

When trying to

|target=example page
|query string=item[status]=available&item[arrival date]=&item[in stock]=42

the resulting page looks like

|arrival date=tomorrow
|in stock=42

I tried with and w/o setting preload=

Then, I did some debugging of SF_AutoeditAPI.php to try to fix this but got lost somewhere between line 912 and 956. Seems to me that the call of $sfgFormPrinter->formHTML in line 927 is subsequently ignored and redone in line 960. This first one correctly omits the cleared field, the second doesn't. I then gave up my efforts trying to sort through SF_FormPrinter.php. Sry.

Problems seems to be that somewhere the distinction between a field that is omitted from the query string and one that is set to an emtpy string is lost. The edit action then treats them both the same way: keep the original value.

Note: omitting a field, setting it to false or submit a bunch of spaces is all treated the same way.

What happens with a field that is omitted is a matter of personal taste, I think. But clearing a field is something one could need now and then. Is it possible to extend the functionality? Or better yet: did I do something wrong (in which case, please tell me how to do it)?


Event Timeline

Change 368413 had a related patch set uploaded (by Oetterer; owner: Oetterer):
[mediawiki/extensions/PageForms@master] Fix problem with autoedit api not being able to clear a template parameter

Change 368413 merged by jenkins-bot:
[mediawiki/extensions/PageForms@master] Fix problem with autoedit api not being able to clear a template parameter