Skip to content

Instantly share code, notes, and snippets.

View jissereitsma's full-sized avatar

Jisse Reitsma jissereitsma

View GitHub Profile
@jissereitsma
jissereitsma / patch.diff
Last active March 15, 2023 07:09
Patch Magento for APSB22-48 (2.4.3, 2.3.7-p3, 2.3.6-p1, 2.2.11 and possibly others)
View patch.diff
diff --git a/Filter/Template.php b/Filter/Template.php
index 8a3b350f3ab..39bf4c23e16 100644
--- a/Filter/Template.php
+++ b/Filter/Template.php
@@ -9,7 +9,9 @@
*/
namespace Magento\Framework\Filter;
+use InvalidArgumentException;
use Magento\Framework\App\ObjectManager;
@jissereitsma
jissereitsma / fix-memory-report-after-integration-tests.patch
Last active August 3, 2020 10:31
Fix memory report in certain CI environments, after integration tests have run successfully
View fix-memory-report-after-integration-tests.patch
--- dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php 2020-08-03 11:38:00.536570075 +0200
+++ dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php 2020-08-03 11:40:49.483161722 +0200
@@ -55,6 +55,7 @@
} catch (\Magento\Framework\Exception\LocalizedException $e) {
// try to use the Windows command line
// some ports of Unix commands on Windows, such as MinGW, have limited capabilities and cannot be used
+ die($e->getMessage());
$result = $this->_getWinProcessMemoryUsage($pid);
}
return $result;
@jissereitsma
jissereitsma / remove-laminas-from-setup-landing-controller.patch
Created August 3, 2020 09:11
Fix Laminas MVC addition in Magento 2.3.4 file setup/src/Magento/Setup/Controller/Landing.php
View remove-laminas-from-setup-landing-controller.patch
--- setup/src/Magento/Setup/Controller/Landing.php 2020-08-03 10:54:26.952234698 +0200
+++ setup/src/Magento/Setup/Controller/Landing.php 2020-08-03 10:54:35.300358599 +0200
@@ -5,8 +5,8 @@
*/
namespace Magento\Setup\Controller;
-use Laminas\Mvc\Controller\AbstractActionController;
-use Laminas\View\Model\ViewModel;
+use Zend\View\Model\ViewModel;
+use Zend\Mvc\Controller\AbstractActionController;
@jissereitsma
jissereitsma / parse_query_arguments.php
Created April 17, 2020 16:04
Simple PHP script to destructure query arguments from an URL
View parse_query_arguments.php
<?php
if (!isset($argv) || count($argv) !== 2) {
die('Usage: ' . basename(__FILE__ ). ' {URL}'."\n");
}
$url = $argv[1];
if (empty($url)) {
die("Empty URL");
}
@jissereitsma
jissereitsma / nginx-sample-snippet.conf
Last active September 25, 2020 13:26
Partial Nginx configuration for Magento 2 with React app in `/public/pwa` folder
View nginx-sample-snippet.conf
#location = / {
# try_files $uri /index.php;
#}
#location / {
# try_files $uri $uri/ /index.php?$args;
#}
location = / {
try_files /pwa/index.html =404;
@jissereitsma
jissereitsma / less_import_parser.php
Created August 7, 2018 06:58
Script to read a LESS file, resolve its @imports and generate a new LESS file
View less_import_parser.php
<?php
declare(strict_types=1);
class LessImportParser
{
private $content = '';
public function load(string $fileName)
{
$this->content = $this->resolveImports($fileName);
@jissereitsma
jissereitsma / magento_clean_attribute_source_models.php
Created October 7, 2017 08:33
Magento 1 script to reset attribute models if model can not be instantiated (because module is uninstalled)
View magento_clean_attribute_source_models.php
<?php
require_once 'app/Mage.php';
Mage::app();
$autoFix = true;
class Clean_Attribute_Source_Models
{
private $autofix;
private $modelFields = ['backend_model', 'frontend_model', 'source_model'];
@jissereitsma
jissereitsma / dutchento-meetup-data.php
Created July 15, 2017 10:51
Dutchento meetup data of all Magento User Groups
View dutchento-meetup-data.php
<?php
include_once 'vendor/autoload.php';
use DMS\Service\Meetup\MeetupKeyAuthClient;
$apiKey = 'enter-your-own-meetup-api-key';
$client = MeetupKeyAuthClient::factory(array('key' => $apiKey));
$meetupGroupUrlNames = array(
'Magento-User-Group-Friesland',
View m2_truncate_catalog.sql
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
TRUNCATE TABLE `cataloginventory_stock_status_idx`;
TRUNCATE TABLE `cataloginventory_stock_status_tmp`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product_index_tmp`;
View create_image_demo.php
<?php
/*
* - Switch to composer package
* - Namespacing
* - Use file/handler package
* - Use downloader package
* - Use image creation package
*/
interface ImageGenerator