| Total Complexity | 5 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class m15_reparse_cblocks_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\m5_add_cblocks_schema', |
||
| 24 | ); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @inheritDoc |
||
| 29 | */ |
||
| 30 | public function update_data() |
||
| 31 | { |
||
| 32 | return array( |
||
| 33 | array('custom', array(array($this, 'reparse'))), |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Run the custom block text reparser (see boardrules extension) |
||
| 39 | * |
||
| 40 | * @param int $current A custom block identifier |
||
| 41 | * @return bool|int A custom block identifier or true if finished |
||
| 42 | */ |
||
| 43 | public function reparse($current = 0) |
||
| 44 | { |
||
| 45 | $reparser = new \blitze\sitemaker\migrations\v30x\textreparser\plugins\custom_block_text( |
||
| 46 | $this->db, |
||
| 47 | $this->table_prefix . 'sm_cblocks' |
||
| 48 | ); |
||
| 49 | |||
| 50 | if (empty($current)) |
||
| 51 | { |
||
| 52 | $current = $reparser->get_max_id(); |
||
| 53 | } |
||
| 54 | |||
| 55 | $limit = 50; // lets keep the reparsing conservative |
||
| 56 | $start = max(1, $current + 1 - $limit); |
||
| 57 | $end = max(1, $current); |
||
| 58 | |||
| 59 | $reparser->reparse_range($start, $end); |
||
| 60 | |||
| 61 | $current = $start - 1; |
||
| 62 | |||
| 63 | return ($current === 0) ? true : $current; |
||
| 64 | } |
||
| 66 |