Skip to content

Instantly share code, notes, and snippets.

diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index d20dcc9..95065ff 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -106,10 +106,22 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
public function db_connect($persistent = FALSE)
{
- // Persistent connection support was added in PHP 5.3.0
- $hostname = ($persistent === TRUE && is_php('5.3'))
@narfbg
narfbg / PHP56SessionHandler_concept.php
Created March 19, 2014 14:55
Pseudo-code explaining how OOP interface to sessions should work in PHP 5.6
<?php
/**
* How OOP interface to PHP sessions should look like in version 5.6.
*
* @author Andrey Andreev
*
* Notes:
* - NO other classes and/or interfaces are necessary/useful and therefore shouldn't exist.
* - Probably a good idea to consider making SessionHandler an abstract class.
*
@narfbg
narfbg / fv_callable_rules.patch
Created March 5, 2014 14:38
Experimental callable rules for CI_Form_validation
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 0c4f949..0a80888 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -144,7 +144,7 @@ class CI_Form_validation {
* Set Rules
*
* This function takes an array of field names and validation
- * rules as input, any custom error messages, validates the info,
+ * rules as input, any custom error messages, validates the info,
@narfbg
narfbg / ci_upload_initialize.diff
Created February 20, 2014 11:34
Simplify CI_Upload::initialize() defaults reset
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 983d832..686f27d 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -301,41 +301,16 @@ class CI_Upload {
*/
public function initialize($config = array())
{
- $defaults = array(
- 'max_size' => 0,
@narfbg
narfbg / hkdf.php
Created February 3, 2014 22:09
Experimental HKDF implementation for CodeIgniter's encryption class
/**
* HKDF
*
* @link https://tools.ietf.org/rfc/rfc5869.txt
* @param $key Input key
* @param $digest A SHA-2 hashing algorithm
* @param $salt Optional salt
* @param $length Output length (defaults to the selected digest size)
* @param $info Optional context/application-specific info
* @return string A pseudo-random key
@narfbg
narfbg / xmlrpc-fix-2737.diff
Created January 9, 2014 11:06
Fix for issue #2737
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 2fd1259..2a38dfd 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -1113,15 +1113,15 @@ class XML_RPC_Message extends CI_Xmlrpc
//-------------------------------------
$parser = xml_parser_create($this->xmlrpc_defencoding);
-
- $this->xh[$parser] = array(
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 1d41a19..c543e15 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2556,6 +2556,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
{
return;
}
+ elseif (in_array('select', $this->qb_cache_exists, TRUE))
+ {
@narfbg
narfbg / 2698.diff
Created October 28, 2013 11:19
A simpler alternative to CodeIgniter#2698
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index a36501e..95c3af3 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2551,11 +2551,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$qb_variable = 'qb_'.$val;
$qb_cache_var = 'qb_cache_'.$val;
- if (count($this->$qb_cache_var) === 0)
+ if (count($this->$qb_cache_var) > 0)
@narfbg
narfbg / gist:5412104
Last active December 16, 2015 09:19
Possible fix for CI issue 2406
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 292621b..569490e 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2554,7 +2554,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
{
continue;
}
- $this->$qb_variable = array_merge($this->$qb_variable, array_diff($this->$qb_cache_var, $this->$qb_variable));
+ $this->$qb_variable = array_merge($this->$qb_variable, array_udiff($this->$qb_cache_var, $this->$qb_variable, '_ci_array_diff'));
@narfbg
narfbg / issue-658-fix.diff
Created October 26, 2012 09:48
Fix for CodeIgniter issue #658
diff --git a/system/core/Router.php b/system/core/Router.php
index 5bc0530..db73cb2 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -368,7 +368,7 @@ class CI_Router {
foreach ($this->routes as $key => $val)
{
// Convert wild-cards to RegEx
- $key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key);
+ $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);