jenkins-bot has submitted this change and it was merged.
Change subject: Hotfix: Make Special:SetSiteLink not set already used Links
......................................................................
Hotfix: Make Special:SetSiteLink not set already used Links
Besides: fixed edit link in ItemView class to Special:SetSitelink
This leaves error message parsing slightly broken, but
that's a different matter.
Change-Id: Iaa3d0718efa34db08c770ca1eb768560ff0e37a0
---
M repo/Wikibase.i18n.php
M repo/includes/ItemView.php
M repo/includes/specials/SpecialSetSiteLink.php
3 files changed, 25 insertions(+), 6 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php
index c2ca27f..3f00112 100644
--- a/repo/Wikibase.i18n.php
+++ b/repo/Wikibase.i18n.php
@@ -175,6 +175,8 @@
'wikibase-setsitelink-submit' => 'Set the site link',
'wikibase-setsitelink-warning-remove' => 'Do you really want to remove
the site link of [[$1]]?',
'wikibase-setsitelink-invalid-site' => 'The site id "$1" is unknown.
Please use an existing site id, such as "enwiki".',
+ 'wikibase-setsitelink-add-failed' => 'The site link could not be
saved.',
+ 'wikibase-setsitelink-remove-failed' => 'The site link could not be
removed.',
'wikibase-setentity-id' => 'ID:',
'wikibase-setentity-language' => 'Language:',
'wikibase-setentity-invalid-langcode' => 'The language identifier "$1"
is unknown. Please use a language identifier known to the system, such as
"en".',
@@ -784,6 +786,8 @@
Parameters:
* $1 - the invalid id',
+ 'wikibase-setsitelink-add-failed' => 'Error message when the site link
could not be saved.',
+ 'wikibase-setsitelink-remove-failed' => 'Error message when the site
link could not be removed.',
'wikibase-setentity-id' => 'Label for the input field to select the ID
of the entity.
{{Identical|ID}}',
'wikibase-setentity-language' => 'Label for the input field to select
the language the label should be set in.
diff --git a/repo/includes/ItemView.php b/repo/includes/ItemView.php
index 59a7e66..d9163c0 100644
--- a/repo/includes/ItemView.php
+++ b/repo/includes/ItemView.php
@@ -99,6 +99,7 @@
} else {
$languageCode = $site->getLanguageCode();
+ $siteId = $site->getGlobalId();
// TODO: for non-JS, also set the dir attribute
on the link cell;
// but do not build language objects for each
site since it causes too much load
@@ -110,7 +111,7 @@
htmlspecialchars( $languageCode ), //
TODO: get an actual site id rather then just the language code
htmlspecialchars( $link->getUrl() ),
htmlspecialchars( $link->getPage() ),
- $this->getHtmlForEditSection( $item,
$lang, $editLink . '/' . $languageCode, 'td' )
+ $this->getHtmlForEditSection( $item,
$lang, $editLink . '/' . $siteId, 'td' )
);
}
}
diff --git a/repo/includes/specials/SpecialSetSiteLink.php
b/repo/includes/specials/SpecialSetSiteLink.php
index f6fd866..40a7c27 100644
--- a/repo/includes/specials/SpecialSetSiteLink.php
+++ b/repo/includes/specials/SpecialSetSiteLink.php
@@ -257,18 +257,32 @@
return $status;
}
- if ( $siteObject->normalizePageName( $page ) === false && $page
!== '' ) {
- $status->error( 'wikibase-error-ui-no-external-page' );
- return $status;
+ if ( $page !== '' ) {
+ // Don't try to normalize an empty string (which means:
remove the link)
+ $page = $siteObject->normalizePageName( $page );
+
+ if ( $page === false ) {
+ $status->error(
'wikibase-error-ui-no-external-page' );
+ return $status;
+ }
}
if ( $page === '' ) {
- $entityContent->getEntity()->removeSitelink( $site );
+ $link = $entityContent->getItem()->getSiteLink( $site );
+ if ( !$link ) {
+ $status->error(
'wikibase-setsitelink-remove-failed' );
+ return $status;
+ }
+ $entityContent->getItem()->removeSitelink( $site );
$i18n = 'wbsetsitelink-remove';
}
else {
$siteLink = new SiteLink( $siteObject, $page );
- $entityContent->getEntity()->addSiteLink( $siteLink,
'set' );
+ $ret = $entityContent->getItem()->addSiteLink(
$siteLink, 'set' );
+ if ( $ret === false ) {
+ $status->error(
'wikibase-setsitelink-add-failed' );
+ return $status;
+ }
$i18n = 'wbsetsitelink-set';
}
$summary = $this->getSummary( $site, $page, $i18n ); //
$summary is passed by reference ( &$summary )
--
To view, visit https://gerrit.wikimedia.org/r/67862
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaa3d0718efa34db08c770ca1eb768560ff0e37a0
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits