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 type from node_type" | while read content_type;
do
echo "Changing comment settings for $content_type"
drush vset comment_default_mode_$content_type 0
drush vset comment_default_per_page_$content_type 50
drush vset comment_$content_type 2
drush vset comment_form_location_$content_type 1
drush vset comment_preview_$content_type 0
drush vset comment_subject_field_$content_type 0
//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
<?php
rules_invoke_component('rules_send_notification_mail', $node, 'paramval2');
?>
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;
@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';
<?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 / rebuild_permissions.php
Created February 3, 2016 06:39
Rebuild permissions from command line.
drush php-eval 'node_access_rebuild();'
@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 / 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;
}
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