Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change error return values in WikiPage::getSection() and setText() (fixes #116) #129

Merged
merged 2 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])

Comment on lines +19 to +22
Copy link
Collaborator

@waldyrious waldyrious Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aw, come on, don't make me feel bad for requesting these lines to be added in the first commit 😅 (Or at least, have the changelog update as a separate commit to either change.)

Copy link
Collaborator Author

@Xymph Xymph Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No intention to do that, but I'm not sure what you're aiming for. Should I move the getSection changelog entry into the first commit with the code change, or split off something into a third commit? How? Figured something out. Hmm, that didn't work yet.

Ok, I give up, bedtime for me.

Copy link
Collaborator

@waldyrious waldyrious Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I move the getSection changelog entry into the first commit with the code change, or split off something into a third commit?

Either should work. Probably having the changelog in a separate commit is easier, but here's how I'd do both:

  1. git rebase -i master, change the first commit's line in the rebase editor from pick to edit, and when the rebase pauses there, I'd make the change to the changelog and then git commit --amend, git rebase --continue. Hopefully git would automatically detect the duplicated changes in the second commit and simply apply the difference.

or

  1. git reset HEAD~ (which I have aliased to git uncommit, btw) to undo the latest commit and leave its changes in the working directory, then git add Wikimate.php, make the commit, and then git add CHANGELOG.md and make that commit.

Since you're gone and I've given you this trouble, let me see if I can do it myself.

Copy link
Collaborator

@waldyrious waldyrious Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, option 1 worked. Git was smart enough to finish the rebase cleanly for me :) I'll go ahead and merge. Once again, sorry for the trouble! 😅

#### 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;
waldyrious marked this conversation as resolved.
Show resolved Hide resolved
} else {
$this->error = null; // Reset the error status
}
Expand Down