Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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. |
|
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
text_reparser.php
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 if (!is_array($resume_data))
058 {
059 /** @var reparser_interface[] $reparsers */
060 $reparsers = $this->container->get('text_reparser_collection');
061
062 // Initialize all reparsers
063 foreach ($reparsers as $name => $reparser)
064 {
065 $reparser_manager->update_resume_data($name, 1, $reparser->get_max_id(), 100);
066 }
067 }
068
069 // Sometimes a cron job is too much
070 $limit = 100;
071 $fast_reparsers = array(
072 'text_reparser.contact_admin_info',
073 'text_reparser.forum_description',
074 'text_reparser.forum_rules',
075 'text_reparser.group_description',
076 );
077
078 if (!is_array($resume_data))
079 {
080 $resume_data = array(
081 'reparser' => 0,
082 'current' => $this->container->get($fast_reparsers[0])->get_max_id(),
083 );
084 }
085
086 $fast_reparsers_size = count($fast_reparsers);
087 $processed_records = 0;
088 while ($processed_records < $limit && $resume_data['reparser'] < $fast_reparsers_size)
089 {
090 $reparser = $this->container->get($fast_reparsers[$resume_data['reparser']]);
091
092 // New reparser
093 if ($resume_data['current'] === 0)
094 {
095 $resume_data['current'] = $reparser->get_max_id();
096 }
097
098 $start = max(1, $resume_data['current'] + 1 - ($limit - $processed_records));
099 $end = max(1, $resume_data['current']);
100 $reparser->reparse_range($start, $end);
101
102 $processed_records += $end - $start + 1;
103 $resume_data['current'] = $start - 1;
104
105 if ($start === 1)
106 {
107 // Prevent CLI command from running these reparsers again
108 $reparser_manager->update_resume_data($fast_reparsers[$resume_data['reparser']], 1, 0, $limit);
109
110 $resume_data['reparser']++;
111 }
112 }
113
114 if ($resume_data['reparser'] === $fast_reparsers_size)
115 {
116 return true;
117 }
118
119 return $resume_data;
120 }
121 }
122