Page MenuHomeGitPull.it

D146.1782239680.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D146.1782239680.diff

diff --git a/include/mw/StaticWikibaseSite.php b/include/mw/StaticWikibaseSite.php
--- a/include/mw/StaticWikibaseSite.php
+++ b/include/mw/StaticWikibaseSite.php
@@ -84,6 +84,38 @@
], $data ) );
}
+ /**
+ * Removes Wikibase claims using the wbremoveclaims API
+ *
+ * You do not need to send the CSRF 'token' and the 'action' parameters.
+ *
+ * @see https://www.wikidata.org/w/api.php?action=help&modules=wbremoveclaims
+ *
+ * @param $data array API data request
+ * @param $claimGUID string containing claim's GUID to be retrieved
+ * using getClaimsInProperty()->getID()
+ * @return mixed
+ */
+ public function removeClaim( $data = [] ) {
+
+ // extends the API arguments adding a 'summary.pre' argument
+ if( isset( $data[ 'summary.pre' ] ) ) {
+ $data[ 'summary' ] = $data[ 'summary.pre' ] . $data[ 'summary' ];
+ unset( $data[ 'summary.pre' ] );
+ }
+
+ // extends the API arguments adding a 'summary.post' argument
+ if( isset( $data[ 'summary.post' ] ) ) {
+ $data[ 'summary' ] .= $data[ 'summary.post' ];
+ unset( $data[ 'summary.post' ] );
+ }
+
+ return $this->post( array_replace( [
+ 'action' => 'wbremoveclaims',
+ 'token' => $this->getToken( \mw\Tokens::CSRF ),
+ ], $data ) );
+ }
+
/**
* Create an empty Wikibase data model related to this site
*
diff --git a/include/wb/DataModel.php b/include/wb/DataModel.php
--- a/include/wb/DataModel.php
+++ b/include/wb/DataModel.php
@@ -526,6 +526,39 @@
return $this->getWikibaseSite()->editEntity( $data );
}
+ /**
+ * Removes Wikibase claims using the wbremoveclaims API
+ *
+ * You do not need to send the CSRF 'token' and the 'action' parameters.
+ *
+ * @see https://www.wikidata.org/w/api.php?action=help&modules=wbremoveclaims
+ *
+ * @param $data array API data request
+ * Allowed extensions:
+ * summary.pre Add something before the summary
+ * summary.post Add something after the summary
+ * @return mixed
+ */
+ public function removeClaim( $data = [] ) {
+
+ // can auto-generate a summary
+ if( !isset( $data['summary'] ) ) {
+ $data['summary'] = $this->getEditSummary();
+ }
+
+ // eventually prefill ID
+ if( !isset( $data['id'] ) ) {
+ $data['id'] = $this->hasEntityID() ? $this->getEntityID() : null;
+ }
+
+ // tell the wiki that a bot is performing the edit
+ if( !isset( $data['bot'] ) ) {
+ $data['bot'] = true;
+ }
+
+ return $this->getWikibaseSite()->removeClaim( $data );
+ }
+
/**
* Static constructor from an associative array
*

File Metadata

Mime Type
text/plain
Expires
Tue, Jun 23, 20:34 (21 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1975588
Default Alt Text
D146.1782239680.diff (2 KB)

Event Timeline