Exemplo n.º 1
0
 function bootstrap_and_dispatch()
 {
     $phases = _drush_bootstrap_phases(FALSE, TRUE);
     $return = '';
     $command_found = FALSE;
     _drush_bootstrap_output_prepare();
     foreach ($phases as $phase) {
         if (drush_bootstrap_to_phase($phase)) {
             $command = drush_parse_command();
             if (is_array($command)) {
                 $bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
                 drush_enforce_requirement_bootstrap_phase($command);
                 drush_enforce_requirement_core($command);
                 drush_enforce_requirement_drupal_dependencies($command);
                 drush_enforce_requirement_drush_dependencies($command);
                 if ($bootstrap_result && empty($command['bootstrap_errors'])) {
                     drush_log(dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])), 'bootstrap');
                     $command_found = TRUE;
                     // Dispatch the command(s).
                     $return = drush_dispatch($command);
                     // Prevent a '1' at the end of the output.
                     if ($return === TRUE) {
                         $return = '';
                     }
                     if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
                         // @todo Create version independant wrapper around Drupal timers. Use it.
                         drush_print_timers();
                     }
                     break;
                 }
             }
         } else {
             break;
         }
     }
     if (!$command_found) {
         // If we reach this point, command doesn't fit requirements or we have not
         // found either a valid or matching command.
         // If no command was found check if it belongs to a disabled module.
         if (!$command) {
             $command = drush_command_belongs_to_disabled_module();
         }
         // Set errors related to this command.
         $args = implode(' ', drush_get_arguments());
         if (isset($command) && is_array($command)) {
             foreach ($command['bootstrap_errors'] as $key => $error) {
                 drush_set_error($key, $error);
             }
             drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The drush command '!args' could not be executed.", array('!args' => $args)));
         } elseif (!empty($args)) {
             drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!args' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.", array('!args' => $args)));
         }
         // Set errors that occurred in the bootstrap phases.
         $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
         foreach ($errors as $code => $message) {
             drush_set_error($code, $message);
         }
     }
     return $return;
 }
Exemplo n.º 2
0
 function bootstrap_and_dispatch()
 {
     $phases = $this->bootstrap_init_phases();
     $return = '';
     $command_found = FALSE;
     _drush_bootstrap_output_prepare();
     foreach ($phases as $phase) {
         if (drush_bootstrap_to_phase($phase)) {
             $command = drush_parse_command();
             if (is_array($command)) {
                 $command += $this->command_defaults();
                 // Insure that we have bootstrapped to a high enough
                 // phase for the command prior to enforcing requirements.
                 $bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
                 $this->enforce_requirement($command);
                 if ($bootstrap_result && empty($command['bootstrap_errors'])) {
                     $this->logger->log(LogLevel::BOOTSTRAP, dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])));
                     $command_found = TRUE;
                     // Dispatch the command(s).
                     $return = drush_dispatch($command);
                     if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
                         // @todo Create version independant wrapper around Drupal timers. Use it.
                         drush_print_timers();
                     }
                     break;
                 }
             }
         } else {
             break;
         }
     }
     // TODO: If we could not find a legacy Drush command, try running a
     // command via the Symfony application. See also drush_main() in preflight.inc;
     // ultimately, the Symfony application should be called from there.
     if (!$command_found && isset($command)) {
         $container = \Drush::getContainer();
         $application = $container->get('application');
         $args = drush_get_arguments();
         if (count($args)) {
             $name = $args[0];
             if ($this->hasRegisteredSymfonyCommand($application, $name)) {
                 $command_found = true;
                 $input = drush_symfony_input();
                 $this->logger->log(LogLevel::BOOTSTRAP, dt("Dispatching with Symfony application as a fallback, since no native Drush command was found. (Set DRUSH_SYMFONY environment variable to skip Drush dispatch.)"));
                 $application->run($input);
             }
         }
     }
     if (!$command_found) {
         // If we reach this point, command doesn't fit requirements or we have not
         // found either a valid or matching command.
         $this->report_command_error($command);
     }
     // Prevent a '1' at the end of the output.
     if ($return === TRUE) {
         $return = '';
     }
     return $return;
 }
Exemplo n.º 3
0
 function report_command_error($command)
 {
     // Set errors related to this command.
     $args = implode(' ', drush_get_arguments());
     if (isset($command) && is_array($command)) {
         foreach ($command['bootstrap_errors'] as $key => $error) {
             drush_set_error($key, $error);
         }
         drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The drush command '!args' could not be executed.", array('!args' => $args)));
     } elseif (!empty($args)) {
         drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!args' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.", array('!args' => $args)));
     }
     // Set errors that occurred in the bootstrap phases.
     $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
     foreach ($errors as $code => $message) {
         drush_set_error($code, $message);
     }
 }
Exemplo n.º 4
0
/**
 * The main Drush function.
 *
 * - Parses the command line arguments, configuration files and environment.
 * - Prepares and executes a Drupal bootstrap, if possible,
 * - Dispatches the given command.
 *
 * @return
 *   Whatever the given command returns.
 */
function drush_main()
{
    $phases = _drush_bootstrap_phases();
    $return = '';
    $command_found = FALSE;
    foreach ($phases as $phase) {
        if (drush_bootstrap($phase)) {
            $command = drush_parse_command();
            if (is_array($command)) {
                if ($command['bootstrap'] == $phase && empty($command['bootstrap_errors'])) {
                    drush_log(dt("Found command: !command", array('!command' => $command['command'])), 'bootstrap');
                    $command_found = TRUE;
                    // Dispatch the command(s).
                    $return = drush_dispatch($command);
                    drush_log_timers();
                    break;
                }
            }
        } else {
            break;
        }
    }
    if (!$command_found) {
        // If we reach this point, we have not found either a valid or matching command.
        $args = implode(' ', drush_get_arguments());
        $drush_command = array_pop(explode('/', DRUSH_COMMAND));
        if (isset($command) && is_array($command)) {
            foreach ($command['bootstrap_errors'] as $key => $error) {
                drush_set_error($key, $error);
            }
            drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The command '!drush_command !args' could not be executed.", array('!drush_command' => $drush_command, '!args' => $args)));
        } elseif (!empty($args)) {
            drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The command '!drush_command !args' could not be found.", array('!drush_command' => $drush_command, '!args' => $args)));
        } else {
            // This can occur if we get an error during _drush_bootstrap_drush_validate();
            drush_set_error('DRUSH_COULD_NOT_EXECUTE', dt("Drush could not execute."));
        }
    }
    // We set this context to let the shutdown function know we reached the end of drush_main();
    drush_set_context("DRUSH_EXECUTION_COMPLETED", TRUE);
    // After this point the drush_shutdown function will run,
    // exiting with the correct exit code.
    return $return;
}
Exemplo n.º 5
0
<?php

function update_body_format($table, $old, $new)
{
    // Get database connection
    \Drupal\Core\Database\Database::setActiveConnection();
    $connection = \Drupal\Core\Database\Database::getConnection();
    // Update the body_format for the specified table
    $results = $connection->update($table)->fields(array('body_format' => $new))->condition('body_format', $old, '=')->execute();
    return $results;
}
$drush_args = drush_get_arguments();
$old_format = $drush_args[2];
$new_format = $drush_args[3];
$results = update_body_format('block_content__body', $old_format, $new_format);
print "Updated body_format for {$results} block(s) from {$old_format} to {$new_format}...\n";
$results = update_body_format('node__body', $old_format, $new_format);
print "Updated body_format for {$results} node(s) from {$old_format} to {$new_format}...\n";
Exemplo n.º 6
0
 /**
  * Check if the given command belongs to a disabled module.
  *
  * @return array
  *   Array with a command-like bootstrap error or FALSE if Drupal was not
  *   bootstrapped fully or the command does not belong to a disabled module.
  */
 function drush_command_belongs_to_disabled_module()
 {
     if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
         _drush_find_commandfiles(DRUSH_BOOTSTRAP_DRUPAL_SITE, DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
         drush_get_commands(TRUE);
         $commands = drush_get_commands();
         $arguments = drush_get_arguments();
         $command_name = array_shift($arguments);
         if (isset($commands[$command_name])) {
             // We found it. Load its module name and set an error.
             if (is_array($commands[$command_name]['drupal dependencies']) && count($commands[$command_name]['drupal dependencies'])) {
                 $modules = implode(', ', $commands[$command_name]['drupal dependencies']);
             } else {
                 // The command does not define Drupal dependencies. Derive them.
                 $command_files = commandfiles_cache()->get();
                 $command_path = $commands[$command_name]['path'] . DIRECTORY_SEPARATOR . $commands[$command_name]['commandfile'] . '.drush.inc';
                 $modules = array_search($command_path, $command_files);
             }
             return array('bootstrap_errors' => array('DRUSH_COMMAND_DEPENDENCY_ERROR' => dt('Command !command needs the following module(s) enabled to run: !dependencies.', array('!command' => $command_name, '!dependencies' => $modules))));
         }
     }
     return FALSE;
 }
Exemplo n.º 7
0
/**
 * The main Drush function.
 *
 * - Parses the command line arguments, configuration files and environment.
 * - Prepares and executes a Drupal bootstrap, if possible,
 * - Dispatches the given command.
 *
 * @return
 *   Whatever the given command returns.
 */
function drush_main()
{
    $phases = _drush_bootstrap_phases(FALSE, TRUE);
    drush_set_context('DRUSH_BOOTSTRAP_PHASE', DRUSH_BOOTSTRAP_NONE);
    // We need some global options processed at this early stage. Namely --debug.
    drush_parse_args();
    _drush_bootstrap_global_options();
    $return = '';
    $command_found = FALSE;
    foreach ($phases as $phase) {
        if (drush_bootstrap_to_phase($phase)) {
            $command = drush_parse_command();
            // Process a remote command if 'remote-host' option is set.
            if (drush_remote_command()) {
                $command_found = TRUE;
                break;
            }
            if (is_array($command)) {
                $bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
                drush_enforce_requirement_bootstrap_phase($command);
                drush_enforce_requirement_core($command);
                drush_enforce_requirement_drupal_dependencies($command);
                drush_enforce_requirement_drush_dependencies($command);
                if ($bootstrap_result && empty($command['bootstrap_errors'])) {
                    drush_log(dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])), 'bootstrap');
                    $command_found = TRUE;
                    // Dispatch the command(s).
                    $return = drush_dispatch($command);
                    // prevent a '1' at the end of the output
                    if ($return === TRUE) {
                        $return = '';
                    }
                    if (drush_get_context('DRUSH_DEBUG')) {
                        drush_print_timers();
                    }
                    drush_log(dt('Peak memory usage was !peak', array('!peak' => drush_format_size(memory_get_peak_usage()))), 'memory');
                    break;
                }
            }
        } else {
            break;
        }
    }
    if (!$command_found) {
        // If we reach this point, we have not found either a valid or matching command.
        $args = implode(' ', drush_get_arguments());
        if (isset($command) && is_array($command)) {
            foreach ($command['bootstrap_errors'] as $key => $error) {
                drush_set_error($key, $error);
            }
            drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The drush command '!args' could not be executed.", array('!args' => $args)));
        } elseif (!empty($args)) {
            drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!args' could not be found.", array('!args' => $args)));
        }
        // Set errors that ocurred in the bootstrap phases.
        $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
        foreach ($errors as $code => $message) {
            drush_set_error($code, $message);
        }
    }
    // We set this context to let the shutdown function know we reached the end of drush_main();
    drush_set_context("DRUSH_EXECUTION_COMPLETED", TRUE);
    // After this point the drush_shutdown function will run,
    // exiting with the correct exit code.
    return $return;
}
Exemplo n.º 8
0
Arquivo: drush.php Projeto: redb/MNPP
function _drush_bootstrap_and_dispatch()
{
    $phases = _drush_bootstrap_phases(FALSE, TRUE);
    $return = '';
    $command_found = FALSE;
    _drush_bootstrap_output_prepare();
    foreach ($phases as $phase) {
        if (drush_bootstrap_to_phase($phase)) {
            $command = drush_parse_command();
            if (is_array($command)) {
                $bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
                drush_enforce_requirement_bootstrap_phase($command);
                drush_enforce_requirement_core($command);
                drush_enforce_requirement_drupal_dependencies($command);
                drush_enforce_requirement_drush_dependencies($command);
                if ($bootstrap_result && empty($command['bootstrap_errors'])) {
                    drush_log(dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])), 'bootstrap');
                    $command_found = TRUE;
                    // Dispatch the command(s).
                    $return = drush_dispatch($command);
                    // prevent a '1' at the end of the output
                    if ($return === TRUE) {
                        $return = '';
                    }
                    if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
                        drush_print_timers();
                    }
                    drush_log(dt('Peak memory usage was !peak', array('!peak' => drush_format_size(memory_get_peak_usage()))), 'memory');
                    break;
                }
            }
        } else {
            break;
        }
    }
    if (!$command_found) {
        // If we reach this point, we have not found either a valid or matching command.
        $args = implode(' ', drush_get_arguments());
        if (isset($command) && is_array($command)) {
            foreach ($command['bootstrap_errors'] as $key => $error) {
                drush_set_error($key, $error);
            }
            drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The drush command '!args' could not be executed.", array('!args' => $args)));
        } elseif (!empty($args)) {
            drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!args' could not be found.", array('!args' => $args)));
        }
        // Set errors that occurred in the bootstrap phases.
        $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
        foreach ($errors as $code => $message) {
            drush_set_error($code, $message);
        }
    }
    return $return;
}
Exemplo n.º 9
0
      [0] => array(
                'collection_id' => '10001',
                'repository_id' => 'A1000001',
                'store'         => '010',
                'files'         => array('10001_001.tif', '10001_002.tif', ...)
             ),
      [1] => array(
                'collection_id' => '10002',
                'repository_id' => 'A10000002',
                'store'         => '010',
                'files'         => array('10002_001.tif', '10002_002.tif', ...)
            ),
      ...
   );
*/
$argv = drush_get_arguments();
$ticket = $argv[2];
//$argc = count($argv);
if (empty($ticket)) {
    mylog('empty ticket', 'mconvert-bug.txt');
    exit(0);
}
$archives = variable_get("archives_for_convert_{$ticket}", array());
if (empty($archives)) {
    mylog('empty archives', 'mconvert-bug.txt');
    variable_del("archives_for_convert_{$ticket}");
    exit(0);
}
variable_del("archives_for_convert_{$ticket}");
$image_format = array('jpg' => NULL, 'jpeg' => NULL, 'png' => NULL, 'tif' => NULL, 'tiff' => NULL, 'bmp' => NULL, 'gif' => NULL);
$video_format = array('mpg' => NULL, 'mpeg' => NULL, 'mp4' => NULL, 'm4p' => NULL, 'w4v' => NULL, 'mp2' => NULL, 'mpe' => NULL, 'mpv' => NULL, 'm2v' => NULL, 'm4v' => NULL, 'webm' => NULL, 'mkv' => NULL, 'flv' => NULL, 'ogv' => NULL, 'ogg' => NULL, 'mov' => NULL, 'qt' => NULL, 'avi' => NULL, 'wmv' => NULL, 'asf' => NULL, 'rm' => NULL, 'rmvb' => NULL, '3gp' => NULL, '3g2' => NULL);
Exemplo n.º 10
0
/**
 * The main Drush function.
 *
 * - Parses the command line arguments, configuration files and environment.
 * - Prepares and executes a Drupal bootstrap, if possible,
 * - Dispatches the given command.
 *
 * @return
 *   Whatever the given command returns.
 */
function drush_main()
{
    $phases = _drush_bootstrap_phases();
    $completed_phases = array();
    $return = '';
    $command_found = FALSE;
    foreach ($phases as $phase) {
        if (drush_bootstrap($phase)) {
            $completed_phases[$phase] = TRUE;
            $command = drush_parse_command();
            // Process a remote command if 'remote-host' option is set.
            if (drush_remote_command()) {
                $command_found = TRUE;
                break;
            }
            if (is_array($command)) {
                if (array_key_exists($command['bootstrap'], $completed_phases) && empty($command['bootstrap_errors'])) {
                    drush_log(dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])), 'bootstrap');
                    $command_found = TRUE;
                    // Dispatch the command(s).
                    $return = drush_dispatch($command);
                    if (drush_get_context('DRUSH_DEBUG')) {
                        drush_print_timers();
                    }
                    drush_log(dt('Peak memory usage was !peak', array('!peak' => drush_format_size(memory_get_peak_usage()))), 'memory');
                    break;
                }
            }
        } else {
            break;
        }
    }
    if (!$command_found) {
        // If we reach this point, we have not found either a valid or matching command.
        $args = implode(' ', drush_get_arguments());
        if (isset($command) && is_array($command)) {
            foreach ($command['bootstrap_errors'] as $key => $error) {
                drush_set_error($key, $error);
            }
            drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The drush command '!args' could not be executed.", array('!args' => $args)));
        } elseif (!empty($args)) {
            drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!args' could not be found.", array('!args' => $args)));
        } else {
            // This can occur if we get an error during _drush_bootstrap_drush_validate();
            drush_set_error('DRUSH_COULD_NOT_EXECUTE', dt("Drush could not execute."));
        }
    }
    // We set this context to let the shutdown function know we reached the end of drush_main();
    drush_set_context("DRUSH_EXECUTION_COMPLETED", TRUE);
    // After this point the drush_shutdown function will run,
    // exiting with the correct exit code.
    return $return;
}