From 223a5dfee1d809e4e9b3a4d079c7d9a29413a1cd Mon Sep 17 00:00:00 2001 From: Xymph Date: Thu, 26 Aug 2021 17:30:50 +0200 Subject: [PATCH 1/2] Fix error return value in WikiPage::getSection() --- CHANGELOG.md | 6 ++++++ Wikimate.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05db78a..378bef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ 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]) + #### Removed * Method `Wikimate::debugCurlConfig()`, deprecated since v0.10.0 ([#128]) @@ -170,5 +175,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 diff --git a/Wikimate.php b/Wikimate.php index 31b28bb..0f7a1fc 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -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]; } From f8f42cee824a57adc8fdf34b68216fe1786385cc Mon Sep 17 00:00:00 2001 From: Xymph Date: Thu, 26 Aug 2021 17:33:54 +0200 Subject: [PATCH 2/2] Fix stray error return in WikiPage::setText() --- CHANGELOG.md | 4 ++++ Wikimate.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 378bef1..743bf59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ 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]) diff --git a/Wikimate.php b/Wikimate.php index 0f7a1fc..ee9ba3d 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -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 }