b2evolution PHP Cross Reference Blogging Systems

Source: /inc/cron/jobs/_heavy_db_maintenance.job.php - 54 lines - 1789 bytes - Text - Print

Description: This file implements the test Cron controller

   1  <?php
   2  /**

   3   * This file implements the test Cron controller

   4   *

   5   * @author fplanque: Francois PLANQUE

   6   *

   7   * @version $Id: _heavy_db_maintenance.job.php 9 2011-10-24 22:32:00Z fplanque $

   8   */
   9  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  10  
  11  global $dbm_tables_count;
  12  
  13  load_funcs('tools/model/_dbmaintenance.funcs.php');
  14  
  15  $simple_keys = array( 0, 1, 2, 3 );
  16  $failed_results = array();
  17  
  18  // Execute query to get results of CHECK command

  19  $results = dbm_check_tables( false, false );
  20  
  21  foreach( $results as $result )
  22  {
  23      if( $result->Msg_type != 'status' )
  24      { // Add different result types then 'status' to the failed resulsts array, so they can be display on the cron task view
  25          // Convert keys to simple integer values to decrease a size of the data

  26          $failed_results[] = array_combine( $simple_keys, (array)$result );
  27      }
  28  }
  29  
  30  // Optimize MyISAM & InnoDB tables

  31  $results = dbm_optimize_tables( false, false );
  32  
  33  foreach( $results as $result )
  34  {
  35      if( $result->Msg_text != 'OK' && ( ! ( $result->Msg_type == 'note' && $result->Msg_text == 'Table does not support optimize, doing recreate + analyze instead' ) ) )
  36      { // Save only results which are not OK and they are different notes then 'Table does not support optimize ...' because that is normal for innoDb tables
  37          // Convert keys to simple integer values to decrease a size of the data

  38          $failed_results[] = array_combine( $simple_keys, (array)$result );
  39      }
  40  }
  41  
  42  $result_message = array(
  43      'message' => sprintf( T_('The commands CHECK & OPTIMIZE have been executed for all %d tables.'), $dbm_tables_count ),
  44      'table_cols' => array(
  45          T_('Table'),
  46          T_('Operation'),
  47          T_('Result'),
  48          T_('Message ')
  49      ),
  50      'table_data' => $failed_results
  51  );
  52  
  53  return 1; /* ok */
  54  ?>

title

Description

title

Description

title

Description

title

title

Body