Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

text_reparser.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.39 KiB


 001  <?php
 002  /**
 003   *
 004   * This file is part of the phpBB Forum Software package.
 005   *
 006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007   * @license GNU General Public License, version 2 (GPL-2.0)
 008   *
 009   * For full copyright and license information, please see
 010   * the docs/CREDITS.txt file.
 011   *
 012   */
 013   
 014  namespace phpbb\db\migration\data\v320;
 015   
 016  use phpbb\textreparser\manager;
 017  use phpbb\textreparser\reparser_interface;
 018   
 019  class text_reparser extends \phpbb\db\migration\container_aware_migration
 020  {
 021      static public function depends_on()
 022      {
 023          return array(
 024              '\phpbb\db\migration\data\v310\contact_admin_form',
 025              '\phpbb\db\migration\data\v320\allowed_schemes_links',
 026          );
 027      }
 028   
 029      public function effectively_installed()
 030      {
 031          return isset($this->config['reparse_lock']);
 032      }
 033   
 034      public function update_data()
 035      {
 036          return array(
 037              array('config.add', array('reparse_lock', 0, true)),
 038              array('config.add', array('text_reparser.pm_text_cron_interval', 10)),
 039              array('config.add', array('text_reparser.pm_text_last_cron', 0)),
 040              array('config.add', array('text_reparser.poll_option_cron_interval', 10)),
 041              array('config.add', array('text_reparser.poll_option_last_cron', 0)),
 042              array('config.add', array('text_reparser.poll_title_cron_interval', 10)),
 043              array('config.add', array('text_reparser.poll_title_last_cron', 0)),
 044              array('config.add', array('text_reparser.post_text_cron_interval', 10)),
 045              array('config.add', array('text_reparser.post_text_last_cron', 0)),
 046              array('config.add', array('text_reparser.user_signature_cron_interval', 10)),
 047              array('config.add', array('text_reparser.user_signature_last_cron', 0)),
 048              array('custom', array(array($this, 'reparse'))),
 049          );
 050      }
 051   
 052      public function reparse($resume_data)
 053      {
 054          /** @var manager $reparser_manager */
 055          $reparser_manager = $this->container->get('text_reparser.manager');
 056   
 057          /** @var reparser_interface[] $reparsers */
 058          $reparsers = $this->container->get('text_reparser_collection');
 059   
 060          // Initialize all reparsers
 061          foreach ($reparsers as $name => $reparser)
 062          {
 063              $reparser_manager->update_resume_data($name, 1, $reparser->get_max_id(), 100);
 064          }
 065   
 066          // Sometimes a cron job is too much
 067          $limit = 100;
 068          $fast_reparsers = array(
 069              'text_reparser.contact_admin_info',
 070              'text_reparser.forum_description',
 071              'text_reparser.forum_rules',
 072              'text_reparser.group_description',
 073          );
 074   
 075          if (!is_array($resume_data))
 076          {
 077              $resume_data = array(
 078                  'reparser'    => 0,
 079                  'current'    => $this->container->get($fast_reparsers[0])->get_max_id(),
 080              );
 081          }
 082   
 083          $fast_reparsers_size = count($fast_reparsers);
 084          $processed_records = 0;
 085          while ($processed_records < $limit && $resume_data['reparser'] < $fast_reparsers_size)
 086          {
 087              $reparser = $this->container->get($fast_reparsers[$resume_data['reparser']]);
 088   
 089              // New reparser
 090              if ($resume_data['current'] === 0)
 091              {
 092                  $resume_data['current'] = $reparser->get_max_id();
 093              }
 094   
 095              $start = max(1, $resume_data['current'] + 1 - ($limit - $processed_records));
 096              $end = max(1, $resume_data['current']);
 097              $reparser->reparse_range($start, $end);
 098   
 099              $processed_records += $end - $start + 1;
 100              $resume_data['current'] = $start - 1;
 101   
 102              if ($start === 1)
 103              {
 104                  // Prevent CLI command from running these reparsers again
 105                  $reparser_manager->update_resume_data($fast_reparsers[$resume_data['reparser']], 1, 0, $limit);
 106   
 107                  $resume_data['reparser']++;
 108              }
 109          }
 110   
 111          if ($resume_data['reparser'] === $fast_reparsers_size)
 112          {
 113              return true;
 114          }
 115   
 116          return $resume_data;
 117      }
 118  }
 119