Skip to content

Instantly share code, notes, and snippets.

View labboy0276's full-sized avatar

John Ouellet labboy0276

View GitHub Profile
@labboy0276
labboy0276 / temp.patch
Last active March 26, 2019 18:35
temp.patch
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index f451e508fa..a32c66353b 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -725,7 +725,7 @@ protected function expandArguments(&$query, &$args) {
throw new \InvalidArgumentException('Placeholders with a trailing [] can only be expanded with an array of values.');
}
elseif (!$is_bracket_placeholder) {
- if ($is_array_data) {
+ if ($is_array_data && !empty($data)) {
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 053429f4b8..44d3c5c898 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -561,8 +561,22 @@ function user_login_finalize(UserInterface $account) {
// This is called before hook_user_login() in case one of those functions
// fails or incorrectly does a redirect which would leave the old session
// in place.
- \Drupal::service('session')->migrate();
- \Drupal::service('session')->set('uid', $account->id());
@labboy0276
labboy0276 / migrate-way-1.php
Last active March 29, 2019 01:41
Various Drupal 8 Body Migration Techniques Ways
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;
/**
* Implements hook_migrate_prepare_row().
*/
function YOUR_MODULE_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
switch ($migration->id()) {
case 'config_name':
diff --git a/redirect_after_login.module b/redirect_after_login.module
index 18b2f25..34a14f9 100644
--- a/redirect_after_login.module
+++ b/redirect_after_login.module
@@ -12,20 +12,24 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
function redirect_after_login_user_login($account) {
$current_route = \Drupal::routeMatch()->getRouteName();
- if (!in_array($current_route, ['user.reset', 'user.reset.login'])) {
- // We want to redirect user on login
@labboy0276
labboy0276 / donation tracking
Created November 21, 2018 14:09
donation tracking
<script type="text/javascript">
/* <![CDATA[ */
goog_snippet_vars = function() {
var w = window;
w.google_conversion_id = 1071200313;
w.google_conversion_label = "QJMECMynhmEQufDk_gM";
w.google_remarketing_only = false;
}
// DO NOT CHANGE THE CODE BELOW.
goog_report_conversion = function(url) {
@labboy0276
labboy0276 / pantheon.md
Last active August 16, 2018 19:29
Pantheon to Pantheon D8 Migration

Pantheon to Pantheon Migration Setup

  1. SFTP a file called secrets.json to your D8's files/private folder.
    • Just put this in the file to make a legit json file: {}
  2. In your D8 site's settings.php put this at the bottom:
# When on Pantheon, connect to a D7 database.
$migrate_settings = __DIR__ . "/settings.migrate-on-pantheon.php";
if (file_exists($migrate_settings) && isset($_ENV['PANTHEON_ENVIRONMENT'])) {
@labboy0276
labboy0276 / 2723615.patch
Created June 20, 2017 16:11
Taxonomy Entity Patch Drupal 8
diff --git a/core/modules/taxonomy/src/Controller/TaxonomyController.php b/core/modules/taxonomy/src/Controller/TaxonomyController.php
index 843cdd7..d55dc50 100644
--- a/core/modules/taxonomy/src/Controller/TaxonomyController.php
+++ b/core/modules/taxonomy/src/Controller/TaxonomyController.php
@@ -20,6 +20,9 @@ class TaxonomyController extends ControllerBase {
*
* @return array
* The taxonomy term add form.
+ *
+ * @deprecated in 8.2.x, will be removed in 9.x. Use
@labboy0276
labboy0276 / default.vcl
Created April 8, 2017 19:31
Wordpress LEMP Varnish VCL
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.
@labboy0276
labboy0276 / object-cache.php
Created April 8, 2017 19:23
Wordpress Redis Object Cache
<?php
/**
* Plugin Name: Redis Object Cache
* Author: Eric Mann & Erick Hitter
* Version: 1.0
*/
/**
* Adds a value to cache.
*
@labboy0276
labboy0276 / default.vcl
Created March 26, 2017 14:38
LAMP Varnish 4 config for Wordpress
# A heavily customized VCL to support WordPress
# Some items of note:
# Supports https
# Supports admin cookies for wp-admin
# Caches everything
# Support for custom error html page
vcl 4.0;
import directors;
import std;