Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/59165
Change subject: (Bug 43269) Hash titles in memcached keys
......................................................................
(Bug 43269) Hash titles in memcached keys
This change ensures that the target title is hashed to a fixed length, making
all memcached keys consistently 48 bytes ('shorturls:title:' + 32 byte MD5
hash). The change will also migrate values stored under the old key format.
Change-Id: I386794c46cbd8e203cbc45115a40d8f399e0939b
---
M ShortUrl.utils.php
1 file changed, 17 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ShortUrl
refs/changes/65/59165/1
diff --git a/ShortUrl.utils.php b/ShortUrl.utils.php
index c02d00e..eb6dc8a 100644
--- a/ShortUrl.utils.php
+++ b/ShortUrl.utils.php
@@ -25,8 +25,24 @@
public static function encodeTitle( $title ) {
global $wgMemc;
- $memcKey = wfMemcKey( 'shorturls', 'title',
$title->getPrefixedText() );
+ $memcKey = wfMemcKey( 'shorturls', 'title', md5(
$title->getPrefixedText() ) );
$id = $wgMemc->get( $memcKey );
+
+ // Bug 43269: Some Extension:ShortUrl memcached keys exceed key
length limit
+ // In the past, the title text was not hashed, and thus sometime
+ // exceeded the key length limit. This if-block migrates old
keys.
+ // This can and and should be removed after spending a day or
so in
+ // production.
+ if ( !$id ) {
+ $oldKey = wfMemcKey( 'shorturls', 'title',
$title->getPrefixedText() );
+ $id = $wgMemc->get( $oldKey );
+ if ( $id ) {
+ // Migrate
+ $wgMemc->set( $memcKey, $id, 0 );
+ $wgMemc->delete( $oldKey );
+ }
+ }
+
if ( !$id ) {
$dbr = wfGetDB( DB_SLAVE );
$entry = $dbr->selectRow(
--
To view, visit https://gerrit.wikimedia.org/r/59165
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I386794c46cbd8e203cbc45115a40d8f399e0939b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ShortUrl
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits