function testPackData() { $in = array('foo' => 'bar'); $out = MyHome::customDataPrefix . '{"foo":"bar"}'; $this->assertEquals($out, MyHome::packData($in)); }
/** * Given an associative array of data to store, adds this to additional data and updates * the row in recentchanges corresponding to the provided RecentChange (or, if rc is not * provided, then the RecentChange that is stored in Wikia::getVar('rc') will be used); */ public static function storeAdditionalRcData($additionalData, &$rc = null) { wfProfileIn(__METHOD__); $rc_data = Wikia::getVar('rc_data'); $rc_data = $rc_data ? $rc_data : array(); // rc_data might not have been set $rc_data = array_merge($rc_data, $additionalData); // additionalData overwrites existing keys in rc_data if there are collisions. if (!is_object($rc)) { $rc = Wikia::getVar('rc'); } if ($rc instanceof RecentChange) { /* @var $rc RecentChange */ $rc_id = $rc->getAttribute('rc_id'); $rc_log_type = $rc->getAttribute('rc_log_type'); if (!in_array($rc_log_type, self::$additionalRcDataBlacklist)) { $dbw = wfGetDB(DB_MASTER); $dbw->update('recentchanges', array('rc_params' => MyHome::packData($rc_data)), array('rc_id' => $rc_id), __METHOD__); } } Wikia::setVar('rc_data', $rc_data); wfProfileOut(__METHOD__); }