From eded2c5307e78bca66de3f53ba53bb68be9df22e Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Wed, 30 Apr 2014 17:10:43 -0700 Subject: [PATCH] Allow editing transcluded sections via the API Change-Id: I784d7263d6743ed16e401384e9efef1f231320a0 --- includes/api/ApiEditPage.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 73eebcad08..635f6f889c 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -167,7 +167,7 @@ class ApiEditPage extends ApiBase { $content = null; } else { // Process the content for section edits - $section = intval( $params['section'] ); + $section = $params['section']; $content = $content->getSection( $section ); if ( !$content ) { @@ -288,12 +288,12 @@ class ApiEditPage extends ApiBase { } if ( !is_null( $params['section'] ) ) { - $section = intval( $params['section'] ); - if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) { - $this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" ); + $section = $params['section']; + if ( !preg_match( '/^((T-)?\d+|new)$/', $section ) ) { + $this->dieUsage( "The section parameter must be a valid section id or 'new'", "invalidsection" ); } $content = $pageObj->getContent(); - if ( $section !== 0 && ( !$content || !$content->getSection( $section ) ) ) { + if ( $section !== '0' && $section != 'new' && ( !$content || !$content->getSection( $section ) ) ) { $this->dieUsage( "There is no section {$section}.", 'nosuchsection' ); } $requestArray['wpSection'] = $params['section']; @@ -529,7 +529,7 @@ class ApiEditPage extends ApiBase { array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ), array( 'code' => 'invalidsection', - 'info' => 'The section parameter must be set to an integer or \'new\'' + 'info' => 'The section parameter must be a valid section id or \'new\'' ), array( 'code' => 'sectionsnotsupported', -- 2.20.1