Skip to content

Instantly share code, notes, and snippets.

View yohgaki's full-sized avatar

Yasuo Ohgaki yohgaki

View GitHub Profile
@yohgaki
yohgaki / php-5.4-accessor-with-trait.php
Created November 20, 2011 00:23
PHP 5.4: Accessor with trait example
<?php
// Example code how to eliminate getter and setter methods
// with traits introduced from PHP 5.4
trait Accessors {
public function __get($name) {
if ($this->r_property[$name])
return $this->$name;
else
trigger_error("Access to read protected property");
@yohgaki
yohgaki / php-trunk-strict-session.patch
Created November 20, 2011 01:35
PHP master: Strict session patch
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 621c4e1..a21e0ca 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -61,40 +61,9 @@ typedef struct {
} ps_files;
ps_module ps_mod_files = {
- PS_MOD(files)
+ PS_MOD_SID(files)
@yohgaki
yohgaki / php-pgsql-escape-literal.patch
Created November 20, 2011 23:49
php-trunk pg_escape_literal patch
Index: ext/pgsql/tests/08escape.phpt
===================================================================
--- ext/pgsql/tests/08escape.phpt (リビジョン 319557)
+++ ext/pgsql/tests/08escape.phpt (作業コピー)
@@ -11,8 +11,9 @@
// pg_escape_string() test
$before = "ABC\\ABC\'";
$expect = "ABC\\\\ABC\\'";
+$expect2 = "ABC\\\\ABC\\\\''"; //the way escape string differs from PostgreSQL 9.0
$after = pg_escape_string($before);
@yohgaki
yohgaki / php-pgsql-escape-literal-identifier-example.php
Created November 22, 2011 21:28
PHP: Example code for pgsql module with pg_escape_identifier()/pg_escape_literal() patch
<?php
$db = pg_connect('host=127.0.0.1 dbname=test');
// Create test table with reserved word "user"
$sql = 'drop table test2; create table test2 ('.pg_escape_identifier('user').' text);';
var_dump($sql);
pg_query($sql);
// Example use of pg_escape_literal().
// Note that no quotes around string. Quotes are added by the function.
@yohgaki
yohgaki / gist:2224196
Created March 28, 2012 06:24
PHP 5.4: Strict Session patch
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 621c4e1..a21e0ca 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -61,40 +61,9 @@ typedef struct {
} ps_files;
ps_module ps_mod_files = {
- PS_MOD(files)
+ PS_MOD_SID(files)
@yohgaki
yohgaki / strict-session-5.3.patch
Created March 28, 2012 06:48
PHP 5.3: Strict Session patch
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index ec25bea..2046934 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -61,40 +61,9 @@ typedef struct {
} ps_files;
ps_module ps_mod_files = {
- PS_MOD(files)
+ PS_MOD_SID(files)
@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)
{