Установка Drupal через drush

Установить друпал можно через командную строку в одну строку!!!! Ну если быть точнее через две.

#Первая строка скачивает drupal
drush dl drupal

#установка друпалла
drush site-install standard --account-name=LoginAdmin --account-pass=passwordAdmin --db-url=mysql://UserDB:PasswordDB@localhost/NameDB

Больше команд можно почитать здесь

DRUSH

drush up — обновление ядра и модулей Drupal.
drush cc all — очистка всего кеша сайта.
drush pm-list — список всех модулей и тем установленных на сайте, а также их версии и статус активности.
drush dl module — загружает модуль или тему. Несколько значений пишится через пробел.
drush en module — включает указанный модуль или тему.
drush dis module — выключает указанный модуль или тему.
drush ard — создание бэкапа сайта. Делает бэкап как самого сайта, так и базы данных, все это сохраняется в tar.gz архиве. Невероятно удобная вещь.
drush arr path — восстановление бекапа созданного командой drush ard. Заместо path нужно указать путь до архива, включая его название и расширение.

Установка drupall

drush dl drupal-7.x
drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://YourMySQLUser:RandomPassword@localhost/YourMySQLDatabase

Розпаковка архива на другой сервер
drush arr nivea.20150415_200549.tar.gz --db-url=mysql://root@localhost:3306/nivea

drush uli - получить разовую ссылку на вход для админа
drush upwd admin --password="newpassword" - сбросить пароль для пользователя

Массовое применение patch drupal 7.32

Для того что применить к всем пользователям патч нужно создать файл на сервере (к примеру в корне) с именем к примеру
pathc.patch. Текст в файле, в нашем случаи можно взять, здесь https://www.drupal.org/files/issues/SA-CORE-2014-005-D7.patch

И зайдя через SSH выполнить команду

for i in /home/www/*/data/www/* ; do cd "$i"; echo "$i"; patch -p1 < /patch.patch; done

Путь конечно же под ваш сервер, у меня первая звездочка это пользователи на сервере, вторая сайты.

Дробное количество ubercart 3

ubercard 3.5 нашел решения с некоторыми коректировками
// making the product quantities FLOAT instead INTEGER Drupal 7, Ubercart 3.1
//// DATABASE CHANGES Four ubercart tables alterations are made from sql terminal (mysql -u ADMIN_USER -p , use DATABASE_NAME )
1) The UC_CART_PRODUCTS table intersect the UC_CARTS table and the UC_PRODUCTS table. The column ц╒Б┌╛е⌠qtyц╒Б┌╛б² is the one to ajust. Here is the MySQL statement that will modify the column to a FLOAT data type:

ALTER TABLE `uc_cart_products` MODIFY COLUMN `qty` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 0;

2) The UC_ORDERS table holds all the orders created. The column to adjust is ц╒Б┌╛е⌠product_countц╒Б┌╛б².

ALTER TABLE `uc_orders` MODIFY COLUMN `product_count` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 0; 3) The UC_PRODUCTS table contains a

default_qty field. This value gets inserted into both the product edit page and the product view page (for the customer). I think it would be a good idea to show the customer how many decimal places one may use.

ALTER TABLE `uc_products` MODIFY COLUMN `default_qty` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 1.00;

4) The UC_ORDER_PRODUCTS table intersects the UC_ORDERS table and the UC_PRODUCTS table. The column to adjust is the ц╒Б┌╛е⌠qtyц╒Б┌╛б² column. Here is the MySQL statement that will modify the column to a FLOAT data type:

ALTER TABLE `uc_order_products` MODIFY COLUMN `qty` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 0;

//// CODE CHANGES // FIRST uc_order -> uc_order.install //Change array elements in function to: /** * Increase maximum order item quantity. */

function uc_order_update_7003() {
db_change_field('uc_order_products', 'qty', 'qty', array(
'description' => 'The number of the same product ordered.',
'type' => 'float',
'precision' => 6,
'scale' => 1,
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1.0,
));
}

// SECOND


uc_order
->
uc_order.install

In $schema['uc_order_products'] change:

'qty' => array(
'description' => 'The number of the same product ordered.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),

To:


'qty' => array(
'description' => 'The number of the same product ordered.',
'type' => 'float',
'precision' => 6,
'scale' => 1,
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1.0,
),

// THIRD uc_product -> uc_product.module //For possibility of using 0.00 to 1.00 quantites in function uc_product_uc_update_cart_item change: (string 1052) p.s. С новыми версиями функция поменялась, я сменил на функцию на старую версию, пока все ок 🙂

</pre>
<pre class="php"><code><span class="php-keyword">function</span> <span class="php-function-or-constant"><a class="local active" title="Implements hook_uc_update_cart_item()." href="http://drupalcontrib.org/api/drupal/contributions%21ubercart%21uc_product%21uc_product.module/function/uc_product_uc_update_cart_item/7">uc_product_uc_update_cart_item</a></span>(<span class="php-variable">$nid</span>, <span class="php-variable">$data</span> = <span class="php-keyword">array</span>(), <span class="php-variable">$qty</span>, <span class="php-variable">$cid</span> = <span class="php-function-or-constant">NULL</span>) {
  <span class="php-keyword">if</span> (!<span class="php-variable">$nid</span>) {
    <span class="php-keyword">return</span> <span class="php-function-or-constant">NULL</span>;
  }
  <span class="php-variable">$cid</span> = !(<span class="php-function-or-constant">is_null</span>(<span class="php-variable">$cid</span>) || <span class="php-keyword">empty</span>(<span class="php-variable">$cid</span>)) ? <span class="php-variable">$cid</span> : <span class="php-function-or-constant"><a class="local" title="Returns the unique cart_id of the user." href="http://drupalcontrib.org/api/drupal/contributions%21ubercart%21uc_cart%21uc_cart.module/function/uc_cart_get_id/7">uc_cart_get_id</a></span>();
  <span class="php-keyword">if</span> (<span class="php-variable">$qty</span> < <span class="php-constant">1</span>) {
    <span class="php-function-or-constant"><a class="local" title="Removes an item from the cart." href="http://drupalcontrib.org/api/drupal/contributions%21ubercart%21uc_cart%21uc_cart.module/function/uc_cart_remove_item/7">uc_cart_remove_item</a></span>(<span class="php-variable">$nid</span>, <span class="php-variable">$cid</span>, <span class="php-variable">$data</span>);
  }
  <span class="php-keyword">else</span> {
    <span class="php-function-or-constant"><a class="local" title="Returns a new UpdateQuery object for the active database." href="http://drupalcontrib.org/api/drupal/drupal%21includes%21database%21database.inc/function/db_update/7">db_update</a></span>(<span class="php-string">'uc_cart_products'</span>)
      -><span class="php-function-or-constant"><a class="local" title="Multiple implementations exist." href="http://drupalcontrib.org/api/search/7/fields">fields</a></span>(<span class="php-keyword">array</span>(
      <span class="php-string">'qty'</span> => <span class="php-variable">$qty</span>, 
      <span class="php-string">'changed'</span> => <span class="php-function-or-constant"><a class="local" title="Time of the current request in seconds elapsed since the Unix Epoch." href="http://drupalcontrib.org/api/drupal/drupal%21includes%21bootstrap.inc/constant/REQUEST_TIME/7">REQUEST_TIME</a></span>,
    ))
      -><span class="php-function-or-constant"><a class="local" title="Multiple implementations exist." href="http://drupalcontrib.org/api/search/7/condition">condition</a></span>(<span class="php-string">'nid'</span>, <span class="php-variable">$nid</span>)
      -><span class="php-function-or-constant"><a class="local" title="Multiple implementations exist." href="http://drupalcontrib.org/api/search/7/condition">condition</a></span>(<span class="php-string">'cart_id'</span>, <span class="php-variable">$cid</span>)
      -><span class="php-function-or-constant"><a class="local" title="Multiple implementations exist." href="http://drupalcontrib.org/api/search/7/condition">condition</a></span>(<span class="php-string">'data'</span>, <span class="php-function-or-constant">serialize</span>(<span class="php-variable">$data</span>))
      -><span class="php-function-or-constant"><a class="local" title="Multiple implementations exist." href="http://drupalcontrib.org/api/search/7/execute">execute</a></span>();
  }
}


 


if ($qty < 1) {

 

CHANGE TO:


if ($qty == 0) {

// FOURTH uc_order -> uc_order.admin.inc //Not sure if it's necessary but just in case (string 1125)

if (!isset($product['remove']) && intval($product['qty']) > 0) {

CHANGE TO:


if (!isset($product['remove']) && ($product['qty']) > 0) {

//FIFTH uc_cart -> uc_cart.install //Not sure if it's necessary but just in case CHANGE TO FLOATS: (string 37)


'qty' => array(
'description' => 'The number of this product in the cart.',
'type' => 'float',
'precision' => 6,
'scale' => 1,
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1.0,

AND (string 126)


function uc_cart_update_7001() {
db_change_field('uc_cart_products', 'qty', 'qty', array(
'description' => 'The number of this product in the cart.',
'type' => 'float',
'precision' => 6,
'scale' => 1,
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1.0,
));
}

/*uc_store\uc_store.module*/ /*chenge */


function uc_store_validate_uc_quantity(&$element, &$form_state) {
if (!preg_match('/^\d+$/', $element['#value'])) {
form_error($element, t('The quantity must be a number.'));
}
elseif (empty($element['#allow_zero']) && !$element['#value']) {
form_error($element, t('The quantity cannot be zero.'));
}
}

/*on*/


function uc_store_validate_uc_quantity(&$element, &$form_state) {
if (!preg_match("/([0-9\.-]+)/", $element['#value'])) {
form_error($element, t('The quantity must be a number.'));
}
elseif (empty($element['#allow_zero']) && !$element['#value']) {
form_error($element, t('The quantity cannot be zero.'));
}
}

Drush update all module and drupal automatic more site

Как всегда не буду тянуть заходим в SSH и вводим такую вот строчку

for i in /home/www/grenuy/data/www/*/sites/.. ; do cd "$i"; drush updb; drush en update; yes | drush pm-update ; drush up drupal ; drush updb ; done

 

grenuy это имя пользователя путь может быть немного видоизмененным в зависимости от сервера.

Скрипт может давать сбои и error, при сбои создается папка с именем drupal-7.** перенеся от туда файлы в корень сайта восстановиться сайт.

обновляет как и 7-ку так и 6-ку в построчечный режим выполнения команд такой(в корне сайта выполняться)

drush en update
drush pm-update
drush up drupal
drush updb

(Russian) views nivo slider Как сделать что бы слайды показывались в рандомному порядку, и первый слайд так же был рандомным

Вибачте цей текст доступний тільки в “Російська і “Англійська”.