"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/admin/module/maint_resync.php" between
wacko.6.1.16.zip and wacko.6.1.17.zip

About: WackoWiki is a multilingual Wiki-engine that supports WYTIWYG-editing, page rights (ACLs), design themes (skins), file upload, email notification and much more.

maint_resync.php  (wacko.6.1.16):maint_resync.php  (wacko.6.1.17)
skipping to change at line 20 skipping to change at line 20
########################################################## ##########################################################
$module['maint_resync'] = [ $module['maint_resync'] = [
'order' => 601, 'order' => 601,
'cat' => 'maintenance', 'cat' => 'maintenance',
'status'=> !RECOVERY_MODE, 'status'=> !RECOVERY_MODE,
]; ];
########################################################## ##########################################################
function admin_maint_resync(&$engine, $module) function admin_maint_resync($engine, $module)
{ {
$prefix = $engine->prefix; $prefix = $engine->prefix;
$batches = [10, 20, 30, 50, 100, 200, 300, 500];
?> ?>
<h1><?php echo $engine->_t($module)['title']; ?></h1> <h1><?php echo $engine->_t($module)['title']; ?></h1>
<br> <br>
<?php <?php
if (isset($_REQUEST['start'])) if (isset($_REQUEST['start']))
{ {
$action = $_REQUEST['action'] ?? null; $action = $_REQUEST['action'] ?? null;
if ($action == 'userstats') if ($action == 'userstats')
{ {
skipping to change at line 192 skipping to change at line 193
// purge body_r field to enforce page re-compiling // purge body_r field to enforce page re-compiling
$engine->db->sql_query("UPDATE " . $prefix . "page SET bo dy_r = ''"); $engine->db->sql_query("UPDATE " . $prefix . "page SET bo dy_r = ''");
$engine->show_message($engine->_t('PreparsedBodyPurged'), 'success'); $engine->show_message($engine->_t('PreparsedBodyPurged'), 'success');
} }
else if ($action == 'wikilinks') else if ($action == 'wikilinks')
{ {
/* TODO: 1) dies if a rendered page throws a fatal error (e.g. action) -> fix broken page, its the last page shown in the list /* TODO: 1) dies if a rendered page throws a fatal error (e.g. action) -> fix broken page, its the last page shown in the list
2) Browser will stop after 20 red irects with: ERR_TOO_MANY_REDIRECTS: There were too many redirects. -> load rece nt url again after error, 2) Browser will stop after 20 red irects with: ERR_TOO_MANY_REDIRECTS: There were too many redirects. -> load rece nt url again after error,
solution: stop after afte r 15 redirects and provide a 'contine' button solution: stop after afte r 15 redirects and provide a 'contine' button
Chrome and Firefox out of the box is 20, Internet Explorer is 10 Chrome and Firefox out of the box is 20
3) if processing breaks see point 1 3) if processing breaks see point 1
- fails with page having a broken action using templates - fails with page having a broken action using templates
4) TIMEOUT or reach of memory lim it - try to reduce the value for the $page_limit parameter 4) TIMEOUT or reach of memory lim it - try to reduce the value for the $page_limit parameter
*/ */
if (isset($_POST['page_limit'])) if (isset($_POST['page_limit']))
{ {
$page_limit = (int) ($_POST['page_limit'] ?? 30); $page_limit = (int) ($_POST['page_limit'] ?? 30);
$engine->sess->resync_limit = (in_array($page _limit, [10, 20, 30, 50, 100, 200, 300, 500])) ? $page_limit : 30; $engine->sess->resync_limit = (in_array($page _limit, $batches)) ? $page_limit : 30;
} }
$limit = $engine->sess->resync_limit; $limit = $engine->sess->resync_limit;
$engine->sess->resync_batch = $engine->sess-> resync_batch ?? 1; $engine->sess->resync_batch = $engine->sess-> resync_batch ?? 1;
$recompile = 0; $recompile = 0;
$redirects = 10; $redirects = 10;
@set_time_limit(1800); @set_time_limit(1800);
if (isset($_POST['recompile_page']) && $_POST['recompile_ page'] == 1) if (isset($_POST['recompile_page']) && $_POST['recompile_ page'] == 1)
skipping to change at line 242 skipping to change at line 243
{ {
$engine->db->sql_query("UPDATE " . $prefi x . "page SET body_toc = ''"); $engine->db->sql_query("UPDATE " . $prefi x . "page SET body_toc = ''");
$engine->db->sql_query("UPDATE " . $prefi x . "page SET body_r = ''"); $engine->db->sql_query("UPDATE " . $prefi x . "page SET body_r = ''");
} }
} }
// do not allow automatic redirection by action {{redirec t}} // do not allow automatic redirection by action {{redirec t}}
$engine->set_user_setting('dont_redirect', 1, 0); $engine->set_user_setting('dont_redirect', 1, 0);
if ($pages = $engine->db->load_all( if ($pages = $engine->db->load_all(
"SELECT a.page_id, a.tag, a.body, a.body_r, a.body_toc, a "SELECT a.page_id, a.tag, a.body, a.body_r, a.body_toc, a
.comment_on_id, a.allow_rawhtml, a.disable_safehtml, " . .comment_on_id, a.page_lang, a.allow_rawhtml, a.disable_safehtml, a.typografica,
"b.tag AS comment_on_tag, b.allow_rawhtml AS pare " .
nt_allow_rawhtml, b.disable_safehtml AS parent_disable_safehtml " . "b.tag AS comment_on_tag, b.allow_rawhtml AS pare
nt_allow_rawhtml, b.disable_safehtml AS parent_disable_safehtml, b.typografica A
S parent_typografica " .
"FROM " . $prefix . "page a " . "FROM " . $prefix . "page a " .
"LEFT JOIN " . $prefix . "page b ON (a.comment_on _id = b.page_id) " . "LEFT JOIN " . $prefix . "page b ON (a.comment_on _id = b.page_id) " .
"ORDER BY a.tag COLLATE utf8mb4_unicode_520_ci " . "ORDER BY a.tag COLLATE utf8mb4_unicode_520_ci " .
"LIMIT " . ($i * $limit) . ", $limit")) "LIMIT " . ($i * $limit) . ", $limit"))
{ {
$engine->sess->resync_links .= '<br>##### ' . dat e('H:i:s') . ' --> ' . ($i + 1) . " #########################################\n\ n"; $engine->sess->resync_links .= '<br>##### ' . dat e('H:i:s') . ' --> ' . ($i + 1) . " #########################################\n\ n";
foreach ($pages as $n => $page) foreach ($pages as $n => $page)
{ {
$record = (($i * $limit) + $n + 1); $record = (($i * $limit) + $n + 1);
$engine->sess->resync_links .= $record . '. ' . $page['tag'] . "\n"; $engine->sess->resync_links .= $record . '. ' . $page['tag'] . "\n";
// find last rendered page // find last rendered page
# Diag::dbg('GOLD', $record, $page['tag'] ); # Diag::dbg('GOLD', $record, $page['tag'] );
// formatter needs these values, comment requires settings from parent page // formatter needs these values, comment requires settings from parent page
$engine->db->allow_rawhtml = ($page['comment_on_id'] ? $page['parent_allow_rawhtml'] : $page[' allow_rawhtml']); $engine->db->allow_rawhtml = ($page['comment_on_id'] ? $page['parent_allow_rawhtml'] : $page[' allow_rawhtml']);
$engine->db->disable_safehtml = ($page[ 'comment_on_id'] ? $page['parent_disable_safehtml'] : $page['disable_safehtml ']); $engine->db->disable_safehtml = ($page[ 'comment_on_id'] ? $page['parent_disable_safehtml'] : $page['disable_safehtml ']);
$engine->db->typografica = ($page['comment_on_id'] ? $page['parent_typografica'] : $page[' typografica']);
// setting context // setting context
$engine->context[++$engine->current_conte xt] = ($page['comment_on_id'] ? $page['comment_on_tag'] : $page['tag']); $engine->context[++$engine->current_conte xt] = ($page['comment_on_id'] ? $page['comment_on_tag'] : $page['tag']);
// recompile if necessary // recompile if necessary
if ($page['body_r'] == '') if ($page['body_r'] == '')
{ {
$paragrafica = !$page['comment $engine->resync_page_id =
_on_id']; $page['page_id'];
$page['body_r'] = $engine->compil $engine->resync_page_lang =
e_body($page['body'], $page['page_id'], $paragrafica, true); $page['page_lang'];
$paragrafica
= !$page['comment_on_id'];
$page['body_r']
= $engine->compile_body($page['body'], $page['page_id'], $paragrafica, tr
ue);
} }
// rendering links // rendering links
$engine->update_link_table($page['page_id '], $page['body_r']); $engine->update_link_table($page['page_id '], $page['body_r']);
$engine->current_context--; $engine->current_context--;
} }
#Diag::dbg('GOLD', $i, $engine->sess->resync_coun ter); #Diag::dbg('GOLD', $i, $engine->sess->resync_coun ter);
// TODO: Fix or workaround, see notice above // redirect limit workaround, see notice above
if ($i < ($redirects + ($engine->sess->resync_cou nter))) if ($i < ($redirects + ($engine->sess->resync_cou nter)))
{ {
$engine->http->redirect($engine->href('', '', ['start' => 1, 'action' => 'wikilinks', 'i' => (++$i)])); $engine->http->redirect($engine->href('', '', ['start' => 1, 'action' => 'wikilinks', 'i' => (++$i)]));
} }
else else
{ {
// show next » link to compile the follow ing batch
$engine->sess->resync_counter = $i + 1 ; $engine->sess->resync_counter = $i + 1 ;
$engine->sess->resync_batch = $engine->sess->resync_batch + 1; $engine->sess->resync_batch = $engine->sess->resync_batch + 1;
$message = $engine->_t('ParseNextBatch') . ' #' . $engine->sess->resync_batch . ' ' . $message = $engine->_t('ParseNextBatch') . ' #' . $engine->sess->resync_batch . ' ' .
'<a href="' . $engine->href('', ' ', ['start' => 1, 'action' => 'wikilinks', 'i' => (++$i)]) . '"' . '>' . $engine ->_t('Next') . ' »</a>' . '<a href="' . $engine->href('', ' ', ['start' => 1, 'action' => 'wikilinks', 'i' => (++$i)]) . '"' . '>' . $engine ->_t('Next') . ' »</a>' .
"<br>\n"; "<br>\n";
$engine->show_message($message); $engine->show_message($message);
} }
} }
else else
{ {
skipping to change at line 381 skipping to change at line 386
<h2><?php echo $engine->_t('WikiLinksResync');?></h2> <h2><?php echo $engine->_t('WikiLinksResync');?></h2>
<p><?php echo $engine->_t('WikiLinksResyncInfo');?></p> <p><?php echo $engine->_t('WikiLinksResyncInfo');?></p>
<?php <?php
echo $engine->form_open('linksupdate'); echo $engine->form_open('linksupdate');
?> ?>
<input type="hidden" name="action" value="wikilinks"> <input type="hidden" name="action" value="wikilinks">
<br> <br>
<strong><small><?php echo $engine->_t('ResyncOptions');?>:</small ></strong><br> <strong><small><?php echo $engine->_t('ResyncOptions');?>:</small ></strong><br>
<select id="page_limit" name="page_limit"> <select id="page_limit" name="page_limit">
<option value="10">10</option> <?php
<option value="20">20</option> foreach ($batches as $value)
<option value="30">30</option> {
<option value="50" selected>50</option> echo '<option value="' . $value . '"' . ($value == 50 ? '
<option value="100">100</option> selected' : '') . '>' . $value . '</option>';
<option value="200">200</option> }
<option value="300">300</option> ?>
<option value="500">500</option>
</select> </select>
<label for="page_limit"><small><?php echo $engine->_t('RecompileP ageLimit');?></small></label><br><br> <label for="page_limit"><small><?php echo $engine->_t('RecompileP ageLimit');?></small></label><br><br>
<input type="checkbox" id="recompile_page" name="recompile_page" value="1"> <input type="checkbox" id="recompile_page" name="recompile_page" value="1">
<label for="recompile_page"><small><?php echo $engine->_t('Recomp ilePage');?></small></label><br><br> <label for="recompile_page"><small><?php echo $engine->_t('Recomp ilePage');?></small></label><br><br>
<button type="submit" name="start" id="submit_wikilinks"><?php ec ho $engine->_t('Synchronize');?></button> <button type="submit" name="start" id="submit_wikilinks"><?php ec ho $engine->_t('Synchronize');?></button>
<?php <?php
echo $engine->form_close(); echo $engine->form_close();
} }
 End of changes. 10 change blocks. 
20 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)