From 2f7991d1e7c74502b65c8ea2b43e5608af8c926d Mon Sep 17 00:00:00 2001 From: Xymph Date: Thu, 1 Jul 2021 10:47:01 +0200 Subject: [PATCH 1/6] Correct error key in token method --- Wikimate.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Wikimate.php b/Wikimate.php index 087f7be..b799961 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -75,7 +75,7 @@ protected function token($type = self::TOKEN_DEFAULT) // Check for supported token types if ($type != self::TOKEN_DEFAULT && $type != self::TOKEN_LOGIN) { $this->error = array(); - $this->error['login'] = 'The API does not support the token type'; + $this->error['token'] = 'The API does not support the token type'; return false; } @@ -91,7 +91,7 @@ protected function token($type = self::TOKEN_DEFAULT) // Check if we got an API result or the API doc page (invalid request) if (strpos($response->body, "This is an auto-generated MediaWiki API documentation page") !== false) { $this->error = array(); - $this->error['login'] = 'The API could not understand the token request'; + $this->error['token'] = 'The API could not understand the token request'; return false; } @@ -99,7 +99,7 @@ protected function token($type = self::TOKEN_DEFAULT) // Check if we got a JSON result if ($tokenResult === null) { $this->error = array(); - $this->error['login'] = 'The API did not return the token response'; + $this->error['token'] = 'The API did not return the token response'; return false; } From b935d45d93c82a293d1f85a172c1d88d6fb7068d Mon Sep 17 00:00:00 2001 From: Xymph Date: Fri, 2 Jul 2021 09:39:09 +0200 Subject: [PATCH 2/6] Add API link to token() info --- Wikimate.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Wikimate.php b/Wikimate.php index b799961..5a5a40f 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -66,6 +66,8 @@ protected function initRequests() * For now this method, in Wikimate tradition, is kept simple and supports * only the two token types needed elsewhere in the library. It also * doesn't support the option to request multiple tokens at once. + * See https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tokens + * for more information. * * @param string $type The token type * @return string The requested token From 52f02a8c229f052070ecfef2f52c4cf3e78a86e3 Mon Sep 17 00:00:00 2001 From: Xymph Date: Fri, 2 Jul 2021 12:46:54 +0200 Subject: [PATCH 3/6] Fix capitalization of PHP default class --- Wikimate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wikimate.php b/Wikimate.php index 5a5a40f..6134127 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -610,7 +610,7 @@ public function getNumSections() /** * Returns the sections offsets and lengths. * - * @return StdClass Section class + * @return stdClass Section class */ public function getSectionOffsets() { From 9d40318d96017d5e2ff4fc92c0347508d461434b Mon Sep 17 00:00:00 2001 From: Xymph Date: Fri, 2 Jul 2021 14:44:05 +0200 Subject: [PATCH 4/6] Fix decoding of PHP format in debug logging --- Wikimate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wikimate.php b/Wikimate.php index 6134127..3ef3c70 100644 --- a/Wikimate.php +++ b/Wikimate.php @@ -301,7 +301,7 @@ public function parse($array) if ($this->debugMode) { echo "parse GET response:\n"; - print_r(json_decode($apiResult->body)); + print_r(unserialize($apiResult->body)); } return unserialize($apiResult->body); } From 8c8edbfc111a915c1df23239ab9a6e6e5fb006ed Mon Sep 17 00:00:00 2001 From: Xymph Date: Sun, 4 Jul 2021 12:53:37 +0200 Subject: [PATCH 5/6] Update USAGE for changed token handling --- USAGE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/USAGE.md b/USAGE.md index 255ba15..fc2ce4f 100644 --- a/USAGE.md +++ b/USAGE.md @@ -300,6 +300,7 @@ print_r($page->getError()); For MediaWiki API errors, the array contains the 'code' and 'info' key/value pairs [defined by the API](https://www.mediawiki.org/wiki/API:Errors_and_warnings#Errors). For other errors, the following key/value pairs are returned: * 'login' for Wikimate authentication problems +* 'token' for Wikimate token problems * 'page' for WikiPage errors * 'file' for WikiFile errors @@ -309,7 +310,6 @@ You can use the edit and query commands in Wikimate: ```php $data = array( 'prop' => 'info|revisions', - 'intoken' => 'edit', 'titles' => 'this|that|other' ); @@ -318,7 +318,6 @@ $array_result = $wiki->query($data); $data = array( 'title' => 'this', - 'token' => '+\\', // this is urlencoded automatically 'etc' => 'stuff' ); From a8bdcfabf97d07e6f99efa743808489546cc031e Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Sun, 4 Jul 2021 22:19:13 +0100 Subject: [PATCH 6/6] Add changelog entry for fixes --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f16138e..77407c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,17 @@ Since v0.10.0 this project adheres to [Semantic Versioning](http://semver.org/) #### Added -* Added more debug logging of MediaWiki requests and responses ([#101]) +* Added more debug logging of MediaWiki requests and responses ([#101], [#106]) * New GOVERNANCE.md file to explicitly codify the project management principles and provide guidelines for maintenance tasks ([#83], [#105]) #### Changed -* Modernize token handling for login and data-modifying actions ([#100]) +* Modernize token handling for login and data-modifying actions ([#100], [#106]) #### Fixed * Prevented PHP notice in `WikiFile::getInfo()` for moved or deleted file ([#85]) +* Fixed capitalization of a built-in PHP class in a comment ([#106]) ### Version 0.12.0 - 2017-02-03 @@ -107,3 +108,4 @@ Since v0.10.0 this project adheres to [Semantic Versioning](http://semver.org/) [#100]: https://github.com/hamstar/Wikimate/pull/100 [#101]: https://github.com/hamstar/Wikimate/pull/101 [#105]: https://github.com/hamstar/Wikimate/pull/105 +[#106]: https://github.com/hamstar/Wikimate/pull/106