Umherirrender has uploaded a new change for review. https://gerrit.wikimedia.org/r/200317
Change subject: Added LogEntryBase::extractParams/makeParamBlob ...................................................................... Added LogEntryBase::extractParams/makeParamBlob Centralize the serialize and unserialize call in the new logging system into two functions to allow reuse by tests. Change-Id: Ibedca39558cbd566661b20e7ebb9d2b6537e4f24 --- M includes/logging/LogEntry.php 1 file changed, 26 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/17/200317/1 diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index e9b479b..73eeb80 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -115,6 +115,28 @@ public function isLegacy() { return false; } + + /** + * Create a blob from a parameter array + * + * @param array $params + * @return string + * @since 1.25 + */ + public static function makeParamBlob( $params ) { + return serialize( (array)$params ); + } + + /** + * Extract a parameter array from a blob + * + * @param string $blob + * @return array + * @since 1.25 + */ + public static function extractParams( $blob ) { + return unserialize( $blob ); + } } /** @@ -225,13 +247,13 @@ if ( !isset( $this->params ) ) { $blob = $this->getRawParameters(); wfSuppressWarnings(); - $params = unserialize( $blob ); + $params = LogEntryBase::extractParams( $blob ); wfRestoreWarnings(); if ( $params !== false ) { $this->params = $params; $this->legacy = false; } else { - $this->params = $blob === '' ? array() : explode( "\n", $blob ); + $this->params = LogPage::extractParams( $blob ); $this->legacy = true; } } @@ -516,7 +538,7 @@ 'log_title' => $this->getTarget()->getDBkey(), 'log_page' => $this->getTarget()->getArticleID(), 'log_comment' => $comment, - 'log_params' => serialize( (array)$this->getParameters() ), + 'log_params' => LogEntryBase::makeParamBlob( $this->getParameters() ), ); if ( isset( $this->deleted ) ) { $data['log_deleted'] = $this->deleted; @@ -588,7 +610,7 @@ $this->getSubtype(), $this->getTarget(), $this->getComment(), - serialize( (array)$this->getParameters() ), + LogEntryBase::makeParamBlob( $this->getParameters() ), $newId, $formatter->getIRCActionComment() // Used for IRC feeds ); -- To view, visit https://gerrit.wikimedia.org/r/200317 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibedca39558cbd566661b20e7ebb9d2b6537e4f24 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits