Skip to content

Commit

Permalink
Merge pull request #129 from Xymph/129-error-return-values
Browse files Browse the repository at this point in the history
Change error return values in WikiPage::getSection() and setText() (fixes #116)
  • Loading branch information
waldyrious authored Aug 26, 2021
2 parents 7fe8219 + f8f42ce commit 9bec877
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ and [Keep a Changelog](http://keepachangelog.com/).
* Added semi-linear merge recommendation to GOVERNANCE.md ([#130])
* Added GitHub Action to enforce updates to CHANGELOG.md ([#131])

_The following entry is a backwards incompatible API change
and may require changes in applications that invoke these methods:_

* Error return values for `WikiPage::getSection()` changed from `false` to `null` ([#129])

#### Fixed

* Fixed one error return value in `WikiPage::setText()` ([#129])

#### Removed

* Method `Wikimate::debugCurlConfig()`, deprecated since v0.10.0 ([#128])
Expand Down Expand Up @@ -170,5 +179,6 @@ and [Keep a Changelog](http://keepachangelog.com/).
[#125]: https://github.com/hamstar/Wikimate/pull/125
[#127]: https://github.com/hamstar/Wikimate/pull/127
[#128]: https://github.com/hamstar/Wikimate/pull/128
[#129]: https://github.com/hamstar/Wikimate/pull/129
[#130]: https://github.com/hamstar/Wikimate/pull/130
[#131]: https://github.com/hamstar/Wikimate/pull/131
10 changes: 5 additions & 5 deletions Wikimate.php
Original file line number Diff line number Diff line change
Expand Up @@ -1145,20 +1145,20 @@ public function getText($refresh = false)
* true to include heading too
* @param boolean $includeSubsections False to get section text only,
* true to include subsections too
* @return string Wikitext of the section on the page,
* or false if section is undefined
* @return mixed Wikitext of the section on the page,
* or null if section is undefined
*/
public function getSection($section, $includeHeading = false, $includeSubsections = true)
{
// Check if we have a section name or index
if (is_int($section)) {
if (!isset($this->sections->byIndex[$section])) {
return false;
return null;
}
$coords = $this->sections->byIndex[$section];
} else if (is_string($section)) {
if (!isset($this->sections->byName[$section])) {
return false;
return null;
}
$coords = $this->sections->byName[$section];
}
Expand Down Expand Up @@ -1308,7 +1308,7 @@ public function setText($text, $section = null, $minor = false, $summary = null)
// Check for errors
if (isset($r['error'])) {
$this->error = $r['error']; // Set the error if there was one
return null;
return false;
} else {
$this->error = null; // Reset the error status
}
Expand Down

0 comments on commit 9bec877

Please sign in to comment.