Handle invalid titles by using `newFromTextThrow` and
returning a fatal status if the title is invalid.
Bug: T207577
Change-Id: I2bdfcdbcb7ee41f96122e7f8aa561f6eee34be7b
public function onFormSubmit( $formData ) {
$title = $formData['page'];
- $page = Title::newFromText( $title );
+ try {
+ $page = Title::newFromTextThrow( $title );
+ } catch ( MalformedTitleException $e ) {
+ return Status::newFatal( $e->getMessageObject() );
+ }
$query = [ 'action' => 'edit', 'section' => 'new' ];
$url = $page->getFullUrlForRedirect( $query );
$this->getOutput()->redirect( $url );