https://bugzilla.wikimedia.org/show_bug.cgi?id=41042
Web browser: ---
Bug #: 41042
Summary: Requesting 'sections' for nonexistent page does not
give error
Product: MediaWiki
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: API
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected],
[email protected]
Classification: Unclassified
Mobile Platform: ---
I'm writing a set of PHP classes to replace botclasses.php for automated use of
the API. I've come across what I feel is a bug, but the API does not return an
error for it.
If I request the sections (TOC) for "Does-not-exist", I get an 'empty' result.
If I request the sections (TOC) for "Special:Does-not-exist", I get a real
error thrown.
This means I've had to code my function such that when an empty list of
sections is returned, it checks if the page exists, thus:
$q = '&prop=sections&page='.urlencode($page);
if ( $revid !== null )
$q .= '&rvstartid='.$revid;
$r = $this->query_content( $q );
if ( isset($r['error']) ) { // Error getting any page data
return self::ERR_ret( self::ERR_error, "API error, info:"
.$result['error']['info']." Result:".$result['error']['code']
);
}
$toc_elem = $r['parse']['sections'];
if ( empty($toc_elem) ) { // Empty, does that mean page doesn't exist?
if ( $this->get_page( $page ) == false) {
return self::ERR_ret( self::ERR_warn, "Requested TOC for
nonexistent page" );
}
}
Because the API is not returning an error straight away that indicates the page
does not exist, a second API call is needed to pull the entire page or throw an
error because a nonexistent page was requested.
This can be seen with
http://en.wikinews.org/w/api.php?action=parse&format=xml&prop=sections&page=doesnotexist
versus
http://en.wikinews.org/w/api.php?action=parse&format=xml&prop=sections&page=Special:doesnotexist
Only the latter throws an error.
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l