Last modified: 2013-09-30 11:45:54 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56666, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54666 - FormSpecialPage's onSubmit() signature omits $form parameter
FormSpecialPage's onSubmit() signature omits $form parameter
Status: NEW
Product: MediaWiki
Classification: Unclassified
Special pages (Other open bugs)
1.22.0
All All
: Low minor (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-26 21:27 UTC by spage
Modified: 2013-09-30 11:45 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description spage 2013-09-26 21:27:44 UTC
HTMLForm's trySubmit() calls the client-supplied onSubmit() callback:
    call_user_func( $callback, $data, $this );

so the second parameter to the callback is the HTMLForm object. This doesn't seem to be documented anywhere.

But when you subclass FormSpecialPage, it declares the form handler as
    abstract public function onSubmit( array $data );

so you can't access this second parameter.  I need access to the form for a demo program because some of the controls on the form affect its display.

If I change the function declaration in SpecialPage.php to
    abstract public function onSubmit( array $data, $form );

then my program can access the form object, but this breaks all the other pages that subclass FormSpecialPage.

I dunno if there's some PHP foo to let children inspect the hidden second parameter, or some way not to break the API.
Comment 1 spage 2013-09-27 22:21:21 UTC
Workaround: FormSpecialPage subclasses can use PHP's func_get_args() in their submit callback function to reveal the second parameter missing from the abstract declaration.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links