Skip to content

Instantly share code, notes, and snippets.

@progmars
progmars / Program.cs
Last active August 7, 2019 09:19
Issue with applying Where conditions from generic classes after Select()
using System;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
namespace ProjectionCriteria
{
public interface ISomeable
@progmars
progmars / dotenv_2_mt_reliability_workaround_vendor.patch
Created March 17, 2016 17:24
Workaround for Dotenv and issues with concurrent requests failing (especially on Windows) because of PHP threaded getenv/putenv implementation. To make this really work, use `getEnvironmentVariable` instead of `getenv` everywhere (e.g. Laravel's `env()` helper, as in the patch https://gist.github.com/progmars/5c18235360c04b621ed7 ).
This is a workaround patch for `getenv()` unstable behavior in multithreaded "PHP as Apache module" environments
(e.g. some prepackaged WAMP stacks).
See
https://github.com/vlucas/phpdotenv/issues/76
https://github.com/vlucas/phpdotenv/issues/163
This fix is intended only for development environments, the same as Dotenv itself.
The paths are based on Composer's vendor directory.
diff --git a/vendor/vlucas/phpdotenv/src/Dotenv.php b/vendor/vlucas/phpdotenv/src/Dotenv.php
index 0737a70..d734a8b 100644
--- a/vendor/vlucas/phpdotenv/src/Dotenv.php
@progmars
progmars / laravel_5_x_getenv_dotenv_mt_reliability_workaround.patch
Last active September 11, 2021 20:56
Workaround for Dotenv and Laravel 5.x issues with concurrent requests failing (especially on Windows) because of PHP threaded getenv/putenv implementation. To make this work on Laravel, you will need also https://gist.github.com/progmars/1e545d96dd48676a2aa7 patch.
This is a workaround patch for `getenv()` unstable behavior in multithreaded "PHP as Apache module" environments
(e.g. some prepackaged WAMP stacks).
See
https://github.com/vlucas/phpdotenv/issues/76
https://github.com/vlucas/phpdotenv/issues/163
This fix is intended only for development environments, the same as Dotenv itself.
In production, you should use Laravel's `config:cache` command to avoid `env` helper and Dotenv altogether.
The paths are based on Composer's vendor directory.
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php b/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php
index 673ce3a..f250729 100644
Simple contract or interface, call as you wish:
interface UnitOfWork
{
public function begin();
public function commit();
public function rollback();
}
@progmars
progmars / dotenv_1_1_1_concurrent_fix_vendor.patch
Last active March 10, 2016 10:53
Fix for Dotenv 1.1.1 and Laravel 5.1.7 issues with concurrent requests failing because of PHP threaded getenv/putenv implementation. This fix does not work for Laravel 5.2, see https://gist.github.com/progmars/5c18235360c04b621ed7 for the L5.2 fix.
Fix for Dotenv and Laravel issues with concurrent requests failing because of PHP threaded getenv/putenv implementation.
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php b/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
index de5939e..715673d 100644
--- a/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
+++ b/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
@@ -625,10 +625,15 @@ if (!function_exists('env'))
*/
function env($key, $default = null)
{
@progmars
progmars / laravel_5_1_7_session_write_improvements_vendor.patch
Created July 15, 2015 20:21
For Laravel 5.1.7. Improvement to prevent writing session data even if it has not changed. Improvement to specify session metadata update frequency in session configuration instead of updating on every request. These both improvements will also reduce the risk for race conditions for concurrent requests.
Improvement to prevent writing session data even if it has not changed.
Improvement to specify session metadata update frequency in session configuration instead of updating on every request.
These both improvements will also reduce the risk for race conditions for concurrent requests.
Also, add 'metadata_update_threshold' => 1, to your config/session.php
diff --git a/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php b/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php
index edf34b8..0b5b763 100644
--- a/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php
+++ b/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php
@@ -22,12 +22,13 @@
@progmars
progmars / session_write_improvements.patch
Last active December 15, 2015 10:03
For Laravel 5.0.27. Improvement to prevent writing session data even if it has not changed. Improvement to specify session metadata update frequency in session configuration instead of updating on every request. These both improvements will also reduce the risk for race conditions for concurrent requests.
Improvement to prevent writing session data even if it has not changed.
Improvement to specify session metadata update frequency in session configuration instead of updating on every request.
These both improvements will also reduce the risk for race conditions for concurrent requests.
Also, add 'metadata_update_threshold' => 1, to your config/session.php
diff --git a/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php b/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php
index edf34b8..0b5b763 100644
--- a/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php
+++ b/vendor/laravel/framework/src/Illuminate/Session/EncryptedStore.php
@@ -20,13 +20,14 @@
@progmars
progmars / dotenv_concurrent_fix.patch
Last active May 19, 2016 13:03
Fix for Dotenv 1.1.0 and Laravel 5.0.27 issues with concurrent requests failing because of PHP threaded getenv/putenv implementation.
Fix for Dotenv and Laravel issues with concurrent requests failing because of PHP threaded getenv/putenv implementation.
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php b/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
index de5939e..715673d 100644
--- a/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
+++ b/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
@@ -603,9 +603,14 @@ if ( ! function_exists('env'))
*/
function env($key, $default = null)
{