Skip to content

Instantly share code, notes, and snippets.

View yohgaki's full-sized avatar

Yasuo Ohgaki yohgaki

View GitHub Profile
@yohgaki
yohgaki / gist:2250214
Created March 30, 2012 09:13
New pgsql module constants
[yohgaki@dev php-src]$ git diff HEAD^
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index e54b824..ad66779 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -947,6 +947,11 @@ PHP_MINIT_FUNCTION(pgsql)
le_result = zend_register_list_destructors_ex(_free_result, NULL, "pgsql result", module_number);
le_lofp = zend_register_list_destructors_ex(_free_ptr, NULL, "pgsql large object", module_number);
le_string = zend_register_list_destructors_ex(_free_ptr, NULL, "pgsql string", module_number);
+#if HAVE_PG_CONFIG_H
@yohgaki
yohgaki / gist:2260846
Created March 31, 2012 08:22
is_subclass_of() document fix
Index: is-subclass-of.xml
===================================================================
--- is-subclass-of.xml (リビジョン 324628)
+++ is-subclass-of.xml (作業コピー)
@@ -42,7 +42,8 @@
<term><parameter>allow_string</parameter></term>
<listitem>
<para>
- Whether to call autoloader if the class doesn't exist.
+ If this parameter set to false, string class name as <parameter>object</parameter>
@yohgaki
yohgaki / gist:2261192
Created March 31, 2012 09:13
Array doc improvement
Index: array.xml
===================================================================
--- array.xml (リビジョン 324628)
+++ array.xml (作業コピー)
@@ -118,6 +118,61 @@
</listitem>
</itemizedlist>
</para>
+
+ <para>
@yohgaki
yohgaki / gist:2270853
Created April 1, 2012 02:52
Apache 1.3.42 build fix patch. Recent libc has getline
diff -ur httpd-1.3.42.orig//src/support/htdigest.c httpd-1.3.42/src/support/htdigest.c
--- httpd-1.3.42.orig//src/support/htdigest.c 2006-07-12 17:16:05.000000000 +0900
+++ httpd-1.3.42/src/support/htdigest.c 2012-04-01 11:48:49.705771078 +0900
@@ -71,7 +71,7 @@
while ((line[y++] = line[x++]));
}
-static int getline(char *s, int n, FILE *f)
+static int my_getline(char *s, int n, FILE *f)
{
@yohgaki
yohgaki / error_handler.php
Created April 21, 2012 08:07
PHP: error handling example
<?php
// 出力バッファを開始
ob_start();
// PHPエラーを例外へ変換する為のクラス
class myException extends Exception {
public function __construct($errno, $errstr, $errfile, $errline, $errctx) {
// エラー番号とエラーレベルのマッピング
$errlev = array(
E_USER_ERROR => 'SECURITY',
@yohgaki
yohgaki / gist:2717255
Created May 17, 2012 07:51
memcache 2.2.6 patch for my strict PHP session patch
diff -up memcache-2.2.6/memcache_session.c.orig memcache-2.2.6/memcache_session.c
--- memcache-2.2.6/memcache_session.c.orig 2012-05-17 14:50:33.000000000 +0900
+++ memcache-2.2.6/memcache_session.c 2012-05-17 16:28:20.000000000 +0900
@@ -280,6 +280,42 @@ PS_GC_FUNC(memcache)
}
/* }}} */
+
+PS_VALIDATE_SID_FUNC(memcache)
+{
@yohgaki
yohgaki / pgsql_session_save_handler_example.php
Last active December 15, 2015 00:15
[PHP] PostgreSQL user defined session save handler example
<?php
/**
Use following table
CREATE TABLE php_session (
id text UNIQUE NOT NULL,
data bytea NOT NULL,
updated int8 NOT NULL
);
@yohgaki
yohgaki / session_php_serializer.patch
Created August 7, 2013 06:07
"php_serialize" session serialize handler for PHP Session module. This patch adds new session.serializer_handler that serializes session data by plain serialize(). This serializer removes limitations due to the heritage of "register_globals". Users may use numeric key for $_SESSION with this new serializer. e.g. $_SESSION[1] = 'foo'
diff --git a/ext/session/session.c b/ext/session/session.c
index c02a10d..1497da4 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -827,6 +827,51 @@ PHP_INI_END()
/* ***************
* Serializers *
*************** */
+PS_SERIALIZER_ENCODE_FUNC(php_serialize) /* {{{ */
+{
@yohgaki
yohgaki / PHP-master-session-write-short-circuit.diff
Last active December 20, 2015 21:38
This simple patch implements session write short circuit. It removes unneeded session data writes by comparing session data hash digest.
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
index e8e79f0..ba3420e 100644
--- a/ext/session/php_session.h
+++ b/ext/session/php_session.h
@@ -180,6 +180,7 @@ typedef struct _php_ps_globals {
double rfc1867_min_freq; /* session.upload_progress.min_freq */
zend_bool use_strict_mode; /* whether or not PHP accepts unknown session ids */
+ char session_data_hash[16]; /* binary MD5 hash length */
} php_ps_globals;
@yohgaki
yohgaki / gist:7441034
Created November 13, 2013 00:00
Patch adds rpm build script to casperjs-master.
diff --git a/rpm/build b/rpm/build
new file mode 100755
index 0000000..de73e32
--- /dev/null
+++ b/rpm/build
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# A silly little helper script to build the RPM.
+set -e