Ejemplo n.º 1
0
Archivo: upgrade.php Proyecto: n8b/VMN
/**
 * Returns a list of upgrade files relative to the $upgrade_path dir.
 *
 * @param string $upgrade_path The directory that has upgrade scripts
 * @return array|false
 * @access private
 *
 * @todo the wire and groups plugins and the installer are using this
 */
function elgg_get_upgrade_files($upgrade_path = null)
{
    if (!$upgrade_path) {
        $upgrade_path = elgg_get_root_path() . 'engine/lib/upgrades/';
    }
    $upgrade_path = sanitise_filepath($upgrade_path);
    $handle = opendir($upgrade_path);
    if (!$handle) {
        return false;
    }
    $upgrade_files = array();
    while ($upgrade_file = readdir($handle)) {
        // make sure this is a well formed upgrade.
        if (is_dir($upgrade_path . '$upgrade_file')) {
            continue;
        }
        $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
        if (!$upgrade_version) {
            continue;
        }
        $upgrade_files[] = $upgrade_file;
    }
    sort($upgrade_files);
    return $upgrade_files;
}
Ejemplo n.º 2
0
/**
 * Boot straps into 1.8 upgrade system from 1.7
 *
 * This runs all the 1.7 upgrades, then sets the processed_upgrades to all existing 1.7 upgrades.
 * Control is then passed back to the main upgrade function which detects and runs the
 * 1.8 upgrades, regardless of filename convention.
 *
 * @return bool
 * @access private
 */
function elgg_upgrade_bootstrap_17_to_18()
{
    $db_version = (int) datalist_get('version');
    // the 1.8 upgrades before the upgrade system change that are interspersed with 1.7 upgrades.
    $upgrades_18 = array('2010111501.php', '2010121601.php', '2010121602.php', '2010121701.php', '2010123101.php', '2011010101.php');
    $upgrade_files = elgg_get_upgrade_files();
    $processed_upgrades = array();
    foreach ($upgrade_files as $upgrade_file) {
        // ignore if not in 1.7 format or if it's a 1.8 upgrade
        if (in_array($upgrade_file, $upgrades_18) || !preg_match("/[0-9]{10}\\.php/", $upgrade_file)) {
            continue;
        }
        $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
        // this has already been run in a previous 1.7.X -> 1.7.X upgrade
        if ($upgrade_version < $db_version) {
            $processed_upgrades[] = $upgrade_file;
        }
    }
    return elgg_set_processed_upgrades($processed_upgrades);
}
Ejemplo n.º 3
0
<?php

// Only admin users can run this upgrade
if (!elgg_is_admin_logged_in()) {
    return;
}
$file_version = elgg_get_upgrade_file_version(basename(__FILE__));
$upgrade_version = elgg_get_plugin_setting('upgrade_version', 'tidypics');
if ($upgrade_version and $file_version <= $upgrade_version) {
    return;
}
$db_prefix = elgg_get_config('dbprefix');
$ignore_access = elgg_set_ignore_access(TRUE);
// Count tidypics_batch entities that need to correct the access_id
$options = array('type' => 'object', 'subtype' => 'tidypics_batch', 'limit' => 0, 'count' => TRUE, 'joins' => array("JOIN {$db_prefix}entities e2 ON e2.guid = e.container_guid"), 'wheres' => array("e.access_id <> e2.access_id"));
$tidypics_batch = elgg_get_entities($options);
// If no entities found set upgrade as runned
if (!$tidypics_batch) {
    return elgg_set_plugin_setting('upgrade_version', $file_version, 'tidypics');
}
// Correct the access_id of the tidypics_batch entities
if ($tidypics_batch) {
    $options['count'] = FALSE;
    $batch = new ElggBatch('elgg_get_entities', $options, 'tidypics_2012111901');
    // Correct the acces_id from river itens
    $tidypics_batch_river = elgg_get_river(array('object_guids' => $batch->callbackResult, 'action_types' => 'create', 'types' => 'object', 'subtypes' => 'tidypics_batch', 'limit' => 0));
    tidypics_adjust_river_access_id($tidypics_batch_river);
    error_log("Tidypics batches upgrade (2012111901) succeeded");
}
elgg_set_ignore_access($ignore_access);
// Set upgrade as runned