Changeset 20544


Ignore:
Timestamp:
02/04/13 12:28:03 (7 years ago)
Author:
plg
Message:

bug 2825: add maintenance action to clean the database and avoid integrity errors

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r19703 r20544  
    482482      set_random_representant($to_rand); 
    483483    } 
     484  } 
     485} 
     486 
     487/** 
     488 * check and repair images integrity 
     489 * 
     490 * TODO see delete_elements function to check all linked tables 
     491 */ 
     492function images_integrity() 
     493{ 
     494  $query = ' 
     495SELECT 
     496    image_id 
     497  FROM '.IMAGE_CATEGORY_TABLE.' 
     498    LEFT JOIN '.IMAGES_TABLE.' ON id = image_id 
     499  WHERE id IS NULL 
     500;'; 
     501  $result = pwg_query($query); 
     502  $orphan_image_ids = array_from_query($query, 'image_id'); 
     503 
     504  if (count($orphan_image_ids) > 0) 
     505  { 
     506    $query = ' 
     507DELETE 
     508  FROM '.IMAGE_CATEGORY_TABLE.' 
     509  WHERE image_id IN ('.implode(',', $orphan_image_ids).') 
     510;'; 
     511    pwg_query($query); 
    484512  } 
    485513} 
  • trunk/admin/maintenance.php

    r19703 r20544  
    6363  case 'categories' : 
    6464  { 
     65    images_integrity(); 
    6566    update_uppercats(); 
    6667    update_category('all'); 
     
    7172  case 'images' : 
    7273  { 
     74    images_integrity(); 
    7375    update_path(); 
    7476                include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php'); 
    7577    update_rating_score(); 
     78    invalidate_user_cache(); 
    7679    break; 
    7780  } 
     
    7982  { 
    8083    delete_orphan_tags(); 
     84    break; 
     85  } 
     86  case 'user_cache' : 
     87  { 
     88    invalidate_user_cache(); 
    8189    break; 
    8290  } 
     
    172180    'U_MAINT_IMAGES' => sprintf($url_format, 'images'), 
    173181    'U_MAINT_ORPHAN_TAGS' => sprintf($url_format, 'delete_orphan_tags'), 
     182    'U_MAINT_USER_CACHE' => sprintf($url_format, 'user_cache'), 
    174183    'U_MAINT_HISTORY_DETAIL' => sprintf($url_format, 'history_detail'), 
    175184    'U_MAINT_HISTORY_SUMMARY' => sprintf($url_format, 'history_summary'), 
  • trunk/admin/themes/default/template/maintenance.tpl

    r18484 r20544  
    2828 
    2929<ul> 
     30        <li><a href="{$U_MAINT_USER_CACHE}">{'Purge user cache'|@translate}</a></li> 
    3031        <li><a href="{$U_MAINT_ORPHAN_TAGS}">{'Delete orphan tags'|@translate}</a></li> 
    3132        <li><a href="{$U_MAINT_HISTORY_DETAIL}" onclick="return confirm('{'Purge history detail'|@translate|@escape:'javascript'}');">{'Purge history detail'|@translate}</a></li> 
  • trunk/language/en_UK/admin.lang.php

    r19703 r20544  
    948948$lang['[%s] Visit album %s'] = "[%s] Visit album %s"; 
    949949$lang['[NBM] Problems or questions'] = "[NBM] Problems or questions"; 
     950$lang['Purge user cache'] = 'Purge user cache'; 
    950951?> 
  • trunk/language/fr_FR/admin.lang.php

    r19703 r20544  
    950950$lang['No members to manage'] = "Aucun membre à gérer"; 
    951951$lang['Rename'] = 'Renommer'; 
    952  
     952$lang['Purge user cache'] = 'Purger le cache utilisateur'; 
    953953?> 
Note: See TracChangeset for help on using the changeset viewer.