Skip to content

Instantly share code, notes, and snippets.

View visabhishek's full-sized avatar
💭
I may be slow to respond.

Abhishek visabhishek

💭
I may be slow to respond.
View GitHub Profile
#!/bin/bash
drush sqlq "SELECT DISTINCT(SELECT name from users where uid = ur.uid) FROM users_roles AS ur WHERE ur.rid IN (4) LIMIT 50" | while read username;
do
echo "Updating Password for Users $username"
drush upwd $username --password='Pass@123'
# or do whatever with individual element of the array
done
Feature: Behat tests for a clean install of the Drupal 8 standard profile. These
tests are meant both to verify the Drupal install as well as Behat test features
(like API access and JavaScript handling).
Scenario: Ensure the Login link is available for anonymous users.
Given I am an anonymous user
When I am on the homepage
And I click "Log in"
Then I should see an "input#edit-name" element
@visabhishek
visabhishek / field_collection_to_paragraph.php
Last active January 28, 2016 08:40
Copy all field collection data to Paragraph item in node wise
$node_wrapper = entity_metadata_wrapper('node', $nodes);
$raw_collection = $node_wrapper->field_testp->value();
foreach ($node_wrapper->field_test as $key => $field_collection_wrapper) {
$collection = new ParagraphsItemEntity(array('field_name' => 'field_testp', 'bundle' => 'paratest'));
$collection->is_new = TRUE;
$collection->setHostEntity('node', $nodes);
$field_collection = $field_collection_wrapper->value();
if (isset($field_collection->field_test1['und'][0]['value'])) {
$collection->field_ptest1 = $field_collection->field_test1;
}
@visabhishek
visabhishek / update-drupal-using-drush
Created January 29, 2016 07:55
update drupal using drush
drush ev "_update_cache_clear()"
drush rf
drush up drupal
@visabhishek
visabhishek / rebuild_permissions.php
Created February 3, 2016 06:39
Rebuild permissions from command line.
drush php-eval 'node_access_rebuild();'
<?php
$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'article')->execute();
$nodes = node_load_multiple(array_keys($result['node']));
foreach ($nodes as $loaded_node) {
node_access_acquire_grants($loaded_node);
}
?>
@visabhishek
visabhishek / prevent_deletion_in_drupal_db.php
Last active February 6, 2016 18:48
prevent deletion in drupal from database level
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$host = 'localhost';
$dbuser = 'root';
$dbpass = 'admin32';
$db = 'drupal7_4';
DELIMITER $$
CREATE TRIGGER trigger1
BEFORE DELETE
ON table1
FOR EACH ROW
BEGIN
IF OLD.id = 1 THEN -- Abort when trying to remove this record
CALL cannot_delete_error; -- raise an error to prevent deleting from the table
END IF;
<?php
rules_invoke_component('rules_send_notification_mail', $node, 'paramval2');
?>
//mysql export
mysqldump --opt --max_allowed_packet=512M -u root -p np_bo > np_bo_dumpxx.sql
//mysql import
mysql --max_allowed_packet=512M -u username -p db < sqlfile.sql