Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/54641
Change subject: Left-pad legacy aft_id values with null-bytes, instead of
right-padding
......................................................................
Left-pad legacy aft_id values with null-bytes, instead of right-padding
Change-Id: I2e9b0e2014b0f4a70c87c39817cd6d955de020cb
---
M ArticleFeedbackv5.backend.LBFactory.php
M ArticleFeedbackv5.hooks.php
A sql/aft_id_pad_left.sql
3 files changed, 18 insertions(+), 4 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5
refs/changes/41/54641/1
diff --git a/ArticleFeedbackv5.backend.LBFactory.php
b/ArticleFeedbackv5.backend.LBFactory.php
index 55c6e4b..edfe2b1 100644
--- a/ArticleFeedbackv5.backend.LBFactory.php
+++ b/ArticleFeedbackv5.backend.LBFactory.php
@@ -201,6 +201,6 @@
* @return string
*/
protected function standardizeId( $id ) {
- return str_pad( $id, 32, chr( 0 ) );
+ return str_pad( $id, 32, chr( 0 ), STR_PAD_LEFT );
}
}
diff --git a/ArticleFeedbackv5.hooks.php b/ArticleFeedbackv5.hooks.php
index 7911c21..9ba75a4 100644
--- a/ArticleFeedbackv5.hooks.php
+++ b/ArticleFeedbackv5.hooks.php
@@ -33,11 +33,10 @@
dirname( __FILE__ ) . '/sql/index_user_data.sql'
);
- $updater->modifyField(
+ $updater->modifyExtensionField(
'aft_article_feedback',
'af_user_ip',
- dirname( __FILE__ ) . '/sql/userip_length.sql',
- true
+ dirname( __FILE__ ) . '/sql/userip_length.sql'
);
// move all data from old schema to new, sharded, schema
@@ -73,6 +72,12 @@
dirname( __FILE__ ) . '/sql/inappropriate.sql'
);
+ $updater->modifyExtensionField(
+ 'aft_feedback',
+ 'aft_id',
+ dirname( __FILE__ ) . '/sql/aft_id_pad_left.sql'
+ );
+
return true;
}
diff --git a/sql/aft_id_pad_left.sql b/sql/aft_id_pad_left.sql
new file mode 100644
index 0000000..cf2a120
--- /dev/null
+++ b/sql/aft_id_pad_left.sql
@@ -0,0 +1,9 @@
+-- legacy AFTv5 entries had auto-incrementing ids
+-- current entries' ids are built using UIDGenerator::newTimestampedUID128( 16
)
+-- both will result in a value that increases as time increases, but to make
+-- sure that such id-based sort resembles a time-based sort, we have to
+-- left-pad the legacy entries with null bytes (instead of right-pad, in which
+-- case 789\0\0\0\0\0\0... would be > than 45b6e2349...)
+-- Even only to accurately sort the legacy ids, this needs to be done, or
+-- 123\0\0\0\0\0\0 would be < than 45\0\0\0\0\0\0\0
+UPDATE aft_feedback SET aft_id = LPAD(TRIM(TRAILING CHAR(0x00) FROM aft_id),
32, "\0");
--
To view, visit https://gerrit.wikimedia.org/r/54641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e9b0e2014b0f4a70c87c39817cd6d955de020cb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits