| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class m14_update_settings_data extends \phpbb\db\migration\migration |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @inheritdoc |
||
| 19 | */ |
||
| 20 | public static function depends_on() |
||
| 21 | { |
||
| 22 | return array( |
||
| 23 | '\blitze\sitemaker\migrations\v20x\m7_update_settings_data', |
||
| 24 | ); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @inheritdoc |
||
| 29 | */ |
||
| 30 | public function update_data() |
||
| 31 | { |
||
| 32 | return array( |
||
| 33 | array('custom', array(array($this, 'update_blocks_settings'))), |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function update_blocks_settings() |
||
| 38 | { |
||
| 39 | $result = $this->db->sql_query('SELECT bid, settings FROM ' . $this->table_prefix . "sm_blocks WHERE settings <> ''"); |
||
| 40 | |||
| 41 | while ($row = $this->db->sql_fetchrow($result)) |
||
| 42 | { |
||
| 43 | $settings = json_encode(unserialize($row['settings'])); |
||
| 44 | $sql_data = array( |
||
| 45 | 'settings' => $settings, |
||
| 46 | 'hash' => md5($settings), |
||
| 47 | ); |
||
| 48 | $this->db->sql_query('UPDATE ' . $this->table_prefix . 'sm_blocks SET ' . $this->db->sql_build_array('UPDATE', $sql_data) .' WHERE bid = ' . (int) $row['bid']); |
||
| 49 | } |
||
| 50 | $this->db->sql_freeresult($result); |
||
| 51 | } |
||
| 53 |