Skip to content

Instantly share code, notes, and snippets.

View xuxucode's full-sized avatar

xuxucode xuxucode

  • fulltech co. ltd.
View GitHub Profile
@xuxucode
xuxucode / apparmor-docker-default.js
Last active February 21, 2024 14:06
Get latest `docker-default` AppArmor profile by parsing template.go
// Usage: node apparmor-docker-default.js
const path = require("node:path");
const fs = require("node:fs");
const profileDirectory = "/etc/apparmor.d"
/**
* @typedef ProfileData
* @property {string} name
@xuxucode
xuxucode / import-corejs-missing-modules.md
Last active August 26, 2023 06:43
微信小程序导入缺失的 `core-js` 模块
'use strict';
const mysql = require('mysql2/promise');
// CREATE TABLE `example` (
// `id` int unsigned NOT NULL AUTO_INCREMENT,
// `title` varchar(1024) NOT NULL DEFAULT '',
// `created_at` bigint NOT NULL,
// PRIMARY KEY (`id`)
// ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
'use strict';
const mysql = require('mysql2/promise');
// CREATE TABLE `example` (
// `id` int unsigned NOT NULL AUTO_INCREMENT,
// `title` varchar(1024) NOT NULL DEFAULT '',
// `created_at` bigint NOT NULL,
// PRIMARY KEY (`id`)
// ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
diff --git a/src/Entity/CommerceContentEntityBase.php b/src/Entity/CommerceContentEntityBase.php
index 026a79c4f..3e62a878e 100644
--- a/src/Entity/CommerceContentEntityBase.php
+++ b/src/Entity/CommerceContentEntityBase.php
@@ -23,7 +23,7 @@ public function getTranslatedReferencedEntities($field_name) {
*/
public function getTranslatedReferencedEntity($field_name) {
$referenced_entities = $this->getTranslatedReferencedEntities($field_name);
- return reset($referenced_entities);
+ return reset($referenced_entities) ?: NULL;
diff --git a/modules/payment/src/Controller/PaymentCheckoutController.php b/modules/payment/src/Controller/PaymentCheckoutController.php
index a60605d..2a9e246 100644
--- a/modules/payment/src/Controller/PaymentCheckoutController.php
+++ b/modules/payment/src/Controller/PaymentCheckoutController.php
@@ -2,12 +2,14 @@
namespace Drupal\commerce_payment\Controller;
+use Drupal\commerce\Response\NeedsRedirectException;
use Drupal\commerce_checkout\CheckoutOrderManagerInterface;
@xuxucode
xuxucode / order_paid_in_full_from_2.3.patch
Last active January 13, 2018 10:19
Order paid in full from tag 2.3
diff --git a/modules/order/commerce_order.post_update.php b/modules/order/commerce_order.post_update.php
index 26dd36c..7c47d89 100644
--- a/modules/order/commerce_order.post_update.php
+++ b/modules/order/commerce_order.post_update.php
@@ -7,6 +7,8 @@
use Drupal\Core\Entity\Entity\EntityFormDisplay;
+use Drupal\Core\Field\BaseFieldDefinition;
+
@xuxucode
xuxucode / graphql_cache_no_errors.patch
Created January 3, 2018 03:44
Prevent caching if there is an error occurs
diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php
index 941b664..a2a7f27 100644
--- a/src/GraphQL/Execution/QueryProcessor.php
+++ b/src/GraphQL/Execution/QueryProcessor.php
@@ -100,9 +100,9 @@ class QueryProcessor {
$metadata->addCacheableDependency($container->get('metadata'));
}
- // Prevent caching if this is a mutation query.
+ // Prevent caching if this is a mutation query or an error occurs.
@xuxucode
xuxucode / search_api_solr_schema_string.patch
Created December 28, 2017 08:16
Change type boolean to string
diff --git a/config/install/search_api_solr.solr_field_type.m_text_und_5_2_0.yml b/config/install/search_api_solr.solr_field_type.m_text_und_5_2_0.yml
index f37be9e..0f4cb5a 100644
--- a/config/install/search_api_solr.solr_field_type.m_text_und_5_2_0.yml
+++ b/config/install/search_api_solr.solr_field_type.m_text_und_5_2_0.yml
@@ -26,7 +26,7 @@ field_type:
-
class: solr.ManagedStopFilterFactory
managed: stopwords
- # ignoreCase: true
+ # ignoreCase: 'true'