Browse Source

removed drush from git. Drush must be installed on machine, not in drupal.

DEV-updatecore
Bèr Kessels 12 years ago
parent
commit
9243b8ec60
26 changed files with 0 additions and 8645 deletions
  1. 0
    274
      sites/localhost/modules/drush/LICENSE.txt
  2. 0
    125
      sites/localhost/modules/drush/README.txt
  3. 0
    441
      sites/localhost/modules/drush/commands/core/core.drush.inc
  4. 0
    120
      sites/localhost/modules/drush/commands/core/drupal/update_5.inc
  5. 0
    458
      sites/localhost/modules/drush/commands/core/drupal/update_6.inc
  6. 0
    616
      sites/localhost/modules/drush/commands/core/drupal/update_7.inc
  7. 0
    107
      sites/localhost/modules/drush/commands/pm/package_handler/cvs.inc
  8. 0
    69
      sites/localhost/modules/drush/commands/pm/package_handler/wget.inc
  9. 0
    831
      sites/localhost/modules/drush/commands/pm/pm.drush.inc
  10. 0
    86
      sites/localhost/modules/drush/commands/pm/update_info/drupal_5.inc
  11. 0
    86
      sites/localhost/modules/drush/commands/pm/update_info/drupal_6.inc
  12. 0
    285
      sites/localhost/modules/drush/commands/pm/updatecode.inc
  13. 0
    91
      sites/localhost/modules/drush/commands/pm/version_control/svn.inc
  14. 0
    109
      sites/localhost/modules/drush/commands/simpletest/simpletest.drush.inc
  15. 0
    442
      sites/localhost/modules/drush/commands/sql/sql.drush.inc
  16. 0
    44
      sites/localhost/modules/drush/drush
  17. 0
    1
      sites/localhost/modules/drush/drush.bat
  18. 0
    198
      sites/localhost/modules/drush/drush.php
  19. 0
    83
      sites/localhost/modules/drush/example.drush.inc
  20. 0
    80
      sites/localhost/modules/drush/example.drushrc.php
  21. 0
    443
      sites/localhost/modules/drush/includes/backend.inc
  22. 0
    606
      sites/localhost/modules/drush/includes/command.inc
  23. 0
    399
      sites/localhost/modules/drush/includes/context.inc
  24. 0
    943
      sites/localhost/modules/drush/includes/drush.inc
  25. 0
    815
      sites/localhost/modules/drush/includes/environment.inc
  26. 0
    893
      sites/localhost/modules/drush/includes/table.inc

+ 0
- 274
sites/localhost/modules/drush/LICENSE.txt View File

@@ -1,274 +0,0 @@
GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
verbatim copies of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to
share and change it. By contrast, the GNU General Public License is
intended to guarantee your freedom to share and change free software--to
make sure the software is free for all its users. This General Public License
applies to most of the Free Software Foundation's software and to any other
program whose authors commit to using it. (Some other Free Software
Foundation software is covered by the GNU Library General Public License
instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the
freedom to distribute copies of free software (and charge for this service if
you wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for
a fee, you must give the recipients all the rights that you have. You must make
sure that they, too, receive or can get the source code. And you must show
them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.

Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems
introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification
follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
MODIFICATION

0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such
program or work, and a "work based on the Program" means either the
Program or any derivative work under copyright law: that is to say, a work
containing the Program or a portion of it, either verbatim or with
modifications and/or translated into another language. (Hereinafter, translation
is included without limitation in the term "modification".) Each licensee is
addressed as "you".

Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program is
not restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made
by running the Program). Whether that is true depends on what the Program
does.

1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the
Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such
modifications or work under the terms of Section 1 above, provided that you
also meet all of these conditions:

a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in whole or in
part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.

c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print such
an announcement, your work based on the Program is not required to print
an announcement.)

These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be
reasonably considered independent and separate works in themselves, then
this License, and its terms, do not apply to those sections when you distribute
them as separate works. But when you distribute the same sections as part
of a whole which is a work based on the Program, the distribution of the
whole must be on the terms of this License, whose permissions for other
licensees extend to the entire whole, and thus to each and every part
regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to
work written entirely by you; rather, the intent is to exercise the right to
control the distribution of derivative or collective works based on the
Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of a
storage or distribution medium does not bring the other work under the scope
of this License.

3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1
and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above
on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for
noncommercial distribution and only if you received the program in object
code or executable form with such an offer, in accord with Subsection b
above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source code
means all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation and
installation of the executable. However, as a special exception, the source
code distributed need not include anything that is normally distributed (in
either source or binary form) with the major components (compiler, kernel,
and so on) of the operating system on which the executable runs, unless that
component itself accompanies the executable.

If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with the
object code.

4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy,
modify, sublicense or distribute the Program is void, and will automatically
terminate your rights under this License. However, parties who have received
copies, or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.

5. You are not required to accept this License, since you have not signed it.
However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the
Program (or any work based on the Program), you indicate your acceptance
of this License to do so, and all its terms and conditions for copying,
distributing or modifying the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these terms and
conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution
of the Program by all those who receive copies directly or indirectly through
you, then the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.

This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In such
case, this License incorporates the limitation as if written in the body of this
License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will be
similar in spirit to the present version, but may differ in detail to address new
problems or concerns.

Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that
version or of any later version published by the Free Software Foundation. If
the Program does not specify a version number of this License, you may
choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make
exceptions for this. Our decision will be guided by the two goals of
preserving the free status of all derivatives of our free software and of
promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

+ 0
- 125
sites/localhost/modules/drush/README.txt View File

@@ -1,125 +0,0 @@
// $Id: README.txt,v 1.25 2009/06/04 03:10:41 weitzman Exp $

DESCRIPTION
-----------
drush is a command line shell and Unix scripting interface for Drupal, a
veritable Swiss Army knife designed to make life easier for those of us who
spend hours hacking at the command prompt.

Drush core ships with lots of useful commands for interacting with code
like modules/themes/profiles. Similarly, it runs update.php, executes sql
queries and DB migrations, and misc utilities like run cron or clear cache.

INSTALLATION
------------
For Linux/Unix/Mac:
1. Untar the tarball into a folder outside of your web site (/path/to/drush)
2. Make the 'drush' command executable:
$ chmod u+x /path/to/drush/drush
3. (Optional, but recommended:) To ease the use of drush,
- create a link to drush in a directory that is in your $PATH, e.g.:
$ ln -s /path/to/drush/drush /usr/bin/drush
OR
- create an alias to drush:
$ alias drush='/path/to/drush/drush'
(this goes into .profile or .bash_aliases in your home folder)

NOTE FOR ADVANCED USERS
- If you want to run drush with a specific version of php, rather than the
one found by the drush command, you can instead create an alias that
executes the drush.php file directly:
$ alias drush='/path/to/php/php /path/to/drush/drush.php'
If you do this, to allow Drush to detect the number of available columns,
you need to add the line 'export COLUMNS' to the .profile file in your
home folder.

4. Start using drush by running "drush" from your Drupal root directory.

(or, if you did not follow step 3, by running "/path/to/drush/drush"
or navigating to /path/to/drush and running "./drush" )

If you have troubles, try using the -l and -r parameters when invoking drush. See below.

For Windows (experimental!):
- Follow step 1. Use drush by navigating to /path/to/drush
and running 'drush.bat'.
- Whenever the documentation or the help text refers to
'drush [option] <command>' or something similar, 'drush' has to be replaced
by 'drush.bat'.
- If drush.bat is not working for you, either add the directory in which your
php.exe resides to your PATH or edit drush.bat to point to your php.exe.

USAGE
-----
Once installed and setup (see above), you can use drush as follows while in
any Drupal directory:

$ drush [options] <command>

Use the 'help' command to get a list of available options and commands:

$ drush help

For multisite installations, you might need to use the -l or other command line
options just to get drush to work:

$ drush -l http://example.com help

Related Options:
-r <path>, --root=<path> Drupal root directory to use
(default: current directory or anywhere in a Drupal directory tree)
-l <uri> , --uri=<uri> URI of the drupal site to use
(only needed in multisite environments)
-v, --verbose Display all available output

Some other options:
-i <path>, --include=<path> Path to folder(s) containing additional drush command files.
Follows the POSIX convention of separating paths with a ':'

If you get tired of typing options all the time, you can add them to your drush.php alias or
create a drushrc.php file. These provide additional options for your drush call. They provide
great flexibility for a multi-site installation, for example. See example.drushrc.php.

COMMANDS
--------
Drush ships with a number of commands, but you can easily write
your own. In fact, writing a drush command is no harder that writing simple
Drupal extensions, since drush command files closely follows the structure of
ordinary Drupal modules.

See example.drush.inc for details on the internals of a drush command
file.

You can put your drush command file in a number of places:

- In a .drush folder in your HOME folder. Note, that you have
to make the .drush folder yourself.
- Along with one of your existing modules. If your command is
related to an existing module, this is the preferred option.
- In a folder specified with the include option (see above).
- In /path/to/drush/commands (not a Smart Thing, but it would work).

In any case, it is important that you append it with ".drush.inc", so
that drush can find it.

REQUIREMENTS
------------
* To use drush from the command line, you'll need a CLI-mode capable PHP
binary. The minimum required PHP version is 5.2.
* drush should also run on Windows, however, drush modules might make use of
unix command line tools, so to use it effectively, you have to install
some of them, e.g. from GnuWin32 (http://gnuwin32.sourceforge.net/).
The READMEs of the individual command files should state which binaries
are required.

FAQ
---
Q: What does "drush" stand for?
A: The Drupal Shell.

CREDITS
-------
Originally developed by Arto Bendiken <http://bendiken.net/> for Drupal 4.7.
Redesigned by Franz Heinzmann (frando) <http://unbiskant.org/> in May 2007 for Drupal 5.
Maintained by Moshe Weitzman <http://drupal.org/moshe> with much help from
Grugnog2, Adrian Rossouw, and Vingborg.

+ 0
- 441
sites/localhost/modules/drush/commands/core/core.drush.inc View File

@@ -1,441 +0,0 @@
<?php
// $Id: core.drush.inc,v 1.30 2009/06/02 23:48:31 weitzman Exp $

/**
* @file
* Core drush commands.
*/

/**
* Implementation of hook_drush_command().
*
* In this hook, you specify which commands your
* drush module makes available, what it does and
* description.
*
* Notice how this structure closely resembles how
* you define menu hooks.
*
* @return
* An associative array describing your command(s).
*/
function core_drush_command() {
$items = array();

$items['help'] = array(
'description' => 'Print this help message. Use --filter to limit command list to one command file (e.g. --filter=pm)',
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap.
'options' => drush_get_option_help(),
'examples' => array(
'drush dl cck zen' => 'Download CCK module and Zen theme.',
'drush --uri=http://example.com status' => 'Show status command for the example.com multi-site.',
'drush help --pipe' => 'A space delimited list of commands',
),
);
$items['cron'] = array(
'description' => 'Run all cron hooks.',
);
$items['updatedb'] = array(
'description' => dt('Execute the update.php process from the command line'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_SITE,
);
$items['status'] = array(
'description' => 'Provides a birds-eye view of the current Drupal installation, if any.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
);
$items['script'] = array(
'description' => "Run php script(s).",
'examples' => array(
'drush script update_variables.php' => 'Run variables.php script',
),
'arguments' => array(
'path/to/script' => 'One or more file paths. Paths may be absolute or relative to the current working dir.',
),
);
$items['cache clear'] = array(
'description' => 'Clear all caches.'
);
$items['watchdog show'] = array(
'description' => 'Shows recent watchdog log messages. Optionally filter for a specific type.',
'drupal dependencies' => drush_drupal_major_version() >= 6 ? array('dblog') : array('watchdog'),
'arguments' => array(
'type' => 'The type of messages to show. Defaults to all.',
),
'options' => array(
'--limit' => 'The number of messages to show. Defaults to 10.',
),
'examples' => array(
'watchdog show cron' => 'Show recent cron watchdog messages.',
'watchdog show --limit 50' => 'Show 50 recent watchdog messages.',
),
);
$items['watchdog delete'] = array(
'description' => 'Delete all messages or only those of a specified type.',
'arguments' => array(
'type' => 'The type of messages to delete. Use \'all.\' to do a complete wipe.',
),
'drupal dependencies' => drush_drupal_major_version() >= 6 ? array('dblog') : array('watchdog'),
'examples' => array(
'watchdog delete all' => 'Delete all watchdog messages.',
'watchdog delete cron' => 'Delete all cron watchdog messages.',
),
);
$items['sync'] = array(
'description' => 'Rsync the Drupal tree to/from another server using ssh.',
'arguments' => array(
'source' => 'See rsync documentation.',
'destination' => 'See rsync documentation.',
),
'examples' => array(
'sync dev:/var/www/files/ stage:/var/www/files/' => 'Rsync \'files\' dir from dev to stage',
),
);
$items['eval'] = array(
'description' => 'Evaluate arbitrary php code after bootstrapping Drupal.',
'examples' => array(
'drush eval \"variable_set(\'hello\', \'world\');\"' => 'Sets the hello variable using Drupal API.',
),
'arguments' => array(
'code' => 'PHP code',
),
);
return $items;
}

function core_drush_engine_drupal() {
$engines = array();
$engines['update'] = array();
return $engines;
}

/**
* Command handler. Execute update.php code from drush.
*/
function drush_core_updatedb() {
drush_include_engine('drupal', 'update', drush_drupal_major_version());
update_main();
drush_log(dt('Finished performing updates.'), 'ok');
}


/**
* This is called if no command or an unknown command is entered.
*/
function drush_core_help() {
$commands = func_get_args();
if (empty($commands)) {
drush_show_help(array('help'));
$phases = _drush_bootstrap_phases();
// For speed, only bootstrap up to DRUSH_BOOTSTRAP_DRUPAL_SITE.
$phases = array_slice($phases, 0, DRUSH_BOOTSTRAP_DRUPAL_SITE+1);
drush_print(dt('Commands: '));

$printed_rows = array();
$phase_index = DRUSH_BOOTSTRAP_DRUSH;

foreach ($phases as $phase_index) {
if (drush_bootstrap_validate($phase_index)) {
if ($phase_index > drush_get_context('DRUSH_BOOTSTRAP_PHASE')) {
drush_bootstrap($phase_index);
}
$commands = drush_get_commands();
// Filter by command file if specified.
if ($commandfile = drush_get_option('filter')) {
foreach ($commands as $key => $candidate) {
if ($candidate['commandfile'] != $commandfile) {
unset($commands[$key]);
}
}
}
$rows = array();
foreach($commands as $key => $command) {
if (!array_key_exists($key, $printed_rows)) {
$rows[$key] = array($key, $commands[$key]['description']);
$pipe[] = "\"$key\"";
}
}
drush_print_table($rows, FALSE, array(0 => 20));
$printed_rows = array_merge($printed_rows, $rows);
}
else {
break;
}
}
// Space delimited list for use by other scripts. Set the --pipe option.
drush_print_pipe(implode(' ', $pipe));
return;
}
else {
return drush_show_help($commands);
}

drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt('Invalid command !command.', array('!command' => implode(" ", $commands))));
}


/**
* Implementation of hook_drush_help().
*
* This function is called whenever a drush user calls
* 'drush help <name-of-your-command>'
*
* @param
* A string with the help section (prepend with 'drush:')
*
* @return
* A string with the help text for your command.
*/
function core_drush_help($section) {
switch ($section) {
case 'drush:help':
return dt('Execute a drush command. Run `drush help [command]` to view command-specific help.');
case 'drush:cron':
return dt("Runs all cron hooks in all active modules for specified site.");
case 'drush:status':
return dt("View the Drupal version and DB credentials for the current site.");
case 'drush:script':
return dt("Runs the given php script(s) after a full Drupal bootstrap. A useful alternative to eval command when your php is lengthy or you can't be bothered to figure out bash quoting.");
case 'drush:watchdog show':
return dt("Show recent watchdog messages.");
case 'drush:watchdog delete':
return dt("Delete watchdog messages.");
case 'drush:updatedb':
return dt("Run update.php just as a web browser would.");
case 'drush:sync':
return dt("Sync the entire drupal directory or a subdirectory to a <destination> using ssh. Excludes .svn directories. Useful for pushing copies of your tree to a staging server, or retrieving a files directory from a remote site. Local paths should be specified relative to Drupal root.");
case 'drush:eval':
return dt("Run arbitrary PHP code in the context of Drupal");
case 'error:DRUSH_DRUPAL_DB_ERROR' :
$message = dt("Drush was not able to start (bootstrap) the Drupal database.\n");
$message .= dt("Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have a configured database.\n");
$message .= dt("\nDrush was attempting to connect to : \n!credentials\n", array('!credentials' => _core_site_credentials()));
$message .= dt("You can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line or \$options['uri'] in your drushrc.php file.\n");
return $message;
case 'error:DRUSH_DRUPAL_BOOTSTRAP_ERROR' :
$message = dt("Drush was not able to start (bootstrap) Drupal.\n");
$message .= dt("Hint: This error can only occur once the database connection has already been succesfully initiated, therefor this error generally points to a site configuration issue, and not a problem connecting to the database.\n");
$message .= dt("\nDrush was attempting to connect to : \n!credentials\n", array('!credentials' => _core_site_credentials()));
$message .= dt("You can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line or \$options['uri'] in your drushrc.php file.\n");
return $message;
break;
}
}

// TODO: consolidate with SQL commands?
function _core_site_credentials() {
$phase = drush_get_context('DRUSH_BOOTSTRAP_PHASE');
if (function_exists('php_ini_loaded_file')) {
// Function available on PHP >= 5.2.4, but we use it if available to help
// users figure out their php.ini issues.
$credentials = sprintf(" %-18s: %s\n", 'PHP configuration', php_ini_loaded_file());
}
if ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT')) {
$credentials .= sprintf(" %-18s: %s\n", 'Drupal Root', $drupal_root);
$credentials .= sprintf(" %-18s: %s\n", 'Drupal version', drush_drupal_version());
if ($site_root = drush_get_context('DRUSH_DRUPAL_SITE_ROOT')) {
$credentials .= sprintf(" %-18s: %s\n", 'Site Path', $site_root);
$credentials .= sprintf(" %-18s: %s\n", 'Site URI', drush_get_context('DRUSH_URI'));
if ($creds = drush_get_context('DRUSH_DB_CREDENTIALS')) {
$credentials .= sprintf(" %-18s: %s\n", 'Database Driver', $creds['driver']);
$credentials .= sprintf(" %-18s: %s\n", 'Database Hostname', $creds['host']);
$credentials .= sprintf(" %-18s: %s\n", 'Database Username', $creds['user']);
$credentials .= sprintf(" %-18s: %s\n", 'Database Name', $creds['name']);
$credentials .= sprintf(" %-18s: %s\n", 'Database Password', $creds['pass']);
if ($phase > DRUSH_BOOTSTRAP_DRUPAL_DATABASE) {
$credentials .= sprintf(" %-18s: %s\n", 'Database', dt('Connected'));
if ($phase > DRUSH_BOOTSTRAP_DRUPAL_FULL) {
$credentials .= sprintf(" %-18s: %s\n", 'Drupal Bootstrap', dt('Successful'));
if ($phase == DRUSH_BOOTSTRAP_DRUPAL_LOGIN) {
global $user;
$username = ($user->uid) ? $user->name : dt('Anonymous');
$credentials .= sprintf(" %-18s: %s\n", 'Drupal User', $username);
}
}
}
}
}
return $credentials;
}
return dt("Could not find a valid Drupal installation\n");
}

/**
* Command callback. Runs cron hooks.
*
* This is where the action takes place.
*
* In this function, all of Drupals API is (usually) available, including
* any functions you have added in your own modules/themes.
*
* To print something to the terminal window, use drush_print().
*
*/
function drush_core_cron() {
drupal_cron_run();
drush_print(dt('Cron run successfully.'));
}

/**
* Command callback. Provides a birds-eye view of the current Drupal
* installation.
*/
function drush_core_status() {
drush_bootstrap_max();
print _core_site_credentials();
return;
}

/**
* Command callback. Runs "naked" php scripts.
*/
function drush_core_script() {
$scripts = func_get_args();
foreach ($scripts as $script) {
$script_filename = drush_cwd() . '/' . $script;
if (file_exists($script_filename)) {
include($script_filename);
}
}
}

function drush_core_cache_clear() {
switch (drush_drupal_major_version()) {
case 5:
// clear preprocessor cache
drupal_clear_css_cache();

// clear core tables
$core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');
$alltables = array_merge($core, module_invoke_all('devel_caches'));
foreach ($alltables as $table) {
cache_clear_all('*', $table, TRUE);
}
drush_print(dt('Cache cleared.'));
break;
case 6:
case 7:
default:
drupal_flush_all_caches();
drush_print(dt('Cache cleared.'));
break;
}
}

/**
* Push files from or to the local Drupal install using SSH and RSync
*
* @return void
**/
function drush_core_sync($source, $destination) {
// Local paths are relative to Drupal root
$drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');
if (!strstr($source, ':')) {
$source = $drupal_root. "/$source";
}
if (!strstr($destination, ':')) {
$destination = $drupal_root . "/$destination";
}

// Prompt for confirmation. This is destructive.
if (!drush_get_context('DRUSH_SIMULATE')) {
drush_print(dt("You will destroy data from !target and replace with data from !source", array('!source' => $source, '!target' => $destination)));
if (!drush_confirm(dt('Do you really want to continue?'))) {
return drush_set_error('CORE_SYNC_ABORT', 'Aborting.');
}
}

$options = '-az';
$exec = "rsync -e ssh $options --exclude \"*.svn*\" $source $destination";
if (drush_get_context('drush_log')) {
// the drush_op() will be verbose about the command that gets executed.
$options .= 'v';
}

return drush_op('system', $exec) !== FALSE;
}

/**
* Displays the most recent watchdog log messages (default: 10 messages).
*/
function drush_core_watchdog_show($type = NULL) {
$severities = array(WATCHDOG_NOTICE => dt('notice'), WATCHDOG_WARNING => dt('warning'), WATCHDOG_ERROR => dt('error'));
$limit = drush_get_option('limit') ? drush_get_option('limit') : 10;

$sql = 'SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid';
$sort = ' ORDER BY w.wid DESC';
if (empty($type)) {
$result = db_query_range($sql . $sort, 0, (int)$limit);
}
else {
switch (drush_drupal_major_version()) {
case 5:
case 6:
$result = db_query_range($sql . " WHERE w.type = '%s'" . $sort, $type, 0, $limit);
break;
default:
$result = db_query_range($sql . " WHERE w.type = :type" . $sort, array(':type' => $type), 0, $limit);
}
}

$rows = array();
// module_load_include('inc', 'dblog', 'dblog.admin');
while ($watchdog = db_fetch_object($result)) {
$rows[] = array(
format_date($watchdog->timestamp, 'small'),
$severities[$watchdog->severity],
dt($watchdog->type),
core_watchdog_format_message($watchdog),
theme('username', $watchdog),
);
}

if (count($rows) == 0) {
return drush_set_error('CORE_WATCHDOG_SHOW_NONE', 'No log messages available.');
}
else {
drush_log(dt('Last !count watchdog log messages:', array('!count' => $limit)));

array_unshift($rows, array(dt('Date'), dt('Severity'), dt('Type'), dt('Message'), dt('User')));
drush_print_table($rows, TRUE);
}
}

function core_watchdog_format_message($watchdog) {
if (drush_drupal_major_version() == 5) {
$message = $watchdog->message;
}
else {
$variables = unserialize($watchdog->variables);
$message = is_array($variables) ? strtr($watchdog->message, $variables) : $watchdog->message;
}
return truncate_utf8(decode_entities($message), 68, FALSE, FALSE);
}

/**
* Deletes all log messages of a certain type from the watchdog log
* (default: all).
*/
function drush_core_watchdog_delete($type = NULL) {
if ($type == "all") {
// D7: ought to be a dynamic query.
drush_op('db_query', 'DELETE FROM {watchdog}'); // indiscriminately delete all
drush_log(dt('Deleted !n rows.', array('!n' => db_affected_rows())), 'ok');
}
elseif (!empty($type)) {
drush_op('db_query', 'DELETE FROM {watchdog} WHERE type = \'%s\'', $type);
drush_log(dt('Deleted !n rows.', array('!n' => db_affected_rows())), 'ok');
}
else {
drush_set_error(dt('Please specify a message type, or "all" to delete all messages.'));
}
}

function drush_core_eval($command) {
eval($command . ';');
}

+ 0
- 120
sites/localhost/modules/drush/commands/core/drupal/update_5.inc View File

@@ -1,120 +0,0 @@
<?php
// $Id: update_5.inc,v 1.7 2009/05/27 00:40:59 grugnog Exp $

/**
* @file
* Update.php for provisioned sites.
* This file is a derivative of the standard drupal update.php,
* which has been modified to allow being run from the command
* line.
*/


ob_start();
include_once("update.php");
ob_end_clean();

function update_main() {
// Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D5/6.
if (!drush_get_context('DRUSH_USER')) {
drush_set_option('user', 1);
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_LOGIN);
}
include_once './includes/install.inc';
drupal_load_updates();

update_fix_schema_version();
update_fix_watchdog_115();
update_fix_watchdog();
update_fix_sessions();
$has_updates = FALSE;

$start = array();
foreach (module_list() as $module) {

$updates = drupal_get_schema_versions($module);
if ($updates !== FALSE) {

$pending[$module] = array();
$updates = drupal_map_assoc($updates);

$schema_version = drupal_get_installed_schema_version($module);
$default = $schema_version;

foreach (array_keys($updates) as $update) {
if ($update > $default) {
$start[$module] = $update;
break;
}
}
// Record any pending updates. Used for confirmation prompt.
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
if (class_exists('ReflectionFunction')) {
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module. '_update_'. $update);
$description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
}
if (empty($description)) {
$description = dt('description not available');
}

$pending[$module][] = array("$update - ". trim($description));
$has_updates = TRUE;
}
}
}
}

// Print a list of pending updates for this module and get confirmation.
if ($has_updates) {
drush_print(dt('The following updates are pending:'));
drush_print();
foreach ($pending as $module => $updates) {
if (sizeof($updates)) {
array_unshift($updates, array($module . ' module'));
drush_print_table($updates, TRUE);
drush_print();
}
}
if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
drush_die('Aborting.');
}

$update_results = array();
foreach ($start as $module => $version) {
drupal_set_installed_schema_version($module, $version - 1);
$updates = drupal_get_schema_versions($module);
$max_version = max($updates);
if ($version <= $max_version) {
drush_log(dt('Updating module @module from schema version @start to schema version @max', array('@module' => $module, '@start' => $version - 1, '@max' => $max_version)));
foreach ($updates as $update) {
$finished = FALSE;
if ($update >= $version) {
while (!$finished) {
// do update
$ret = module_invoke($module, 'update_' . $update);
_drush_log_update_sql($ret);
$finished = 1;
if (isset($ret['#finished'])) {
$finished = $ret['#finished'];
unset($ret['#finished']);
}
}
drupal_set_installed_schema_version($module, $update);
}
}
}
else {
drush_log(dt('No database updates for @module module', array('@module' => $module)), 'success');
}
}
}
else {
drush_log(dt("No database updates required"), 'success');
}
}



+ 0
- 458
sites/localhost/modules/drush/commands/core/drupal/update_6.inc View File

@@ -1,458 +0,0 @@
<?php
// $Id: update_6.inc,v 1.8 2009/05/27 00:40:59 grugnog Exp $
/**
* @file
* Update.php for provisioned sites.
* This file is a derivative of the standard drupal update.php,
* which has been modified to allow being run from the command
* line.
*/
define('MAINTENANCE_MODE', 'update');

/**
* Add a column to a database using syntax appropriate for PostgreSQL.
* Save result of SQL commands in $ret array.
*
* Note: when you add a column with NOT NULL and you are not sure if there are
* already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL
* won't work when the table is not empty, and db_add_column() will fail.
* To have an empty string as the default, you must use: 'default' => "''"
* in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL
* version will set values of the added column in old rows to the
* DEFAULT value.
*
* @param $ret
* Array to which results will be added.
* @param $table
* Name of the table, without {}
* @param $column
* Name of the column
* @param $type
* Type of column
* @param $attributes
* Additional optional attributes. Recognized attributes:
* not null => TRUE|FALSE
* default => NULL|FALSE|value (the value must be enclosed in '' marks)
* @return
* nothing, but modifies $ret parameter.
*/
function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
if (array_key_exists('not null', $attributes) and $attributes['not null']) {
$not_null = 'NOT NULL';
}
if (array_key_exists('default', $attributes)) {
if (is_null($attributes['default'])) {
$default_val = 'NULL';
$default = 'default NULL';
}
elseif ($attributes['default'] === FALSE) {
$default = '';
}
else {
$default_val = "$attributes[default]";
$default = "default $attributes[default]";
}
}

$ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column $type");
if (!empty($default)) {
$ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET $default");
}
if (!empty($not_null)) {
if (!empty($default)) {
$ret[] = update_sql("UPDATE {". $table ."} SET $column = $default_val");
}
$ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET NOT NULL");
}
}

/**
* Change a column definition using syntax appropriate for PostgreSQL.
* Save result of SQL commands in $ret array.
*
* Remember that changing a column definition involves adding a new column
* and dropping an old one. This means that any indices, primary keys and
* sequences from serial-type columns are dropped and might need to be
* recreated.
*
* @param $ret
* Array to which results will be added.
* @param $table
* Name of the table, without {}
* @param $column
* Name of the column to change
* @param $column_new
* New name for the column (set to the same as $column if you don't want to change the name)
* @param $type
* Type of column
* @param $attributes
* Additional optional attributes. Recognized attributes:
* not null => TRUE|FALSE
* default => NULL|FALSE|value (with or without '', it won't be added)
* @return
* nothing, but modifies $ret parameter.
*/
function db_change_column(&$ret, $table, $column, $column_new, $type, $attributes = array()) {
if (array_key_exists('not null', $attributes) and $attributes['not null']) {
$not_null = 'NOT NULL';
}
if (array_key_exists('default', $attributes)) {
if (is_null($attributes['default'])) {
$default_val = 'NULL';
$default = 'default NULL';
}
elseif ($attributes['default'] === FALSE) {
$default = '';
}
else {
$default_val = "$attributes[default]";
$default = "default $attributes[default]";
}
}

$ret[] = update_sql("ALTER TABLE {". $table ."} RENAME $column TO ". $column ."_old");
$ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column_new $type");
$ret[] = update_sql("UPDATE {". $table ."} SET $column_new = ". $column ."_old");
if ($default) { $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column_new SET $default"); }
if ($not_null) { $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column_new SET NOT NULL"); }
$ret[] = update_sql("ALTER TABLE {". $table ."} DROP ". $column ."_old");
}


/**
* Disable anything in the {system} table that is not compatible with the
* current version of Drupal core.
*/
function update_fix_compatibility() {
$ret = array();
$incompatible = array();
$query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
while ($result = db_fetch_object($query)) {
if (update_check_incompatibility($result->name, $result->type)) {
$incompatible[] = $result->name;
drush_log(dt("%type %name is incompatible with this release of Drupal, and will be disabled.",
array("%type" => $result->type, '%name' => $result->name)), "warning");
}
}
if (!empty($incompatible)) {

$ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('". implode("','", $incompatible) ."')");
}
return $ret;
}

/**
* Helper function to test compatibility of a module or theme.
*/
function update_check_incompatibility($name, $type = 'module') {
static $themes, $modules;

// Store values of expensive functions for future use.
if (empty($themes) || empty($modules)) {
$themes = _system_theme_data();
$modules = module_rebuild_cache();
}

if ($type == 'module' && isset($modules[$name])) {
$file = $modules[$name];
}
else if ($type == 'theme' && isset($themes[$name])) {
$file = $themes[$name];
}
if (!isset($file)
|| !isset($file->info['core'])
|| $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
|| version_compare(phpversion(), $file->info['php']) < 0) {
return TRUE;
}
return FALSE;
}

/**
* Perform Drupal 5.x to 6.x updates that are required for update.php
* to function properly.
*
* This function runs when update.php is run the first time for 6.x,
* even before updates are selected or performed. It is important
* that if updates are not ultimately performed that no changes are
* made which make it impossible to continue using the prior version.
* Just adding columns is safe. However, renaming the
* system.description column to owner is not. Therefore, we add the
* system.owner column and leave it to system_update_6008() to copy
* the data from description and remove description. The same for
* renaming locales_target.locale to locales_target.language, which
* will be finished by locale_update_6002().
*/
function update_fix_d6_requirements() {
$ret = array();

if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
$spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
db_add_field($ret, 'cache', 'serialized', $spec);
db_add_field($ret, 'cache_filter', 'serialized', $spec);
db_add_field($ret, 'cache_page', 'serialized', $spec);
db_add_field($ret, 'cache_menu', 'serialized', $spec);

db_add_field($ret, 'system', 'info', array('type' => 'text'));
db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
if (db_table_exists('locales_target')) {
db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
}
if (db_table_exists('locales_source')) {
db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
}
variable_set('update_d6_requirements', TRUE);

// Create the cache_block table. See system_update_6027() for more details.
$schema['cache_block'] = array(
'fields' => array(
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'headers' => array('type' => 'text', 'not null' => FALSE),
'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
),
'indexes' => array('expire' => array('expire')),
'primary key' => array('cid'),
);
db_create_table($ret, 'cache_block', $schema['cache_block']);
}

return $ret;
}

/**
* Check update requirements and report any errors.
*/
function update_check_requirements() {
// Check the system module requirements only.
$requirements = module_invoke('system', 'requirements', 'update');
$severity = drupal_requirements_severity($requirements);

// If there are issues, report them.
if ($severity != REQUIREMENT_OK) {
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
$message = isset($requirement['description']) ? $requirement['description'] : '';
if (isset($requirement['value']) && $requirement['value']) {
$message .= ' (Currently using '. $requirement['title'] .' '. $requirement['value'] .')';
}
drush_log($message, 'warning');
}
}
}
}

/**
* Create the batch table.
*
* This is part of the Drupal 5.x to 6.x migration.
*/
function update_create_batch_table() {

// If batch table exists, update is not necessary
if (db_table_exists('batch')) {
return;
}

$schema['batch'] = array(
'fields' => array(
'bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'token' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
'timestamp' => array('type' => 'int', 'not null' => TRUE),
'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
),
'primary key' => array('bid'),
'indexes' => array('token' => array('token')),
);

$ret = array();
db_create_table($ret, 'batch', $schema['batch']);
return $ret;
}


function update_main() {
global $profile;
// Some unavoidable errors happen because the database is not yet up-to-date.
// Our custom error handler is not yet installed, so we just suppress them.
drush_errors_off();

require_once './includes/bootstrap.inc';
// Minimum load of components.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
require_once './includes/install.inc';
require_once './includes/file.inc';
require_once './modules/system/system.install';

// Load module basics.
include_once './includes/module.inc';
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
module_list(TRUE, FALSE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'filter');

// Set up $language, since the installer components require it.
drupal_init_language();

// Set up theme system for the maintenance page.
drupal_maintenance_theme();

// Check the update requirements for Drupal.
update_check_requirements();


drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
$profile = variable_get('install_profile', 'default');
// Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D5/6.
if (!drush_get_context('DRUSH_USER')) {
drush_set_option('user', 1);
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_LOGIN);
}
drupal_maintenance_theme();

// This must happen *after* drupal_bootstrap(), since it calls
// variable_(get|set), which only works after a full bootstrap.
_drush_log_update_sql(update_create_batch_table());

// Turn error reporting back on. From now on, only fatal errors (which are
// not passed through the error handler) will cause a message to be printed.
drush_errors_on();



include_once './includes/install.inc';
include_once './includes/batch.inc';
drupal_load_updates();

_drush_log_update_sql(update_fix_d6_requirements());
_drush_log_update_sql(update_fix_compatibility());

$start = array();
$has_updates = FALSE;
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
$updates = drupal_get_schema_versions($module);
// Skip incompatible module updates completely, otherwise test schema versions.
if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
// module_invoke returns NULL for nonexisting hooks, so if no updates
// are removed, it will == 0.
$last_removed = module_invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
drush_set_error('PROVISION_DRUPAL_UPDATE_FAILED', dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
continue;
}

$updates = drupal_map_assoc($updates);
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
$start[$module] = $update;
break;
}
}
// Record any pending updates. Used for confirmation prompt.
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
if (class_exists('ReflectionFunction')) {
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module. '_update_'. $update);
$description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
}
if (empty($description)) {
$description = dt('description not available');
}

$pending[$module][] = array("$update - ". trim($description));
$has_updates = TRUE;
}
}

}
}

// Print a list of pending updates for this module and get confirmation.
if ($has_updates) {
drush_print(dt('The following updates are pending:'));
drush_print();
foreach ($pending as $module => $updates) {
if (sizeof($updates)) {
array_unshift($updates, array($module . ' module'));
drush_print_table($updates, TRUE);
drush_print();
}
}
if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
drush_die('Aborting.');
}
// Proceed with running all pending updates.
$operations = array();
foreach ($start as $module => $version) {
drupal_set_installed_schema_version($module, $version - 1);
$updates = drupal_get_schema_versions($module);
$max_version = max($updates);
if ($version <= $max_version) {
drush_log(dt('Updating module @module from schema version @start to schema version @max', array('@module' => $module, '@start' => $version - 1, '@max' => $max_version)));
foreach ($updates as $update) {
if ($update >= $version) {
$operations[] = array('_update_do_one', array($module, $update));
}
}
}
else {
drush_log(dt('No database updates for module @module', array('@module' => $module)), 'success');
}
}
$batch = array(
'operations' => $operations,
'title' => 'Updating',
'init_message' => 'Starting updates',
'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
'finished' => 'update_finished',
);
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
batch_process();
}
else {
drush_log(dt("No database updates required"), 'success');
}
}

/**
* A simplified version of the batch_do_one function from update.php
*
* This does not mess with sessions and the like, as it will be used
* from the command line
*/
function _update_do_one($module, $number, &$context) {
// If updates for this module have been aborted
// in a previous step, go no further.
if (!empty($context['results'][$module]['#abort'])) {
return;
}

$function = $module .'_update_'. $number;

if (function_exists($function)) {
$ret = $function($context['sandbox']);
_drush_log_update_sql($ret);
}

if (isset($ret['#finished'])) {
$context['finished'] = $ret['#finished'];
unset($ret['#finished']);
}

if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) {
drupal_set_installed_schema_version($module, $number);
}

}


+ 0
- 616
sites/localhost/modules/drush/commands/core/drupal/update_7.inc View File

@@ -1,616 +0,0 @@
<?php
// $Id: update_7.inc,v 1.8 2009/05/27 00:40:59 grugnog Exp $
/**
* @file
* Update.php for provisioned sites.
* This file is a derivative of the standard drupal update.php,
* which has been modified to allow being run from the command
* line.
*/

/**
* Global flag to identify update.php run, and so avoid various unwanted
* operations, such as hook_init() and hook_exit() invokes, css/js preprocessing
* and translation, and solve some theming issues. This flag is checked on several
* places in Drupal code (not just update.php).
*/
define('MAINTENANCE_MODE', 'update');

/**
* Add a column to a database using syntax appropriate for PostgreSQL.
* Save result of SQL commands in $ret array.
*
* Note: when you add a column with NOT NULL and you are not sure if there are
* already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL
* won't work when the table is not empty, and db_add_column() will fail.
* To have an empty string as the default, you must use: 'default' => "''"
* in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL
* version will set values of the added column in old rows to the
* DEFAULT value.
*
* @param $ret
* Array to which results will be added.
* @param $table
* Name of the table, without {}
* @param $column
* Name of the column
* @param $type
* Type of column
* @param $attributes
* Additional optional attributes. Recognized attributes:
* not null => TRUE|FALSE
* default => NULL|FALSE|value (the value must be enclosed in '' marks)
* @return
* nothing, but modifies $ret parameter.
*/
function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
if (array_key_exists('not null', $attributes) and $attributes['not null']) {
$not_null = 'NOT NULL';
}
if (array_key_exists('default', $attributes)) {
if (is_null($attributes['default'])) {
$default_val = 'NULL';
$default = 'default NULL';
}
elseif ($attributes['default'] === FALSE) {
$default = '';
}
else {
$default_val = "$attributes[default]";
$default = "default $attributes[default]";
}
}

$ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column $type");
if (!empty($default)) {
$ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET $default");
}
if (!empty($not_null)) {
if (!empty($default)) {
$ret[] = update_sql("UPDATE {" . $table . "} SET $column = $default_val");
}
$ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET NOT NULL");
}
}

/**
* Change a column definition using syntax appropriate for PostgreSQL.
* Save result of SQL commands in $ret array.
*
* Remember that changing a column definition involves adding a new column
* and dropping an old one. This means that any indices, primary keys and
* sequences from serial-type columns are dropped and might need to be
* recreated.
*
* @param $ret
* Array to which results will be added.
* @param $table
* Name of the table, without {}
* @param $column
* Name of the column to change
* @param $column_new
* New name for the column (set to the same as $column if you don't want to change the name)
* @param $type
* Type of column
* @param $attributes
* Additional optional attributes. Recognized attributes:
* not null => TRUE|FALSE
* default => NULL|FALSE|value (with or without '', it won't be added)
* @return
* nothing, but modifies $ret parameter.
*/
function db_change_column(&$ret, $table, $column, $column_new, $type, $attributes = array()) {
if (array_key_exists('not null', $attributes) and $attributes['not null']) {
$not_null = 'NOT NULL';
}
if (array_key_exists('default', $attributes)) {
if (is_null($attributes['default'])) {
$default_val = 'NULL';
$default = 'default NULL';
}
elseif ($attributes['default'] === FALSE) {
$default = '';
}
else {
$default_val = "$attributes[default]";
$default = "default $attributes[default]";
}
}

$ret[] = update_sql("ALTER TABLE {" . $table . "} RENAME $column TO " . $column . "_old");
$ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column_new $type");
$ret[] = update_sql("UPDATE {" . $table . "} SET $column_new = " . $column . "_old");
if ($default) {
$ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET $default");
}
if ($not_null) {
$ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET NOT NULL");
}
$ret[] = update_sql("ALTER TABLE {" . $table . "} DROP " . $column . "_old");
}

/**
* Perform one update and store the results which will later be displayed on
* the finished page.
*
* An update function can force the current and all later updates for this
* module to abort by returning a $ret array with an element like:
* $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong');
* The schema version will not be updated in this case, and all the
* aborted updates will continue to appear on update.php as updates that
* have not yet been run.
*
* @param $module
* The module whose update will be run.
* @param $number
* The update number to run.
* @param $context
* The batch context array
*/
function update_do_one($module, $number, &$context) {
// If updates for this module have been aborted
// in a previous step, go no further.
if (!empty($context['results'][$module]['#abort'])) {
return;
}

try {
$function = $module . '_update_' . $number;
if (function_exists($function)) {
$ret = $function($context['sandbox']);
_drush_log_update_sql($ret);
}
}
catch (Exception $e) {
drush_set_error('DRUPAL_EXCEPTION', var_export($e, TRUE));
}

if (isset($ret['#finished'])) {
$context['finished'] = $ret['#finished'];
unset($ret['#finished']);
}

if (!isset($context['results'][$module])) {
$context['results'][$module] = array();
}
if (!isset($context['results'][$module][$number])) {
$context['results'][$module][$number] = array();
}
$context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);

if (!empty($ret['#abort'])) {
$context['results'][$module]['#abort'] = TRUE;
}
// Record the schema update if it was completed successfully.
if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) {
drupal_set_installed_schema_version($module, $number);
}

$context['message'] = 'Updating ' . check_plain($module) . ' module';
}

/**
* Create the batch table.
*
* This is part of the Drupal 5.x to 6.x migration.
*/
function update_create_batch_table() {

// If batch table exists, update is not necessary
if (db_table_exists('batch')) {
return;
}

$schema['batch'] = array(
'fields' => array(
'bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'token' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
'timestamp' => array('type' => 'int', 'not null' => TRUE),
'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
),
'primary key' => array('bid'),
'indexes' => array('token' => array('token')),
);

$ret = array();
db_create_table($ret, 'batch', $schema['batch']);
return $ret;
}

/**
* Disable anything in the {system} table that is not compatible with the
* current version of Drupal core.
*/
function update_fix_compatibility() {
$ret = array();
$incompatible = array();
$query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
while ($result = db_fetch_object($query)) {
if (update_check_incompatibility($result->name, $result->type)) {
$incompatible[] = $result->name;
drush_log(dt("%type %name is incompatible with this release of Drupal, and will be disabled.",
array("%type" => $result->type, '%name' => $result->name)), "warning");
}
}
if (!empty($incompatible)) {
$ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('" . implode("','", $incompatible) . "')");
}
return $ret;
}

/**
* Helper function to test compatibility of a module or theme.
*/
function update_check_incompatibility($name, $type = 'module') {
static $themes, $modules;

// Store values of expensive functions for future use.
if (empty($themes) || empty($modules)) {
$themes = _system_theme_data();
$modules = module_rebuild_cache();
}

if ($type == 'module' && isset($modules[$name])) {
$file = $modules[$name];
}
elseif ($type == 'theme' && isset($themes[$name])) {
$file = $themes[$name];
}
if (!isset($file)
|| !isset($file->info['core'])
|| $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
|| version_compare(phpversion(), $file->info['php']) < 0
|| ($type == 'module' && empty($file->info['files']))) {
return TRUE;
}
return FALSE;
}

/**
* Perform Drupal 5.x to 6.x updates that are required for update.php
* to function properly.
*
* This function runs when update.php is run the first time for 6.x,
* even before updates are selected or performed. It is important
* that if updates are not ultimately performed that no changes are
* made which make it impossible to continue using the prior version.
* Just adding columns is safe. However, renaming the
* system.description column to owner is not. Therefore, we add the
* system.owner column and leave it to system_update_6008() to copy
* the data from description and remove description. The same for
* renaming locales_target.locale to locales_target.language, which
* will be finished by locale_update_6002().
*/
function update_fix_d6_requirements() {
$ret = array();

if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
$spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
db_add_field($ret, 'cache', 'serialized', $spec);
db_add_field($ret, 'cache_filter', 'serialized', $spec);
db_add_field($ret, 'cache_page', 'serialized', $spec);
db_add_field($ret, 'cache_menu', 'serialized', $spec);

db_add_field($ret, 'system', 'info', array('type' => 'text'));
db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
if (db_table_exists('locales_target')) {
db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
}
if (db_table_exists('locales_source')) {
db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
}
variable_set('update_d6_requirements', TRUE);

// Create the cache_block table. See system_update_6027() for more details.
$schema['cache_block'] = array(
'fields' => array(
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'headers' => array('type' => 'text', 'not null' => FALSE),
'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
),
'indexes' => array('expire' => array('expire')),
'primary key' => array('cid'),
);
db_create_table($ret, 'cache_block', $schema['cache_block']);
}

return $ret;
}

/**
* Add the update task list to the current page.
*/
function update_task_list($active = NULL) {
// Default list of tasks.
$tasks = array(
'info' => 'Overview',
'select' => 'Review updates',
'run' => 'Run updates',
'finished' => 'Review log',
);

drupal_set_content('left', theme('task_list', $tasks, $active));
}

/**
* Check update requirements and report any errors.
*/
function update_check_requirements() {
global $db_url, $databases;
$requirements = array();

// If we will rewrite the settings.php then we need to make sure it is
// writeable.
if (empty($databases) && !empty($db_url) && is_string($db_url)) {
$requirements = install_check_requirements('', FALSE);
}
$warnings = FALSE;

// Check the system module requirements only.
$requirements += module_invoke('system', 'requirements', 'update');
$severity = drupal_requirements_severity($requirements);

// If there are issues, report them.
if ($severity != REQUIREMENT_OK) {
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
$message = isset($requirement['description']) ? $requirement['description'] : '';
if (isset($requirement['value']) && $requirement['value']) {
$message .= ' (Currently using ' . $requirement['title'] . ' ' . $requirement['value'] . ')';
}
$warnings = TRUE;
drupal_set_message($message, 'warning');
}
}
}
return $warnings;
}

/**
* Converts Drupal 6 $db_url to Drupal 7 $databases array.
*/
function update_check_d7_settings() {
global $db_url, $databases;

if (empty($databases) && !empty($db_url) && is_string($db_url)) {
$url = parse_url($db_url);
$driver = substr($db_url, 0, strpos($db_url, '://'));
if ($driver == 'mysqli') {
$driver = 'mysql';
}
$databases['default']['default']['driver'] = $driver;
$databases['default']['default']['database'] = substr($url['path'], 1);
foreach (array('user' => 'username', 'pass' => 'password', 'host' => 'host', 'port' => 'port') as $old_key => $new_key) {
$databases['default']['default'][$new_key] = isset($url[$old_key]) ? urldecode($url[$old_key]) : '';
}
$conf_path = conf_path();
file_put_contents($conf_path .'/settings.php', "\n" . '$databases = '. var_export($databases, TRUE) . ';', FILE_APPEND);
}
}

function update_main() {
global $profile;
// Some unavoidable errors happen because the database is not yet up-to-date.
// Our custom error handler is not yet installed, so we just suppress them.
drush_errors_off();

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// We only load DRUPAL_BOOTSTRAP_CONFIGURATION for the update requirements
// check to avoid reaching the PHP memory limit.
// Minimum load of components.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);

require_once DRUPAL_ROOT . '/includes/install.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
require_once DRUPAL_ROOT . '/modules/system/system.install';

// Load module basics.
include_once DRUPAL_ROOT . '/includes/module.inc';
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
module_list(TRUE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'filter');

// Set up $language, since the installer components require it.
drupal_init_language();

// Set up theme system for the maintenance page.
drupal_maintenance_theme();

// Check the update requirements for Drupal.
$warnings = update_check_requirements();

// Allow the database system to work even though the registry has not
// been created yet.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
include_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_init_database();
spl_autoload_unregister('drupal_autoload_class');
spl_autoload_unregister('drupal_autoload_interface');
// The new {blocked_ips} table is used in Drupal 7 to store a list of
// banned IP addresses. If this table doesn't exist then we are still
// running on a Drupal 6 database, so suppress the unavoidable errors
// that occur.
try {
drupal_bootstrap(DRUPAL_BOOTSTRAP_ACCESS);
}
catch (Exception $e) {
if (db_table_exists('blocked_ips')) {
throw $e;
}
}
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
$profile = variable_get('install_profile', 'default');

// Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D5/6.
if (!drush_get_context('DRUSH_USER')) {
// Remove after http://drupal.org/node/439236 lands.
require(DRUPAL_ROOT . '/modules/field/field.crud.inc');
require(DRUPAL_ROOT . '/modules/field/field.autoload.inc');

drush_set_option('user', 1);
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_LOGIN);

}

drupal_maintenance_theme();
drush_errors_on();

drupal_load_updates();

_drush_log_update_sql(update_fix_d6_requirements());
_drush_log_update_sql(update_fix_compatibility());

$start = array();
$has_updates = FALSE;
$start['system'] = array();
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
$updates = drupal_get_schema_versions($module);
// Skip incompatible module updates completely, otherwise test schema versions.
if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
// module_invoke returns NULL for nonexisting hooks, so if no updates
// are removed, it will == 0.
$last_removed = module_invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
drush_set_error('PROVISION_DRUPAL_UPDATE_FAILED', dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
continue;
}

$updates = drupal_map_assoc($updates);
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
$start[$module] = $update;
break;
}
}

// Record any pending updates. Used for confirmation prompt.
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
if (class_exists('ReflectionFunction')) {
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module. '_update_'. $update);
$description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
}
if (empty($description)) {
$description = dt('description not available');
}

$pending[] = array("$update - ". trim($description));
$has_updates = TRUE;
}
}
}
}

// Print a list of pending updates for this module and get confirmation.
if ($has_updates) {
drush_print(dt('The following updates are pending:'));
drush_print();
foreach ($pending as $module => $updates) {
if (sizeof($updates)) {
array_unshift($updates, array($module . ' module'));
drush_print_table($updates, TRUE);
drush_print();
}
}
if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
drush_die('Aborting.');
}
// Proceed with running all pending updates.
$operations = array();
foreach ($start as $module => $version) {
drupal_set_installed_schema_version($module, $version - 1);
$updates = drupal_get_schema_versions($module);
$max_version = max($updates);
if ($version <= $max_version) {
drush_log(dt('Updating module @module from schema version @start to schema version @max', array('@module' => $module, '@start' => $version - 1, '@max' => $max_version)));
foreach ($updates as $update) {
if ($update >= $version) {
$operations[] = array('_update_do_one', array($module, $update));
}
}
}
else {
drush_log(dt('No database updates for module @module', array('@module' => $module)), 'success');
}
}
$batch = array(
'operations' => $operations,
'title' => 'Updating',
'init_message' => 'Starting updates',
'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
'finished' => 'update_finished',
);
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
batch_process();
}
else {
drush_log(dt("No database updates required"), 'success');
}
}

/**
* A simplified version of the batch_do_one function from update.php
*
* This does not mess with sessions and the like, as it will be used
* from the command line
*/
function _update_do_one($module, $number, &$context) {
// If updates for this module have been aborted
// in a previous step, go no further.
if (!empty($context['results'][$module]['#abort'])) {
return;
}

try {
$function = $module .'_update_'. $number;
if (function_exists($function)) {
drush_log("Running $function");
$ret = $function($context['sandbox']);
}
_drush_log_update_sql($ret);
}
catch (Exception $e) {
drush_log(var_dump($e, TRUE));
}

if (isset($ret['#finished'])) {
$context['finished'] = $ret['#finished'];
unset($ret['#finished']);
}

if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) {
drupal_set_installed_schema_version($module, $number);
}

}


function update_finished($success, $results, $operations) {
// clear the caches in case the data has been updated.
drupal_flush_all_caches();

drupal_set_session('update_results', $results);
drupal_set_session('update_success', $success);
drupal_set_session('updates_remaining', $operations);

// Now that the update is done, we can disable site maintenance if it was
// previously turned off.
if (isset($_SESSION['site_offline']) && $_SESSION['site_offline'] == FALSE) {
variable_set('site_offline', FALSE);
unset($_SESSION['site_offline']);
}
}


+ 0
- 107
sites/localhost/modules/drush/commands/pm/package_handler/cvs.inc View File

@@ -1,107 +0,0 @@
<?php
// $Id: cvs.inc,v 1.3 2009/04/19 03:56:32 weitzman Exp $

/**
* @file Drush PM CVS extension
*/

/**
* Install a project (so far, only modules are supported).
*
* @param $project The short name of the drupal.org project
* @param $info The details (fetched from drupal.org via xml-rpc)
* @param $path The path to install the module to.
*/
function package_handler_install_project($project, $info, $path = '.') {
drush_op('chdir', $path);

drush_log("Downloading project $project ...");