From dccfdb642699a3ed67e7237de27992afdee1f86d Mon Sep 17 00:00:00 2001
From: Marcin Krol <hawk@tld-linux.org>
Date: Wed, 13 Jan 2016 10:14:02 +0000
Subject: [PATCH] - updated to 7.0.2, mostly PLD merge, but TLDized (as usual)
 and with some patches    reworked from scratch, release 0.1 for now

---
 dep-tests.sh                         |   7 +-
 fpm-conf-split.patch                 | 866 ---------------------------
 mysql-lib-ver-mismatch.patch         |  11 -
 pcre-shared.patch                    |  44 +-
 php-db.patch                         |  14 +-
 php-fcgi-error_log-no-newlines.patch |  16 +-
 php-fcgi-graceful.patch              |  31 +-
 php-fpm-config.patch                 |  42 +-
 php-fpm-shared.patch                 |  12 +-
 php-ini.patch                        |  40 +-
 php-mod_php.conf                     |   4 +-
 php-mysql-charsetphpini.patch        |  76 ---
 php-mysql-nowarning.patch            |  22 -
 php-mysqli-charsetphpini.patch       |  38 +-
 php-sapi-ini-file.patch              |  93 ++-
 php-shared.patch                     |  90 ++-
 php-silent-session-cleanup.patch     |   8 +-
 php-systzdata.patch                  |  53 +-
 php-tds.patch                        |  11 -
 php-tld.patch                        |  14 +-
 php-zlib-for-getimagesize.patch      |  12 +-
 php.spec                             | 541 ++++++++---------
 skip-tests.sh                        |  52 +-
 spl-shared.patch                     |   8 +-
 24 files changed, 574 insertions(+), 1531 deletions(-)
 delete mode 100644 fpm-conf-split.patch
 delete mode 100644 php-mysql-charsetphpini.patch
 delete mode 100644 php-mysql-nowarning.patch
 delete mode 100644 php-tds.patch

diff --git a/dep-tests.sh b/dep-tests.sh
index f28ab54..18ea66c 100755
--- a/dep-tests.sh
+++ b/dep-tests.sh
@@ -19,7 +19,7 @@ dep_pdo_dblib="$dep_pdo pdo"
 dep_pdo_mysql="$dep_pdo pdo $with_mysqlnd"
 dep_simplexml="$dep_spl spl"
 dep_imap="pcre"
-dep_phar="$dep_spl spl"
+dep_phar="$dep_spl spl hash"
 dep_sqlite="$dep_pdo pdo"
 dep_fileinfo="pcre"
 dep_wddx='xml'
@@ -27,6 +27,7 @@ dep_xmlreader='dom'
 dep_xmlrpc='xml'
 dep_xsl='dom'
 dep_snmp="$dep_spl spl snmp"
+dep_opcache='pcre'
 
 php=${PHP:-$(php-config --php-binary)}
 ext_dir=${EXTENSION_DIR:-$(php-config --extension-dir)}
@@ -34,7 +35,7 @@ conf_dir=${CONFIG_DIR:-$(php-config --sysconfdir)/conf.d $(php-config --sysconfd
 tmpini=$(mktemp)
 
 # poldek --sn ac-ready -u php-*
-for ext in ${1:-$ext_dir/*.so}; do
+for ext in ${*:-$ext_dir/*.so}; do
 	[ -f $ext ] || continue
 	ext=${ext##*/}; ext=${ext%.so}
 
@@ -47,7 +48,7 @@ for ext in ${1:-$ext_dir/*.so}; do
 	# special: opcache is listed as "Zend Opcache"
 	[ "$ext" = "opcache" ] && ext="zend opcache"
 
-	grep -rlE '^(zend_)?extension=('$(echo "${deps# }" | tr ' ' '|')').so$' $conf_dir | LC_CTYPE=C LC_ALL= sort | xargs cat > $tmpini
+	grep -rlE '^(zend_)?extension=('$(echo "${deps# }" | tr ' ' '|')').so$' $conf_dir | LC_ALL=C sort | xargs cat > $tmpini
 	$php -n -d extension_dir=$ext_dir -c $tmpini -r "exit(extension_loaded('${ext}') ? 0 : 1);"
 	rc=$?
 	if [ $rc = 0 ]; then
diff --git a/fpm-conf-split.patch b/fpm-conf-split.patch
deleted file mode 100644
index 2466c51..0000000
--- a/fpm-conf-split.patch
+++ /dev/null
@@ -1,866 +0,0 @@
---- php-5.6.4/sapi/fpm/php-fpm.conf.in~	2015-01-01 17:18:30.000000000 +0200
-+++ php-5.6.4/sapi/fpm/php-fpm.conf.in	2015-01-01 17:20:31.203799290 +0200
-@@ -6,14 +6,6 @@
- ; prefix (@prefix@). This prefix can be dynamically changed by using the
- ; '-p' argument from the command line.
- 
--; Include one or more files. If glob(3) exists, it is used to include a bunch of
--; files from a glob(3) pattern. This directive can be used everywhere in the
--; file.
--; Relative path can also be used. They will be prefixed by:
--;  - the global prefix if it's been set (-p argument)
--;  - @prefix@ otherwise
--;include=etc/fpm.d/*.conf
--
- ;;;;;;;;;;;;;;;;;;
- ; Global Options ;
- ;;;;;;;;;;;;;;;;;;
-@@ -123,415 +115,3 @@
- ; ports and different management options.  The name of the pool will be
- ; used in logs and stats. There is no limitation on the number of pools which
- ; FPM can handle. Your system will tell you anyway :)
--
--; Start a new pool named 'www'.
--; the variable $pool can we used in any directive and will be replaced by the
--; pool name ('www' here)
--[www]
--
--; Per pool prefix
--; It only applies on the following directives:
--; - 'access.log'
--; - 'slowlog'
--; - 'listen' (unixsocket)
--; - 'chroot'
--; - 'chdir'
--; - 'php_values'
--; - 'php_admin_values'
--; When not set, the global prefix (or @php_fpm_prefix@) applies instead.
--; Note: This directive can also be relative to the global prefix.
--; Default Value: none
--;prefix = /path/to/pools/$pool
--
--; Unix user/group of processes
--; Note: The user is mandatory. If the group is not set, the default user's group
--;       will be used.
--user = @php_fpm_user@
--group = @php_fpm_group@
--
--; The address on which to accept FastCGI requests.
--; Valid syntaxes are:
--;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
--;                            a specific port;
--;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
--;                            a specific port;
--;   'port'                 - to listen on a TCP socket to all IPv4 addresses on a
--;                            specific port;
--;   '[::]:port'            - to listen on a TCP socket to all addresses
--;                            (IPv6 and IPv4-mapped) on a specific port;
--;   '/path/to/unix/socket' - to listen on a unix socket.
--; Note: This value is mandatory.
--listen = 127.0.0.1:9000
--
--; Set listen(2) backlog.
--; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
--;listen.backlog = 65535
--
--; Set permissions for unix socket, if one is used. In Linux, read/write
--; permissions must be set in order to allow connections from a web server. Many
--; BSD-derived systems allow connections regardless of permissions. 
--; Default Values: user and group are set as the running user
--;                 mode is set to 0660
--;listen.owner = @php_fpm_user@
--;listen.group = @php_fpm_group@
--;listen.mode = 0660
--; When POSIX Access Control Lists are supported you can set them using
--; these options, value is a comma separated list of user/group names.
--; When set, listen.owner and listen.group are ignored
--;listen.acl_users =
--;listen.acl_groups =
-- 
--; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
--; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
--; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
--; must be separated by a comma. If this value is left blank, connections will be
--; accepted from any ip address.
--; Default Value: any
--;listen.allowed_clients = 127.0.0.1
--
--; Specify the nice(2) priority to apply to the pool processes (only if set)
--; The value can vary from -19 (highest priority) to 20 (lower priority)
--; Note: - It will only work if the FPM master process is launched as root
--;       - The pool processes will inherit the master process priority
--;         unless it specified otherwise
--; Default Value: no set
--; process.priority = -19
--
--; Choose how the process manager will control the number of child processes.
--; Possible Values:
--;   static  - a fixed number (pm.max_children) of child processes;
--;   dynamic - the number of child processes are set dynamically based on the
--;             following directives. With this process management, there will be
--;             always at least 1 children.
--;             pm.max_children      - the maximum number of children that can
--;                                    be alive at the same time.
--;             pm.start_servers     - the number of children created on startup.
--;             pm.min_spare_servers - the minimum number of children in 'idle'
--;                                    state (waiting to process). If the number
--;                                    of 'idle' processes is less than this
--;                                    number then some children will be created.
--;             pm.max_spare_servers - the maximum number of children in 'idle'
--;                                    state (waiting to process). If the number
--;                                    of 'idle' processes is greater than this
--;                                    number then some children will be killed.
--;  ondemand - no children are created at startup. Children will be forked when
--;             new requests will connect. The following parameter are used:
--;             pm.max_children           - the maximum number of children that
--;                                         can be alive at the same time.
--;             pm.process_idle_timeout   - The number of seconds after which
--;                                         an idle process will be killed.
--; Note: This value is mandatory.
--pm = dynamic
--
--; The number of child processes to be created when pm is set to 'static' and the
--; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
--; This value sets the limit on the number of simultaneous requests that will be
--; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
--; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
--; CGI. The below defaults are based on a server without much resources. Don't
--; forget to tweak pm.* to fit your needs.
--; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
--; Note: This value is mandatory.
--pm.max_children = 5
--
--; The number of child processes created on startup.
--; Note: Used only when pm is set to 'dynamic'
--; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
--pm.start_servers = 2
--
--; The desired minimum number of idle server processes.
--; Note: Used only when pm is set to 'dynamic'
--; Note: Mandatory when pm is set to 'dynamic'
--pm.min_spare_servers = 1
--
--; The desired maximum number of idle server processes.
--; Note: Used only when pm is set to 'dynamic'
--; Note: Mandatory when pm is set to 'dynamic'
--pm.max_spare_servers = 3
--
--; The number of seconds after which an idle process will be killed.
--; Note: Used only when pm is set to 'ondemand'
--; Default Value: 10s
--;pm.process_idle_timeout = 10s;
-- 
--; The number of requests each child process should execute before respawning.
--; This can be useful to work around memory leaks in 3rd party libraries. For
--; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
--; Default Value: 0
--;pm.max_requests = 500
--
--; The URI to view the FPM status page. If this value is not set, no URI will be
--; recognized as a status page. It shows the following informations:
--;   pool                 - the name of the pool;
--;   process manager      - static, dynamic or ondemand;
--;   start time           - the date and time FPM has started;
--;   start since          - number of seconds since FPM has started;
--;   accepted conn        - the number of request accepted by the pool;
--;   listen queue         - the number of request in the queue of pending
--;                          connections (see backlog in listen(2));
--;   max listen queue     - the maximum number of requests in the queue
--;                          of pending connections since FPM has started;
--;   listen queue len     - the size of the socket queue of pending connections;
--;   idle processes       - the number of idle processes;
--;   active processes     - the number of active processes;
--;   total processes      - the number of idle + active processes;
--;   max active processes - the maximum number of active processes since FPM
--;                          has started;
--;   max children reached - number of times, the process limit has been reached,
--;                          when pm tries to start more children (works only for
--;                          pm 'dynamic' and 'ondemand');
--; Value are updated in real time.
--; Example output:
--;   pool:                 www
--;   process manager:      static
--;   start time:           01/Jul/2011:17:53:49 +0200
--;   start since:          62636
--;   accepted conn:        190460
--;   listen queue:         0
--;   max listen queue:     1
--;   listen queue len:     42
--;   idle processes:       4
--;   active processes:     11
--;   total processes:      15
--;   max active processes: 12
--;   max children reached: 0
--;
--; By default the status page output is formatted as text/plain. Passing either
--; 'html', 'xml' or 'json' in the query string will return the corresponding
--; output syntax. Example:
--;   http://www.foo.bar/status
--;   http://www.foo.bar/status?json
--;   http://www.foo.bar/status?html
--;   http://www.foo.bar/status?xml
--;
--; By default the status page only outputs short status. Passing 'full' in the
--; query string will also return status for each pool process.
--; Example: 
--;   http://www.foo.bar/status?full
--;   http://www.foo.bar/status?json&full
--;   http://www.foo.bar/status?html&full
--;   http://www.foo.bar/status?xml&full
--; The Full status returns for each process:
--;   pid                  - the PID of the process;
--;   state                - the state of the process (Idle, Running, ...);
--;   start time           - the date and time the process has started;
--;   start since          - the number of seconds since the process has started;
--;   requests             - the number of requests the process has served;
--;   request duration     - the duration in µs of the requests;
--;   request method       - the request method (GET, POST, ...);
--;   request URI          - the request URI with the query string;
--;   content length       - the content length of the request (only with POST);
--;   user                 - the user (PHP_AUTH_USER) (or '-' if not set);
--;   script               - the main script called (or '-' if not set);
--;   last request cpu     - the %cpu the last request consumed
--;                          it's always 0 if the process is not in Idle state
--;                          because CPU calculation is done when the request
--;                          processing has terminated;
--;   last request memory  - the max amount of memory the last request consumed
--;                          it's always 0 if the process is not in Idle state
--;                          because memory calculation is done when the request
--;                          processing has terminated;
--; If the process is in Idle state, then informations are related to the
--; last request the process has served. Otherwise informations are related to
--; the current request being served.
--; Example output:
--;   ************************
--;   pid:                  31330
--;   state:                Running
--;   start time:           01/Jul/2011:17:53:49 +0200
--;   start since:          63087
--;   requests:             12808
--;   request duration:     1250261
--;   request method:       GET
--;   request URI:          /test_mem.php?N=10000
--;   content length:       0
--;   user:                 -
--;   script:               /home/fat/web/docs/php/test_mem.php
--;   last request cpu:     0.00
--;   last request memory:  0
--;
--; Note: There is a real-time FPM status monitoring sample web page available
--;       It's available in: @EXPANDED_DATADIR@/fpm/status.html
--;
--; Note: The value must start with a leading slash (/). The value can be
--;       anything, but it may not be a good idea to use the .php extension or it
--;       may conflict with a real PHP file.
--; Default Value: not set 
--;pm.status_path = /status
-- 
--; The ping URI to call the monitoring page of FPM. If this value is not set, no
--; URI will be recognized as a ping page. This could be used to test from outside
--; that FPM is alive and responding, or to
--; - create a graph of FPM availability (rrd or such);
--; - remove a server from a group if it is not responding (load balancing);
--; - trigger alerts for the operating team (24/7).
--; Note: The value must start with a leading slash (/). The value can be
--;       anything, but it may not be a good idea to use the .php extension or it
--;       may conflict with a real PHP file.
--; Default Value: not set
--;ping.path = /ping
--
--; This directive may be used to customize the response of a ping request. The
--; response is formatted as text/plain with a 200 response code.
--; Default Value: pong
--;ping.response = pong
--
--; The access log file
--; Default: not set
--;access.log = log/$pool.access.log
--
--; The access log format.
--; The following syntax is allowed
--;  %%: the '%' character
--;  %C: %CPU used by the request
--;      it can accept the following format:
--;      - %{user}C for user CPU only
--;      - %{system}C for system CPU only
--;      - %{total}C  for user + system CPU (default)
--;  %d: time taken to serve the request
--;      it can accept the following format:
--;      - %{seconds}d (default)
--;      - %{miliseconds}d
--;      - %{mili}d
--;      - %{microseconds}d
--;      - %{micro}d
--;  %e: an environment variable (same as $_ENV or $_SERVER)
--;      it must be associated with embraces to specify the name of the env
--;      variable. Some exemples:
--;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
--;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
--;  %f: script filename
--;  %l: content-length of the request (for POST request only)
--;  %m: request method
--;  %M: peak of memory allocated by PHP
--;      it can accept the following format:
--;      - %{bytes}M (default)
--;      - %{kilobytes}M
--;      - %{kilo}M
--;      - %{megabytes}M
--;      - %{mega}M
--;  %n: pool name
--;  %o: output header
--;      it must be associated with embraces to specify the name of the header:
--;      - %{Content-Type}o
--;      - %{X-Powered-By}o
--;      - %{Transfert-Encoding}o
--;      - ....
--;  %p: PID of the child that serviced the request
--;  %P: PID of the parent of the child that serviced the request
--;  %q: the query string 
--;  %Q: the '?' character if query string exists
--;  %r: the request URI (without the query string, see %q and %Q)
--;  %R: remote IP address
--;  %s: status (response code)
--;  %t: server time the request was received
--;      it can accept a strftime(3) format:
--;      %d/%b/%Y:%H:%M:%S %z (default)
--;  %T: time the log has been written (the request has finished)
--;      it can accept a strftime(3) format:
--;      %d/%b/%Y:%H:%M:%S %z (default)
--;  %u: remote user
--;
--; Default: "%R - %u %t \"%m %r\" %s"
--;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
-- 
--; The log file for slow requests
--; Default Value: not set
--; Note: slowlog is mandatory if request_slowlog_timeout is set
--;slowlog = log/$pool.log.slow
-- 
--; The timeout for serving a single request after which a PHP backtrace will be
--; dumped to the 'slowlog' file. A value of '0s' means 'off'.
--; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
--; Default Value: 0
--;request_slowlog_timeout = 0
-- 
--; The timeout for serving a single request after which the worker process will
--; be killed. This option should be used when the 'max_execution_time' ini option
--; does not stop script execution for some reason. A value of '0' means 'off'.
--; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
--; Default Value: 0
--;request_terminate_timeout = 0
-- 
--; Set open file descriptor rlimit.
--; Default Value: system defined value
--;rlimit_files = 1024
-- 
--; Set max core size rlimit.
--; Possible Values: 'unlimited' or an integer greater or equal to 0
--; Default Value: system defined value
--;rlimit_core = 0
-- 
--; Chroot to this directory at the start. This value must be defined as an
--; absolute path. When this value is not set, chroot is not used.
--; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
--; of its subdirectories. If the pool prefix is not set, the global prefix
--; will be used instead.
--; Note: chrooting is a great security feature and should be used whenever 
--;       possible. However, all PHP paths will be relative to the chroot
--;       (error_log, sessions.save_path, ...).
--; Default Value: not set
--;chroot = 
-- 
--; Chdir to this directory at the start.
--; Note: relative path can be used.
--; Default Value: current directory or / when chroot
--;chdir = /var/www
-- 
--; Redirect worker stdout and stderr into main error log. If not set, stdout and
--; stderr will be redirected to /dev/null according to FastCGI specs.
--; Note: on highloaded environement, this can cause some delay in the page
--; process time (several ms).
--; Default Value: no
--;catch_workers_output = yes
--
--; Clear environment in FPM workers
--; Prevents arbitrary environment variables from reaching FPM worker processes
--; by clearing the environment in workers before env vars specified in this
--; pool configuration are added.
--; Setting to "no" will make all environment variables available to PHP code
--; via getenv(), $_ENV and $_SERVER.
--; Default Value: yes
--;clear_env = no
--
--; Limits the extensions of the main script FPM will allow to parse. This can
--; prevent configuration mistakes on the web server side. You should only limit
--; FPM to .php extensions to prevent malicious users to use other extensions to
--; exectute php code.
--; Note: set an empty value to allow all extensions.
--; Default Value: .php
--;security.limit_extensions = .php .php3 .php4 .php5
-- 
--; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
--; the current environment.
--; Default Value: clean env
--;env[HOSTNAME] = $HOSTNAME
--;env[PATH] = /usr/local/bin:/usr/bin:/bin
--;env[TMP] = /tmp
--;env[TMPDIR] = /tmp
--;env[TEMP] = /tmp
--
--; Additional php.ini defines, specific to this pool of workers. These settings
--; overwrite the values previously defined in the php.ini. The directives are the
--; same as the PHP SAPI:
--;   php_value/php_flag             - you can set classic ini defines which can
--;                                    be overwritten from PHP call 'ini_set'. 
--;   php_admin_value/php_admin_flag - these directives won't be overwritten by
--;                                     PHP call 'ini_set'
--; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
--
--; Defining 'extension' will load the corresponding shared extension from
--; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
--; overwrite previously defined php.ini values, but will append the new value
--; instead.
--
--; Note: path INI options can be relative and will be expanded with the prefix
--; (pool, global or @prefix@)
--
--; Default Value: nothing is defined by default except the values in php.ini and
--;                specified at startup with the -d argument
--;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
--;php_flag[display_errors] = off
--;php_admin_value[error_log] = /var/log/fpm-php.www.log
--;php_admin_flag[log_errors] = on
--;php_admin_value[memory_limit] = 32M
---- /dev/null	2007-02-13 18:29:53.000000000 +0200
-+++ php-5.6.4/sapi/fpm/php-fpm.conf-d.in	2015-01-01 17:19:55.621958470 +0200
-@@ -0,0 +1,406 @@
-+; Start a new pool named 'www'.
-+; the variable $pool can we used in any directive and will be replaced by the
-+; pool name ('www' here)
-+[www]
-+
-+; Per pool prefix
-+; It only applies on the following directives:
-+; - 'access.log'
-+; - 'slowlog'
-+; - 'listen' (unixsocket)
-+; - 'chroot'
-+; - 'chdir'
-+; - 'php_values'
-+; - 'php_admin_values'
-+; When not set, the global prefix (or @php_fpm_prefix@) applies instead.
-+; Note: This directive can also be relative to the global prefix.
-+; Default Value: none
-+;prefix = /path/to/pools/$pool
-+
-+; Unix user/group of processes
-+; Note: The user is mandatory. If the group is not set, the default user's group
-+;       will be used.
-+user = @php_fpm_user@
-+group = @php_fpm_group@
-+
-+; The address on which to accept FastCGI requests.
-+; Valid syntaxes are:
-+;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
-+;                            a specific port;
-+;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
-+;                            a specific port;
-+;   'port'                 - to listen on a TCP socket to all IPv4 addresses on a
-+;                            specific port;
-+;   '[::]:port'            - to listen on a TCP socket to all addresses
-+;                            (IPv6 and IPv4-mapped) on a specific port;
-+;   '/path/to/unix/socket' - to listen on a unix socket.
-+; Note: This value is mandatory.
-+listen = 127.0.0.1:9000
-+
-+; Set listen(2) backlog.
-+; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
-+;listen.backlog = 65535
-+
-+; Set permissions for unix socket, if one is used. In Linux, read/write
-+; permissions must be set in order to allow connections from a web server. Many
-+; BSD-derived systems allow connections regardless of permissions. 
-+; Default Values: user and group are set as the running user
-+;                 mode is set to 0660
-+;listen.owner = @php_fpm_user@
-+;listen.group = @php_fpm_group@
-+;listen.mode = 0660
-+ 
-+; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
-+; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
-+; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
-+; must be separated by a comma. If this value is left blank, connections will be
-+; accepted from any ip address.
-+; Default Value: any
-+;listen.allowed_clients = 127.0.0.1
-+
-+; Specify the nice(2) priority to apply to the pool processes (only if set)
-+; The value can vary from -19 (highest priority) to 20 (lower priority)
-+; Note: - It will only work if the FPM master process is launched as root
-+;       - The pool processes will inherit the master process priority
-+;         unless it specified otherwise
-+; Default Value: no set
-+; process.priority = -19
-+
-+; Choose how the process manager will control the number of child processes.
-+; Possible Values:
-+;   static  - a fixed number (pm.max_children) of child processes;
-+;   dynamic - the number of child processes are set dynamically based on the
-+;             following directives. With this process management, there will be
-+;             always at least 1 children.
-+;             pm.max_children      - the maximum number of children that can
-+;                                    be alive at the same time.
-+;             pm.start_servers     - the number of children created on startup.
-+;             pm.min_spare_servers - the minimum number of children in 'idle'
-+;                                    state (waiting to process). If the number
-+;                                    of 'idle' processes is less than this
-+;                                    number then some children will be created.
-+;             pm.max_spare_servers - the maximum number of children in 'idle'
-+;                                    state (waiting to process). If the number
-+;                                    of 'idle' processes is greater than this
-+;                                    number then some children will be killed.
-+;  ondemand - no children are created at startup. Children will be forked when
-+;             new requests will connect. The following parameter are used:
-+;             pm.max_children           - the maximum number of children that
-+;                                         can be alive at the same time.
-+;             pm.process_idle_timeout   - The number of seconds after which
-+;                                         an idle process will be killed.
-+; Note: This value is mandatory.
-+pm = dynamic
-+
-+; The number of child processes to be created when pm is set to 'static' and the
-+; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
-+; This value sets the limit on the number of simultaneous requests that will be
-+; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
-+; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
-+; CGI. The below defaults are based on a server without much resources. Don't
-+; forget to tweak pm.* to fit your needs.
-+; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
-+; Note: This value is mandatory.
-+pm.max_children = 5
-+
-+; The number of child processes created on startup.
-+; Note: Used only when pm is set to 'dynamic'
-+; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
-+pm.start_servers = 2
-+
-+; The desired minimum number of idle server processes.
-+; Note: Used only when pm is set to 'dynamic'
-+; Note: Mandatory when pm is set to 'dynamic'
-+pm.min_spare_servers = 1
-+
-+; The desired maximum number of idle server processes.
-+; Note: Used only when pm is set to 'dynamic'
-+; Note: Mandatory when pm is set to 'dynamic'
-+pm.max_spare_servers = 3
-+
-+; The number of seconds after which an idle process will be killed.
-+; Note: Used only when pm is set to 'ondemand'
-+; Default Value: 10s
-+;pm.process_idle_timeout = 10s;
-+ 
-+; The number of requests each child process should execute before respawning.
-+; This can be useful to work around memory leaks in 3rd party libraries. For
-+; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
-+; Default Value: 0
-+;pm.max_requests = 500
-+
-+; The URI to view the FPM status page. If this value is not set, no URI will be
-+; recognized as a status page. It shows the following informations:
-+;   pool                 - the name of the pool;
-+;   process manager      - static, dynamic or ondemand;
-+;   start time           - the date and time FPM has started;
-+;   start since          - number of seconds since FPM has started;
-+;   accepted conn        - the number of request accepted by the pool;
-+;   listen queue         - the number of request in the queue of pending
-+;                          connections (see backlog in listen(2));
-+;   max listen queue     - the maximum number of requests in the queue
-+;                          of pending connections since FPM has started;
-+;   listen queue len     - the size of the socket queue of pending connections;
-+;   idle processes       - the number of idle processes;
-+;   active processes     - the number of active processes;
-+;   total processes      - the number of idle + active processes;
-+;   max active processes - the maximum number of active processes since FPM
-+;                          has started;
-+;   max children reached - number of times, the process limit has been reached,
-+;                          when pm tries to start more children (works only for
-+;                          pm 'dynamic' and 'ondemand');
-+; Value are updated in real time.
-+; Example output:
-+;   pool:                 www
-+;   process manager:      static
-+;   start time:           01/Jul/2011:17:53:49 +0200
-+;   start since:          62636
-+;   accepted conn:        190460
-+;   listen queue:         0
-+;   max listen queue:     1
-+;   listen queue len:     42
-+;   idle processes:       4
-+;   active processes:     11
-+;   total processes:      15
-+;   max active processes: 12
-+;   max children reached: 0
-+;
-+; By default the status page output is formatted as text/plain. Passing either
-+; 'html', 'xml' or 'json' in the query string will return the corresponding
-+; output syntax. Example:
-+;   http://www.foo.bar/status
-+;   http://www.foo.bar/status?json
-+;   http://www.foo.bar/status?html
-+;   http://www.foo.bar/status?xml
-+;
-+; By default the status page only outputs short status. Passing 'full' in the
-+; query string will also return status for each pool process.
-+; Example: 
-+;   http://www.foo.bar/status?full
-+;   http://www.foo.bar/status?json&full
-+;   http://www.foo.bar/status?html&full
-+;   http://www.foo.bar/status?xml&full
-+; The Full status returns for each process:
-+;   pid                  - the PID of the process;
-+;   state                - the state of the process (Idle, Running, ...);
-+;   start time           - the date and time the process has started;
-+;   start since          - the number of seconds since the process has started;
-+;   requests             - the number of requests the process has served;
-+;   request duration     - the duration in µs of the requests;
-+;   request method       - the request method (GET, POST, ...);
-+;   request URI          - the request URI with the query string;
-+;   content length       - the content length of the request (only with POST);
-+;   user                 - the user (PHP_AUTH_USER) (or '-' if not set);
-+;   script               - the main script called (or '-' if not set);
-+;   last request cpu     - the %cpu the last request consumed
-+;                          it's always 0 if the process is not in Idle state
-+;                          because CPU calculation is done when the request
-+;                          processing has terminated;
-+;   last request memory  - the max amount of memory the last request consumed
-+;                          it's always 0 if the process is not in Idle state
-+;                          because memory calculation is done when the request
-+;                          processing has terminated;
-+; If the process is in Idle state, then informations are related to the
-+; last request the process has served. Otherwise informations are related to
-+; the current request being served.
-+; Example output:
-+;   ************************
-+;   pid:                  31330
-+;   state:                Running
-+;   start time:           01/Jul/2011:17:53:49 +0200
-+;   start since:          63087
-+;   requests:             12808
-+;   request duration:     1250261
-+;   request method:       GET
-+;   request URI:          /test_mem.php?N=10000
-+;   content length:       0
-+;   user:                 -
-+;   script:               /home/fat/web/docs/php/test_mem.php
-+;   last request cpu:     0.00
-+;   last request memory:  0
-+;
-+; Note: There is a real-time FPM status monitoring sample web page available
-+;       It's available in: @EXPANDED_DATADIR@/fpm/status.html
-+;
-+; Note: The value must start with a leading slash (/). The value can be
-+;       anything, but it may not be a good idea to use the .php extension or it
-+;       may conflict with a real PHP file.
-+; Default Value: not set 
-+;pm.status_path = /status
-+ 
-+; The ping URI to call the monitoring page of FPM. If this value is not set, no
-+; URI will be recognized as a ping page. This could be used to test from outside
-+; that FPM is alive and responding, or to
-+; - create a graph of FPM availability (rrd or such);
-+; - remove a server from a group if it is not responding (load balancing);
-+; - trigger alerts for the operating team (24/7).
-+; Note: The value must start with a leading slash (/). The value can be
-+;       anything, but it may not be a good idea to use the .php extension or it
-+;       may conflict with a real PHP file.
-+; Default Value: not set
-+;ping.path = /ping
-+
-+; This directive may be used to customize the response of a ping request. The
-+; response is formatted as text/plain with a 200 response code.
-+; Default Value: pong
-+;ping.response = pong
-+
-+; The access log file
-+; Default: not set
-+;access.log = log/$pool.access.log
-+
-+; The access log format.
-+; The following syntax is allowed
-+;  %%: the '%' character
-+;  %C: %CPU used by the request
-+;      it can accept the following format:
-+;      - %{user}C for user CPU only
-+;      - %{system}C for system CPU only
-+;      - %{total}C  for user + system CPU (default)
-+;  %d: time taken to serve the request
-+;      it can accept the following format:
-+;      - %{seconds}d (default)
-+;      - %{miliseconds}d
-+;      - %{mili}d
-+;      - %{microseconds}d
-+;      - %{micro}d
-+;  %e: an environment variable (same as $_ENV or $_SERVER)
-+;      it must be associated with embraces to specify the name of the env
-+;      variable. Some exemples:
-+;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
-+;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
-+;  %f: script filename
-+;  %l: content-length of the request (for POST request only)
-+;  %m: request method
-+;  %M: peak of memory allocated by PHP
-+;      it can accept the following format:
-+;      - %{bytes}M (default)
-+;      - %{kilobytes}M
-+;      - %{kilo}M
-+;      - %{megabytes}M
-+;      - %{mega}M
-+;  %n: pool name
-+;  %o: output header
-+;      it must be associated with embraces to specify the name of the header:
-+;      - %{Content-Type}o
-+;      - %{X-Powered-By}o
-+;      - %{Transfert-Encoding}o
-+;      - ....
-+;  %p: PID of the child that serviced the request
-+;  %P: PID of the parent of the child that serviced the request
-+;  %q: the query string 
-+;  %Q: the '?' character if query string exists
-+;  %r: the request URI (without the query string, see %q and %Q)
-+;  %R: remote IP address
-+;  %s: status (response code)
-+;  %t: server time the request was received
-+;      it can accept a strftime(3) format:
-+;      %d/%b/%Y:%H:%M:%S %z (default)
-+;  %T: time the log has been written (the request has finished)
-+;      it can accept a strftime(3) format:
-+;      %d/%b/%Y:%H:%M:%S %z (default)
-+;  %u: remote user
-+;
-+; Default: "%R - %u %t \"%m %r\" %s"
-+;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
-+ 
-+; The log file for slow requests
-+; Default Value: not set
-+; Note: slowlog is mandatory if request_slowlog_timeout is set
-+;slowlog = log/$pool.log.slow
-+ 
-+; The timeout for serving a single request after which a PHP backtrace will be
-+; dumped to the 'slowlog' file. A value of '0s' means 'off'.
-+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-+; Default Value: 0
-+;request_slowlog_timeout = 0
-+ 
-+; The timeout for serving a single request after which the worker process will
-+; be killed. This option should be used when the 'max_execution_time' ini option
-+; does not stop script execution for some reason. A value of '0' means 'off'.
-+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-+; Default Value: 0
-+;request_terminate_timeout = 0
-+ 
-+; Set open file descriptor rlimit.
-+; Default Value: system defined value
-+;rlimit_files = 1024
-+ 
-+; Set max core size rlimit.
-+; Possible Values: 'unlimited' or an integer greater or equal to 0
-+; Default Value: system defined value
-+;rlimit_core = 0
-+ 
-+; Chroot to this directory at the start. This value must be defined as an
-+; absolute path. When this value is not set, chroot is not used.
-+; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
-+; of its subdirectories. If the pool prefix is not set, the global prefix
-+; will be used instead.
-+; Note: chrooting is a great security feature and should be used whenever 
-+;       possible. However, all PHP paths will be relative to the chroot
-+;       (error_log, sessions.save_path, ...).
-+; Default Value: not set
-+;chroot = 
-+ 
-+; Chdir to this directory at the start.
-+; Note: relative path can be used.
-+; Default Value: current directory or / when chroot
-+;chdir = /var/www
-+ 
-+; Redirect worker stdout and stderr into main error log. If not set, stdout and
-+; stderr will be redirected to /dev/null according to FastCGI specs.
-+; Note: on highloaded environement, this can cause some delay in the page
-+; process time (several ms).
-+; Default Value: no
-+;catch_workers_output = yes
-+
-+; Clear environment in FPM workers
-+; Prevents arbitrary environment variables from reaching FPM worker processes
-+; by clearing the environment in workers before env vars specified in this
-+; pool configuration are added.
-+; Setting to "no" will make all environment variables available to PHP code
-+; via getenv(), $_ENV and $_SERVER.
-+; Default Value: yes
-+;clear_env = no
-+
-+; Limits the extensions of the main script FPM will allow to parse. This can
-+; prevent configuration mistakes on the web server side. You should only limit
-+; FPM to .php extensions to prevent malicious users to use other extensions to
-+; exectute php code.
-+; Note: set an empty value to allow all extensions.
-+; Default Value: .php
-+;security.limit_extensions = .php .php3 .php4 .php5
-+ 
-+; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
-+; the current environment.
-+; Default Value: clean env
-+;env[HOSTNAME] = $HOSTNAME
-+;env[PATH] = /usr/local/bin:/usr/bin:/bin
-+;env[TMP] = /tmp
-+;env[TMPDIR] = /tmp
-+;env[TEMP] = /tmp
-+
-+; Additional php.ini defines, specific to this pool of workers. These settings
-+; overwrite the values previously defined in the php.ini. The directives are the
-+; same as the PHP SAPI:
-+;   php_value/php_flag             - you can set classic ini defines which can
-+;                                    be overwritten from PHP call 'ini_set'. 
-+;   php_admin_value/php_admin_flag - these directives won't be overwritten by
-+;                                     PHP call 'ini_set'
-+; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
-+
-+; Defining 'extension' will load the corresponding shared extension from
-+; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
-+; overwrite previously defined php.ini values, but will append the new value
-+; instead.
-+
-+; Note: path INI options can be relative and will be expanded with the prefix
-+; (pool, global or @prefix@)
-+
-+; Default Value: nothing is defined by default except the values in php.ini and
-+;                specified at startup with the -d argument
-+;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
-+;php_flag[display_errors] = off
-+;php_admin_value[error_log] = /var/log/fpm-php.www.log
-+;php_admin_flag[log_errors] = on
-+;php_admin_value[memory_limit] = 32M
---- php-5.5.7/sapi/fpm/config.m4~	2013-12-16 17:57:03.000000000 +0200
-+++ php-5.5.7/sapi/fpm/config.m4	2013-12-16 18:00:34.936527309 +0200
-@@ -609,7 +609,7 @@
- 
-   PHP_ADD_BUILD_DIR(sapi/fpm/fpm)
-   PHP_ADD_BUILD_DIR(sapi/fpm/fpm/events)
--  PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html)
-+  PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/php-fpm.conf-d sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html)
-   PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/fpm/Makefile.frag])
- 
-   SAPI_FPM_PATH=sapi/fpm/php-fpm
---- php-5.6.2/sapi/fpm/Makefile.frag~	2014-10-15 15:59:32.000000000 +0300
-+++ php-5.6.2/sapi/fpm/Makefile.frag	2014-10-27 08:12:57.402883790 +0200
-@@ -11,8 +11,9 @@
- 	@$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT)
- 
- 	@echo "Installing PHP FPM config:        $(INSTALL_ROOT)$(sysconfdir)/" && \
--	$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir) || :
-+	$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/fpm.d || :
- 	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default || :
-+	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf-d $(INSTALL_ROOT)$(sysconfdir)/fpm.d/www.conf.default || :
- 
- 	@echo "Installing PHP FPM man page:      $(INSTALL_ROOT)$(mandir)/man8/"
- 	@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man8
diff --git a/mysql-lib-ver-mismatch.patch b/mysql-lib-ver-mismatch.patch
index d49d195..81d9261 100644
--- a/mysql-lib-ver-mismatch.patch
+++ b/mysql-lib-ver-mismatch.patch
@@ -4,17 +4,6 @@
  	zend_bool			self_alloced = 0;
  
  
--#if !defined(MYSQL_USE_MYSQLND)
-+#if 0 && !defined(MYSQL_USE_MYSQLND)
- 	if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
- 		php_error_docref(NULL TSRMLS_CC, E_NOTICE,
- 						"Headers and client library minor version mismatch. Headers:%d Library:%ld",
---- php-5.3.27/ext/mysql/php_mysql.c~	2013-11-20 00:19:11.000000000 +0200
-+++ php-5.3.27/ext/mysql/php_mysql.c	2013-11-20 00:20:01.719956531 +0200
-@@ -704,7 +704,7 @@
- 	zend_bool free_host=0, new_link=0;
- 	long connect_timeout;
- 
 -#if !defined(MYSQL_USE_MYSQLND)
 +#if 0 && !defined(MYSQL_USE_MYSQLND)
  	if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
diff --git a/pcre-shared.patch b/pcre-shared.patch
index 642207d..ae69ebd 100644
--- a/pcre-shared.patch
+++ b/pcre-shared.patch
@@ -1,5 +1,5 @@
---- php-5.5.0alpha6/ext/pcre/config0.m4~	2013-03-19 18:08:15.000000000 +0200
-+++ php-5.5.0alpha6/ext/pcre/config0.m4	2013-03-19 18:09:26.732804962 +0200
+--- php-7.0/ext/pcre/config0.m4~	2015-05-24 14:39:04.000000000 +0300
++++ php-7.0/ext/pcre/config0.m4	2015-05-24 14:53:49.980250297 +0300
 @@ -11,7 +11,7 @@
  
    if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
@@ -27,35 +27,35 @@
      
      AC_DEFINE(HAVE_PCRE, 1, [ ])
      PHP_ADD_INCLUDE($PCRE_INCDIR)
--    PHP_NEW_EXTENSION(pcre, php_pcre.c, no)
-+    PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared)
+-    PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
++    PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
      PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
 +    EXTRA_LIBS="$EXTRA_LIBS -lpcre"
    else
      AC_MSG_CHECKING([for PCRE library to use])
      AC_MSG_RESULT([bundled])
-@@ -61,7 +61,7 @@
-     				 pcrelib/pcre_tables.c pcrelib/pcre_valid_utf8.c \
-     				 pcrelib/pcre_version.c pcrelib/pcre_xclass.c"
-     PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcrelib"
+@@ -61,7 +62,7 @@
+     				 pcrelib/pcre_version.c pcrelib/pcre_xclass.c \
+     				 pcrelib/pcre_jit_compile.c"
+     PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcrelib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
 -    PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
 +    PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, $ext_shared,,$PHP_PCRE_CFLAGS)
      PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
      PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcrelib/])
      AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
---- php-5.3.1/ext/pcre/php_pcre.h	2009-11-30 20:59:04.046581246 +0200
-+++ php-5.3.1.pcre/ext/pcre/php_pcre.h	2009-11-30 21:38:06.435493243 +0000
+--- php-7.0/ext/pcre/php_pcre.h~	2015-05-21 17:57:06.000000000 +0300
++++ php-7.0/ext/pcre/php_pcre.h	2015-05-24 14:56:27.528425546 +0300
 @@ -34,7 +34,12 @@
  #endif
  
- PHPAPI char *php_pcre_replace(char *regex, int regex_len, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC);
+ PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int limit, int *replace_count);
 +#if COMPILE_DL_PCRE
 +#define pcre_get_compiled_regex pcre_get_compiled_regex_p
-+extern PHPAPI pcre* (*pcre_get_compiled_regex)(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
++extern PHPAPI pcre* (*pcre_get_compiled_regex)(zend_string *regex, pcre_extra **extra, int *options);
 +#else
- PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
+ PHPAPI pcre* pcre_get_compiled_regex(zend_string *regex, pcre_extra **extra, int *options);
 +#endif
- PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *coptions TSRMLS_DC);
+ PHPAPI pcre* pcre_get_compiled_regex_ex(zend_string *regex, pcre_extra **extra, int *preg_options, int *coptions);
  
  extern zend_module_entry pcre_module_entry;
 --- php-5.3.1/ext/pcre/php_pcre.c	2009-11-30 21:10:01.370473754 +0200
@@ -66,7 +66,7 @@
  
 +#if COMPILE_DL_PCRE
 +#undef pcre_get_compiled_regex
-+PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_options TSRMLS_DC);
++PHPAPI pcre* pcre_get_compiled_regex(zend_string *regex, pcre_extra **extra, int *options);
 +#endif
 +
  #include "ext/standard/php_string.h"
@@ -99,7 +99,7 @@
  
 +#if COMPILE_DL_PCRE
 +// will be visible in here
-+PHPAPI pcre* (*pcre_get_compiled_regex_p)(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
++PHPAPI pcre* (*pcre_get_compiled_regex_p)(zend_string *regex, pcre_extra **extra, int *options);
 +#endif
 +
  #define DEFAULT_SECTION_NAME "Default Browser Capability Settings"
@@ -116,3 +116,15 @@
  
  [Zend Modules]
  %aDone
+--- php-7.0.0beta3/main/php_ini.c~	2015-08-26 18:50:15.000000000 +0300
++++ php-7.0.0beta3/main/php_ini.c	2015-08-26 22:33:59.126957396 +0300
+@@ -765,8 +765,8 @@
+  */
+ void php_ini_register_extensions(void)
+ {
+-	zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
+ 	zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb);
++	zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
+ 
+ 	zend_llist_destroy(&extension_lists.engine);
+ 	zend_llist_destroy(&extension_lists.functions);
diff --git a/php-db.patch b/php-db.patch
index e9638f1..fbd0fb7 100644
--- a/php-db.patch
+++ b/php-db.patch
@@ -1,5 +1,5 @@
---- php-5.3.16/ext/dba/config.m4.orig	2012-09-06 11:15:09.743002303 +0200
-+++ php-5.3.16/ext/dba/config.m4	2012-09-06 11:28:12.192974701 +0200
+--- php-7.0.2/ext/dba/config.m4~	2016-01-11 00:42:48.000000000 +0200
++++ php-7.0.2/ext/dba/config.m4	2016-01-11 00:43:39.055351157 +0200
 @@ -287,6 +287,14 @@
        THIS_PREFIX=$i
        THIS_INCLUDE=$i/db4/db.h
@@ -15,3 +15,13 @@
      elif test -f "$i/include/db5.1/db.h"; then
        THIS_PREFIX=$i
        THIS_INCLUDE=$i/include/db5.1/db.h
+@@ -376,7 +376,7 @@
+       break
+     fi
+   done
+-  PHP_DBA_DB_CHECK(4, db-5.3 db-5.1 db-5.0 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
++  PHP_DBA_DB_CHECK(4, db-5.3 db-5.2 db-5.1 db-5.0 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
+ fi
+ PHP_DBA_STD_RESULT(db4,Berkeley DB4)
+ 
+
diff --git a/php-fcgi-error_log-no-newlines.patch b/php-fcgi-error_log-no-newlines.patch
index 321452f..83c4509 100644
--- a/php-fcgi-error_log-no-newlines.patch
+++ b/php-fcgi-error_log-no-newlines.patch
@@ -1,14 +1,16 @@
---- php-5.6.6/sapi/cgi/cgi_main.c.orig	2015-02-24 12:35:21.097436930 +0100
-+++ php-5.6.6/sapi/cgi/cgi_main.c	2015-02-24 12:38:49.851431030 +0100
-@@ -739,10 +739,7 @@
- 			int ret, len = strlen(message);
- 			char *buf = malloc(len+2);
+--- php-7.0/sapi/cgi/cgi_main.c~	2015-05-21 23:12:23.000000000 +0300
++++ php-7.0/sapi/cgi/cgi_main.c	2015-05-21 23:13:24.947976867 +0300
+@@ -701,12 +701,8 @@
+ 		request = (fcgi_request*) SG(server_context);
+ 		if (request) {
+ 			int ret, len = (int)strlen(message);
+-			char *buf = malloc(len+2);
  
 -			memcpy(buf, message, len);
 -			memcpy(buf + len, "\n", sizeof("\n"));
--			ret = fcgi_write(request, FCGI_STDERR, buf, len + 1);
+-			ret = fcgi_write(request, FCGI_STDERR, buf, (int)(len + 1));
 -			free(buf);
-+			fcgi_write(request, FCGI_STDERR, message, len);
++			ret = fcgi_write(request, FCGI_STDERR, message, len);
  			if (ret < 0) {
  				php_handle_aborted_connection();
  			}
diff --git a/php-fcgi-graceful.patch b/php-fcgi-graceful.patch
index 26f86f3..505462f 100644
--- a/php-fcgi-graceful.patch
+++ b/php-fcgi-graceful.patch
@@ -18,8 +18,8 @@ while ($i < 35) {
 echo "end!<br>\n";
 ?>
 
---- php-5.4.0alpha2/sapi/cgi/cgi_main.c~	2011-08-05 13:26:14.000000000 +0300
-+++ php-5.4.0alpha2/sapi/cgi/cgi_main.c	2011-08-05 13:57:17.564708456 +0300
+--- php-7.0.0beta1/sapi/cgi/cgi_main.c~	2015-07-13 16:14:53.000000000 +0300
++++ php-7.0.0beta1/sapi/cgi/cgi_main.c	2015-07-15 13:51:32.072326529 +0300
 @@ -101,6 +101,9 @@
   */
  static int parent = 1;
@@ -60,18 +60,19 @@ echo "end!<br>\n";
  	fcgi_request *request = NULL;
  	int repeats = 1;
  	int benchmark = 0;
-@@ -1579,9 +1596,13 @@
- 					parent = 0;
+@@ -2050,10 +2050,13 @@
+ 						 */
+ 						parent = 0;
  
- 					/* don't catch our signals */
--					sigaction(SIGTERM, &old_term, 0);
- 					sigaction(SIGQUIT, &old_quit, 0);
- 					sigaction(SIGINT,  &old_int,  0);
+-						/* don't catch our signals */
+-						sigaction(SIGTERM, &old_term, 0);
+ 						sigaction(SIGQUIT, &old_quit, 0);
+ 						sigaction(SIGINT,  &old_int,  0);
 +
-+					/* call graceful shutdown handler for SIGTERM */
-+					act.sa_flags = 0;
-+					act.sa_handler = fastcgi_graceful_shutdown;
-+					sigaction(SIGTERM, &act, &old_term);
- 					break;
- 				case -1:
- 					perror("php (pre-forking)");
++						/* call graceful shutdown handler for SIGTERM */
++						act.sa_flags = 0;
++						act.sa_handler = fastcgi_graceful_shutdown;
++						sigaction(SIGTERM, &act, &old_term);
+ 						break;
+ 					case -1:
+ 						perror("php (pre-forking)");
diff --git a/php-fpm-config.patch b/php-fpm-config.patch
index cb2b91d..c4b2d8a 100644
--- a/php-fpm-config.patch
+++ b/php-fpm-config.patch
@@ -17,31 +17,19 @@
  
  ; syslog_facility is used to specify what type of program is logging the
  ; message. This lets syslogd specify that messages from different facilities
-@@ -115,3 +115,11 @@
- ; ports and different management options.  The name of the pool will be
- ; used in logs and stats. There is no limitation on the number of pools which
- ; FPM can handle. Your system will tell you anyway :)
-+
-+; Include one or more files. If glob(3) exists, it is used to include a bunch of
-+; files from a glob(3) pattern. This directive can be used everywhere in the
-+; file.
-+; Relative path can also be used. They will be prefixed by:
-+;  - the global prefix if it's been set (-p argument)
-+;  - @prefix@ otherwise
-+include=/etc/php/fpm.d/*.conf
---- php-5.6.2.old/sapi/fpm/php-fpm.conf-d.in	2014-10-27 08:07:47.762117299 +0200
-+++ php-5.6.2/sapi/fpm/php-fpm.conf-d.in	2014-10-27 08:23:41.232196777 +0200
-@@ -32,7 +32,7 @@
- ;                            specific port;
+--- php-5.6.2.old/sapi/fpm/www.conf.in	2014-10-27 08:07:47.762117299 +0200
++++ php-5.6.2/sapi/fpm/www.conf.in	2014-10-27 08:23:41.232196777 +0200
+@@ -33,7 +33,7 @@
+ ;                            (IPv6 and IPv4-mapped) on a specific port;
  ;   '/path/to/unix/socket' - to listen on a unix socket.
  ; Note: This value is mandatory.
 -listen = 127.0.0.1:9000
 +listen = /var/run/php/@processname@.sock
  
  ; Set listen(2) backlog.
- ; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
-@@ -41,9 +41,9 @@
- ; BSD-derived systems allow connections regardless of permissions. 
+ ; Default Value: 511 (-1 on FreeBSD and OpenBSD)
+@@ -44,9 +44,9 @@
+ ; BSD-derived systems allow connections regardless of permissions.
  ; Default Values: user and group are set as the running user
  ;                 mode is set to 0660
 -;listen.owner = @php_fpm_user@
@@ -50,10 +38,10 @@
 +listen.owner = root
 +listen.group = @php_fpm_group@
 +listen.mode = 0660
-  
- ; List of ipv4 addresses of FastCGI clients which are allowed to connect.
- ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
-@@ -53,7 +53,7 @@
+ ; When POSIX Access Control Lists are supported you can set them using
+ ; these options, value is a comma separated list of user/group names.
+ ; When set, listen.owner and listen.group are ignored
+@@ -59,7 +59,7 @@
  ; must be separated by a comma. If this value is left blank, connections will be
  ; accepted from any ip address.
  ; Default Value: any
@@ -62,7 +50,7 @@
  
  ; Specify the nice(2) priority to apply to the pool processes (only if set)
  ; The value can vary from -19 (highest priority) to 20 (lower priority)
-@@ -372,7 +372,7 @@
+@@ -382,7 +382,7 @@
  ; the current environment.
  ; Default Value: clean env
  ;env[HOSTNAME] = $HOSTNAME
@@ -87,11 +75,11 @@
 @@ -12,8 +12,8 @@
  
  	@echo "Installing PHP FPM config:        $(INSTALL_ROOT)$(sysconfdir)/" && \
- 	$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/fpm.d || :
+ 	$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d || :
 -	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default || :
--	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf-d $(INSTALL_ROOT)$(sysconfdir)/fpm.d/www.conf.default || :
+-	@$(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d/www.conf.default || :
 +	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf || :
-+	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf-d $(INSTALL_ROOT)$(sysconfdir)/fpm.d/www.conf || :
++	@$(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d/www.conf || :
  
  	@echo "Installing PHP FPM man page:      $(INSTALL_ROOT)$(mandir)/man8/"
  	@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man8
diff --git a/php-fpm-shared.patch b/php-fpm-shared.patch
index d137526..4b66857 100644
--- a/php-fpm-shared.patch
+++ b/php-fpm-shared.patch
@@ -1,11 +1,11 @@
 --- php-5.4.0alpha2/sapi/fpm/config.m4~	2011-06-26 18:48:11.000000000 +0300
 +++ php-5.4.0alpha2/sapi/fpm/config.m4	2011-08-07 11:46:26.970876686 +0300
-@@ -458,7 +458,7 @@
-         BUILD_FPM="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FPM_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
+@@ -718,7 +718,7 @@
+         BUILD_FPM="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_FPM_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
        ;;
        *)
--        BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
-+        BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la  \$(PHP_BINARY_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(SAPI_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
+-        BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
++        BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(SAPI_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
        ;;
    esac
  
@@ -14,8 +14,8 @@
 @@ -1,6 +1,6 @@
  fpm: $(SAPI_FPM_PATH)
  
--$(SAPI_FPM_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FPM_OBJS)
-+$(SAPI_FPM_PATH): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_FPM_OBJS) $(SAPI_EXTRA_DEPS)
+-$(SAPI_FPM_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_FPM_OBJS)
++$(SAPI_FPM_PATH): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_FPM_OBJS) $(SAPI_EXTRA_DEPS)
  	$(BUILD_FPM)
  
  install-fpm: $(SAPI_FPM_PATH)
diff --git a/php-ini.patch b/php-ini.patch
index 9c247b9..796cddd 100644
--- a/php-ini.patch
+++ b/php-ini.patch
@@ -1,5 +1,5 @@
---- php-5.6.12.orig/php.ini	2015-08-06 07:55:57.000000000 +0000
-+++ php-5.6.12/php.ini	2015-08-09 14:51:00.224790532 +0000
+--- php-7.0.1/php.ini	2015-12-16 10:41:54.000000000 +0000
++++ php-7.0.1/php.ini	2015-12-18 12:13:28.614443158 +0000
 @@ -82,6 +82,20 @@
  ; much more verbose when it comes to errors. We recommend using the
  ; development version only in development environments, as errors shown to
@@ -48,7 +48,7 @@
  ; Development Value: Off
  ; Production Value: Off
  ; http://php.net/short-open-tag
-@@ -360,7 +374,7 @@
+@@ -356,7 +370,7 @@
  ; threat in any way, but it makes it possible to determine whether you use PHP
  ; on your server or not.
  ; http://php.net/expose-php
@@ -57,7 +57,7 @@
  
  ;;;;;;;;;;;;;;;;;;;
  ; Resource Limits ;
-@@ -731,7 +745,7 @@
+@@ -720,7 +734,7 @@
  
  ; Directory in which the loadable extensions (modules) reside.
  ; http://php.net/extension-dir
@@ -66,7 +66,7 @@
  ; On windows:
  ; extension_dir = "ext"
  
-@@ -745,53 +759,6 @@
+@@ -734,53 +748,6 @@
  ; http://php.net/enable-dl
  enable_dl = Off
  
@@ -120,14 +120,14 @@
  ;;;;;;;;;;;;;;;;
  ; File Uploads ;
  ;;;;;;;;;;;;;;;;
-@@ -869,48 +836,8 @@
+@@ -858,46 +825,8 @@
  ; If you only provide the name of the extension, PHP will look for it in its
  ; default extension directory.
  ;
 -; Windows Extensions
 -; Note that ODBC support is built in, so no dll is needed for it.
--; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
--; extension folders as well as the separate PECL DLL download (PHP 5).
+-; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5+)
+-; extension folders as well as the separate PECL DLL download (PHP 5+).
 -; Be sure to appropriately set the extension_dir directive.
 -;
 -;extension=php_bz2.dll
@@ -142,7 +142,6 @@
 -;extension=php_ldap.dll
 -;extension=php_mbstring.dll
 -;extension=php_exif.dll      ; Must be after mbstring as it depends on it
--;extension=php_mysql.dll
 -;extension=php_mysqli.dll
 -;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
 -;extension=php_openssl.dll
@@ -155,14 +154,13 @@
 -;extension=php_pgsql.dll
 -;extension=php_shmop.dll
 -
--; The MIBS data available in the PHP distribution must be installed. 
--; See http://www.php.net/manual/en/snmp.installation.php 
+-; The MIBS data available in the PHP distribution must be installed.
+-; See http://www.php.net/manual/en/snmp.installation.php
 -;extension=php_snmp.dll
 -
 -;extension=php_soap.dll
 -;extension=php_sockets.dll
 -;extension=php_sqlite3.dll
--;extension=php_sybase_ct.dll
 -;extension=php_tidy.dll
 -;extension=php_xmlrpc.dll
 -;extension=php_xsl.dll
@@ -171,7 +169,7 @@
  
  ;;;;;;;;;;;;;;;;;;;
  ; Module Settings ;
-@@ -948,19 +875,19 @@
+@@ -935,19 +864,19 @@
  ; Use of this INI entry is deprecated, use global input_encoding instead.
  ; If empty, default_charset or input_encoding or iconv.input_encoding is used.
  ; The precedence is: default_charset < intput_encoding < iconv.input_encoding
@@ -194,17 +192,7 @@
  
  [intl]
  ;intl.default_locale =
-@@ -1174,6 +1101,9 @@
- ; http://php.net/mysql.connect-timeout
- mysql.connect_timeout = 60
- 
-+; The name of the character set to use as the default character set.
-+;mysql.connect_charset=utf8
-+
- ; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
- ; SQL-Errors will be displayed.
- ; http://php.net/mysql.trace-mode
-@@ -1213,6 +1143,9 @@
+@@ -1146,6 +1075,9 @@
  ; http://php.net/mysqli.default-socket
  mysqli.default_socket =
  
@@ -214,7 +202,7 @@
  ; Default host for mysql_connect() (doesn't apply in safe mode).
  ; http://php.net/mysqli.default-host
  mysqli.default_host =
-@@ -1379,7 +1312,7 @@
+@@ -1273,7 +1205,7 @@
  
  [browscap]
  ; http://php.net/browscap
@@ -223,7 +211,7 @@
  
  [Session]
  ; Handler used to store/retrieve data.
-@@ -1839,7 +1772,7 @@
+@@ -1696,7 +1628,7 @@
  
  ; Sets the directory name where SOAP extension will put cache files.
  ; http://php.net/soap.wsdl-cache-dir
diff --git a/php-mod_php.conf b/php-mod_php.conf
index a5f5f59..100c4c8 100644
--- a/php-mod_php.conf
+++ b/php-mod_php.conf
@@ -1,6 +1,6 @@
-LoadModule php5_module modules/libphp5.so
+LoadModule php7_module modules/mod_php.so
 
-<IfModule mod_php5.c>
+<IfModule mod_php7.c>
 	<Files *.php>
 		AddType application/x-httpd-php .php
 	</Files>
diff --git a/php-mysql-charsetphpini.patch b/php-mysql-charsetphpini.patch
deleted file mode 100644
index 37ff15b..0000000
--- a/php-mysql-charsetphpini.patch
+++ /dev/null
@@ -1,76 +0,0 @@
---- php-5.5.0RC2/ext/mysql/php_mysql.c~	2013-06-11 22:12:11.000000000 +0300
-+++ php-5.5.0RC2/ext/mysql/php_mysql.c	2013-06-11 22:16:04.192270533 +0300
-@@ -360,6 +360,7 @@
- 	PHP_INI_ENTRY("mysql.default_port",				NULL,	PHP_INI_ALL,		OnMySQLPort)
- 	STD_PHP_INI_ENTRY("mysql.default_socket",		NULL,	PHP_INI_ALL,		OnUpdateStringUnempty,	default_socket,	zend_mysql_globals,		mysql_globals)
- 	STD_PHP_INI_ENTRY("mysql.connect_timeout",		"60",	PHP_INI_ALL,		OnUpdateLong,		connect_timeout, 	zend_mysql_globals,		mysql_globals)
-+	STD_PHP_INI_ENTRY("mysql.connect_charset",		NULL,	PHP_INI_ALL,		OnUpdateString,		connect_charset,	zend_mysql_globals,		mysql_globals)
- 	STD_PHP_INI_BOOLEAN("mysql.trace_mode",			"0",	PHP_INI_ALL,		OnUpdateLong,		trace_mode, 		zend_mysql_globals,		mysql_globals)
- PHP_INI_END()
- /* }}} */
-@@ -376,6 +377,7 @@
- 	mysql_globals->connect_errno = 0;
- 	mysql_globals->connect_error = NULL;
- 	mysql_globals->connect_timeout = 0;
-+	mysql_globals->connect_charset = NULL;
- 	mysql_globals->trace_mode = 0;
- 	mysql_globals->result_allocated = 0;
- }
-@@ -723,6 +723,7 @@
- {
- 	char *user=NULL, *passwd=NULL, *host_and_port=NULL, *socket=NULL, *tmp=NULL, *host=NULL;
- 	int  user_len = 0, passwd_len = 0, host_len = 0;
-+	char *connect_charset=NULL;
- 	char *hashed_details=NULL;
- 	int hashed_details_length, port = MYSQL_PORT;
- 	long client_flags = 0;
-@@ -527,6 +530,7 @@
- 
- 
- 	connect_timeout = MySG(connect_timeout);
-+	connect_charset = MySG(connect_charset);
- 
- 	socket = MySG(default_socket);
- 
---- php-5.3.1/ext/mysql/php_mysql.c~	2010-02-20 00:51:52.000000000 +0200
-+++ php-5.3.1/ext/mysql/php_mysql.c	2010-02-20 00:55:43.475653264 +0200
-@@ -777,6 +777,10 @@
- 			if (connect_timeout != -1) {
- 				mysql_options(mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
- 			}
-+
-+			if (connect_charset != NULL)
-+				mysql_options(mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
-+
- #ifndef MYSQL_USE_MYSQLND
- 			if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL)
- #else
-@@ -826,6 +830,8 @@
- #endif	
- 			if (mysql_ping(mysql->conn)) {
- 				if (mysql_errno(mysql->conn) == 2006) {
-+					if (connect_charset != NULL)
-+						mysql_options(mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
- #ifndef MYSQL_USE_MYSQLND
- 					if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL)
- #else
-@@ -898,6 +904,9 @@
- 		if (connect_timeout != -1)
- 				mysql_options(mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
- 
-+		if (connect_charset != NULL)
-+			mysql_options(mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
-+
- #ifndef MYSQL_USE_MYSQLND
- 		if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) 
- #else
---- php-5.2.5_p20080206.orig/ext/mysql/php_mysql_structs.h	2008-02-06 14:22:57.510605687 +0100
-+++ php-5.2.5_p20080206/ext/mysql/php_mysql_structs.h	2008-02-06 14:23:27.764590355 +0100
-@@ -103,6 +103,7 @@
- 	long default_port;
- 	char *default_host, *default_user, *default_password;
- 	char *default_socket;
-+	char *connect_charset;
- 	char *connect_error;
- 	long connect_errno;
- 	long connect_timeout;
diff --git a/php-mysql-nowarning.patch b/php-mysql-nowarning.patch
deleted file mode 100644
index ee6e11c..0000000
--- a/php-mysql-nowarning.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- php-5.3.6/ext/mysql/php_mysql.c~	2011-04-13 20:47:29.263652096 +0200
-+++ php-5.3.6/ext/mysql/php_mysql.c	2011-04-13 20:48:30.206453191 +0200
-@@ -706,7 +706,7 @@
- 
- #if !defined(MYSQL_USE_MYSQLND)
- 	if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
--		php_error_docref(NULL TSRMLS_CC, E_WARNING,
-+		php_error_docref(NULL TSRMLS_CC, E_NOTICE,
- 						"Headers and client library minor version mismatch. Headers:%d Library:%ld",
- 						MYSQL_VERSION_ID, mysql_get_client_version());
- 	}
---- php-5.3.6/ext/mysqli/mysqli_nonapi.c~	2011-04-13 20:47:29.273652556 +0200
-+++ php-5.3.6/ext/mysqli/mysqli_nonapi.c	2011-04-13 20:48:41.070285840 +0200
-@@ -75,7 +75,7 @@
- 
- #if !defined(MYSQL_USE_MYSQLND)
- 	if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
--		php_error_docref(NULL TSRMLS_CC, E_WARNING,
-+		php_error_docref(NULL TSRMLS_CC, E_NOTICE,
- 						"Headers and client library minor version mismatch. Headers:%d Library:%ld",
- 						MYSQL_VERSION_ID, mysql_get_client_version());
- 	}
diff --git a/php-mysqli-charsetphpini.patch b/php-mysqli-charsetphpini.patch
index 895a1a7..29145b7 100644
--- a/php-mysqli-charsetphpini.patch
+++ b/php-mysqli-charsetphpini.patch
@@ -1,14 +1,14 @@
---- php-5.3.1/ext/mysqli/mysqli.c~	2010-02-20 00:58:34.000000000 +0200
-+++ php-5.3.1/ext/mysqli/mysqli.c	2010-02-20 01:00:22.459111311 +0200
-@@ -602,6 +602,7 @@
+--- php-7.0.1/ext/mysqli/mysqli.c	2015-12-16 10:42:04.000000000 +0000
++++ php-7.0.1/ext/mysqli/mysqli.c	2015-12-28 15:16:20.868443158 +0000
+@@ -522,6 +522,7 @@ PHP_INI_BEGIN()
  #else
  	STD_PHP_INI_ENTRY("mysqli.default_socket",			NULL,	PHP_INI_ALL,		OnUpdateStringUnempty,	default_socket,	zend_mysqli_globals,		mysqli_globals)
  #endif
 +	STD_PHP_INI_ENTRY("mysqli.connect_charset",			NULL,	PHP_INI_ALL,		OnUpdateString,		connect_charset,	zend_mysqli_globals,		mysqli_globals)
  	STD_PHP_INI_BOOLEAN("mysqli.reconnect",				"0",	PHP_INI_SYSTEM,		OnUpdateLong,		reconnect,			zend_mysqli_globals,		mysqli_globals)
  	STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile",	"1",	PHP_INI_SYSTEM,		OnUpdateLong,		allow_local_infile,	zend_mysqli_globals,		mysqli_globals)
- #ifdef MYSQLI_USE_MYSQLND
-@@ -475,6 +476,7 @@
+ PHP_INI_END()
+@@ -545,6 +546,7 @@ static PHP_GINIT_FUNCTION(mysqli)
  	mysqli_globals->default_user = NULL;
  	mysqli_globals->default_pw = NULL;
  	mysqli_globals->default_socket = NULL;
@@ -16,18 +16,18 @@
  	mysqli_globals->reconnect = 0;
  	mysqli_globals->report_mode = 0;
  	mysqli_globals->report_ht = 0;
---- php-5.3.4/ext/mysqli/mysqli_nonapi.c~	2010-12-12 23:07:03.000000000 +0200
-+++ php-5.3.4/ext/mysqli/mysqli_nonapi.c	2010-12-12 23:07:36.497424912 +0200
-@@ -61,7 +61,7 @@
+--- php-7.0.1/ext/mysqli/mysqli_nonapi.c	2015-12-16 10:42:03.000000000 +0000
++++ php-7.0.1/ext/mysqli/mysqli_nonapi.c	2015-12-28 15:23:36.769443158 +0000
+@@ -61,7 +61,7 @@ void mysqli_common_connect(INTERNAL_FUNC
  	MY_MYSQL			*mysql = NULL;
  	MYSQLI_RESOURCE		*mysqli_resource = NULL;
  	zval				*object = getThis();
 -	char				*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
 +	char				*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL, *connect_charset=NULL;
- 	int					hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
+ 	size_t					hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
  	zend_bool			persistent = FALSE;
- 	long				port = 0, flags = 0;
-@@ -241,6 +241,12 @@
+ 	zend_long				port = 0, flags = 0;
+@@ -233,6 +233,12 @@ void mysqli_common_connect(INTERNAL_FUNC
  	}
  #endif
  
@@ -38,15 +38,15 @@
 +	}
 +
  #if !defined(MYSQLI_USE_MYSQLND)
- 	if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname, port, socket, CLIENT_MULTI_RESULTS) == NULL)
- #else
---- php-5.3.1/ext/mysqli/php_mysqli_structs.h~	2009-10-14 16:51:25.000000000 +0300
-+++ php-5.3.1/ext/mysqli/php_mysqli_structs.h	2010-02-20 01:04:56.512214846 +0200
-@@ -358,6 +358,7 @@
+ 	/* BC for prior to bug fix #53425 */
+ 	flags |= CLIENT_MULTI_RESULTS;
+--- php-7.0.1/ext/mysqli/php_mysqli_structs.h	2015-12-28 15:16:20.870443158 +0000
++++ php-7.0.1/ext/mysqli/php_mysqli_structs.h	2015-12-28 15:23:04.136443158 +0000
+@@ -330,6 +330,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqli)
  	char			*default_user;
  	char			*default_socket;
  	char			*default_pw;
 +	char			*connect_charset;
- 	long			reconnect;
- 	long			allow_local_infile;
- 	long			strict;
+ 	zend_long			reconnect;
+ 	zend_long			allow_local_infile;
+ 	zend_long			strict;
diff --git a/php-sapi-ini-file.patch b/php-sapi-ini-file.patch
index 7dab0cc..d18142a 100644
--- a/php-sapi-ini-file.patch
+++ b/php-sapi-ini-file.patch
@@ -1,6 +1,11 @@
---- php-5.4.0RC3/main/php_ini.c~	2011-12-10 03:35:27.000000000 +0200
-+++ php-5.4.0RC3/main/php_ini.c	2011-12-10 03:36:08.930154336 +0200
-@@ -358,6 +358,11 @@
+to test which is main php.ini:
+$ php -r 'var_dump(array(get_cfg_var("cfg_file_path"),php_ini_loaded_file()));'
+
+https://github.com/pld-linux/php/commit/762ec2e
+
+--- php-7.0.0RC6.orig/main/php_ini.c	2015-11-10 23:58:52.227101032 +0200
++++ php-7.0.0RC6/main/php_ini.c	2015-11-11 00:01:43.502674750 +0200
+@@ -375,12 +375,19 @@
  }
  /* }}} */
  
@@ -11,48 +16,91 @@
 +
  /* {{{ php_init_config
   */
- int php_init_config(TSRMLS_D)
-@@ -480,6 +485,24 @@
+ int php_init_config(void)
+ {
+ 	char *php_ini_file_name = NULL;
+ 	char *php_ini_search_path = NULL;
++	// value for php_ini_loaded_file() to be stored into php_ini_opened_path
++	char *php_ini_loaded_file = NULL;
+ 	int php_ini_scanned_path_len;
+ 	char *open_basedir;
+ 	int free_ini_search_path = 0;
+@@ -557,8 +564,26 @@
  				}
  			}
  		}
 +		/* Search (global) php.ini file in search path */
 +		if (!fh.handle.fp) {
-+			fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
++			fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path);
 +			if (fh.handle.fp) {
-+				fh.filename = php_ini_opened_path;
-+				//PG(safe_mode) = safe_mode_state;
++				fh.filename = ZSTR_VAL(opened_path);
++
++				// parse the ini file now
 +				PG(open_basedir) = open_basedir;
 +				fh.type = ZEND_HANDLE_FP;
 +				zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
-+				//safe_mode_state = PG(safe_mode);
 +				open_basedir = PG(open_basedir);
-+				//PG(safe_mode) = 0;
 +				PG(open_basedir) = NULL;
 +				fh.handle.fp = NULL;
-+				efree(php_ini_opened_path);
-+				fh.filename = php_ini_opened_path = NULL;
++
++				php_ini_loaded_file = estrdup(fh.filename);
++				fh.filename = NULL;
 +			}
 +		}
  
- 		/* Otherwise search for php-%sapi-module-name%.ini file in search path */
+-		/* Otherwise search for php-%sapi-module-name%.ini file in search path */
++		/* Also search for php-%sapi-module-name%.ini file in search path */
  		if (!fh.handle.fp) {
-@@ -492,14 +515,6 @@
- 				fh.filename = php_ini_opened_path;
+ 			const char *fmt = "php-%s.ini";
+ 			char *ini_fname;
+@@ -568,15 +593,8 @@
+ 			if (fh.handle.fp) {
+ 				fh.filename = ZSTR_VAL(opened_path);
  			}
- 		}
--
+-		}
+ 
 -		/* If still no ini file found, search for php.ini file in search path */
 -		if (!fh.handle.fp) {
--			fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
+-			fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path);
 -			if (fh.handle.fp) {
--				fh.filename = php_ini_opened_path;
+-				fh.filename = ZSTR_VAL(opened_path);
 -			}
 -		}
++ 		}
  	}
  
  	if (free_ini_search_path) {
-@@ -645,13 +645,15 @@ int php_init_config(TSRMLS_D)
+@@ -593,14 +611,28 @@
+ 
+ 		{
+ 			zval tmp;
++			// use main php.ini if loaded
++			// see https://github.com/pld-linux/php/commit/762ec2e
++			// test with:
++			// php -r 'var_dump(array(get_cfg_var("cfg_file_path"),php_ini_loaded_file()));'
++			if (php_ini_loaded_file) {
++				if (fh.filename) {
++					efree((char *)fh.filename);
++				}
++				fh.filename = php_ini_loaded_file;
++			}
+ 
+ 			ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
+ 			zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
+ 			if (opened_path) {
+ 				zend_string_release(opened_path);
+-			} else {
++			}
++
++			if (fh.filename) {
+ 				efree((char *)fh.filename);
++				fh.filename = NULL;
+ 			}
++
+ 			php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
+ 		}
+ 	}
+@@ -624,13 +656,15 @@
  		zend_llist scanned_ini_list;
  		zend_llist_element *element;
  		int l, total_l = 0;
@@ -69,13 +117,12 @@
  		for (debpath = bufpath ; debpath ; debpath=endpath) {
  			endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR);
  			if (endpath) {
-@@ -664,7 +666,7 @@ int php_init_config(TSRMLS_D)
+@@ -643,7 +677,7 @@
  			}
- 			lenpath = strlen(debpath);
+ 			lenpath = (int)strlen(debpath);
  
 -			if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) {
 +			if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_csort)) > 0) {
  
  				for (i = 0; i < ndir; i++) {
  
-
diff --git a/php-shared.patch b/php-shared.patch
index 2aaa1d5..b414183 100644
--- a/php-shared.patch
+++ b/php-shared.patch
@@ -1,3 +1,15 @@
+--- php-7.0.0RC3/configure.in~	2015-09-26 14:55:35.000000000 +0300
++++ php-7.0.0RC3/configure.in	2015-09-26 15:13:29.581882625 +0300
+@@ -224,6 +224,9 @@
+ dnl check for -R, etc. switch
+ PHP_RUNPATH_SWITCH
+ 
++dnl Always shared
++PHP_BUILD_SHARED
++
+ dnl Checks for some support/generator progs
+ PHP_PROG_AWK
+ PHP_PROG_BISON
 --- php-5.2.4/Makefile.global~	2007-08-31 19:13:58.000000000 +0300
 +++ php-5.2.4/Makefile.global	2007-08-31 19:19:33.799017413 +0300
 @@ -13,8 +13,12 @@
@@ -29,24 +41,24 @@
  				break; \
  			fi; \
  		done; \
---- php-5.4.0alpha2/sapi/cgi/config9.m4~	2010-11-14 01:13:07.000000000 +0200
-+++ php-5.4.0alpha2/sapi/cgi/config9.m4	2011-08-01 10:28:47.495056372 +0300
+--- php-7.0.0beta1/sapi/cgi/config9.m4~	2015-07-10 15:11:43.000000000 +0300
++++ php-7.0.0beta1/sapi/cgi/config9.m4	2015-07-13 16:03:06.900955209 +0300
 @@ -64,7 +64,7 @@
-         BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_CGI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
+         BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_CGI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
        ;;
        *)
--        BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
-+        BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_BINARY_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
+-        BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
++        BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
        ;;
      esac
  
---- php-5.4.0alpha2/sapi/cgi/Makefile.frag~	2010-11-14 01:13:07.000000000 +0200
-+++ php-5.4.0alpha2/sapi/cgi/Makefile.frag	2011-08-01 12:21:29.155180914 +0300
+--- php-7.0.0beta1/sapi/cgi/Makefile.frag~	2015-07-10 15:11:43.000000000 +0300
++++ php-7.0.0beta1/sapi/cgi/Makefile.frag	2015-07-13 16:03:56.810212555 +0300
 @@ -1,6 +1,6 @@
  cgi: $(SAPI_CGI_PATH)
  
--$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_CGI_OBJS)
-+$(SAPI_CGI_PATH): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_CGI_OBJS)
+-$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_CGI_OBJS)
++$(SAPI_CGI_PATH): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_CGI_OBJS)
  	$(BUILD_CGI)
  
  install-cgi: $(SAPI_CGI_PATH)
@@ -71,3 +83,63 @@
  	$(BUILD_CLI)
  
  install-cli: $(SAPI_CLI_PATH)
+--- php-7.0.0RC3/sapi/phpdbg/Makefile.frag~	2015-09-16 15:49:38.000000000 +0300
++++ php-7.0.0RC3/sapi/phpdbg/Makefile.frag	2015-09-27 21:24:44.370536565 +0300
+@@ -2,10 +2,10 @@
+ 
+ phpdbg-shared: $(BUILD_SHARED)
+ 
+-$(BUILD_SHARED): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
++$(BUILD_SHARED): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
+ 	$(BUILD_PHPDBG_SHARED)
+ 
+-$(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
++$(BUILD_BINARY): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
+ 	$(BUILD_PHPDBG)
+ 
+ %.c: %.y
+--- php-7.0.0RC3/sapi/phpdbg/config.m4~	2015-09-16 15:49:38.000000000 +0300
++++ php-7.0.0RC3/sapi/phpdbg/config.m4	2015-09-27 21:25:34.413134698 +0300
+@@ -40,7 +40,7 @@
+   
+   BUILD_PHPDBG="\$(LIBTOOL) --mode=link \
+         \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
+-                \$(PHP_GLOBAL_OBJS) \
++                libphp_common.la \
+                 \$(PHP_BINARY_OBJS) \
+                 \$(PHP_PHPDBG_OBJS) \
+                 \$(EXTRA_LIBS) \
+@@ -50,7 +50,7 @@
+ 
+   BUILD_PHPDBG_SHARED="\$(LIBTOOL) --mode=link \
+         \$(CC) -shared -Wl,-soname,libphpdbg.so -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
+-                \$(PHP_GLOBAL_OBJS) \
++                libphp_common.la \
+                 \$(PHP_BINARY_OBJS) \
+                 \$(PHP_PHPDBG_OBJS) \
+                 \$(EXTRA_LIBS) \
+--- php-7.0.0RC3/sapi/litespeed/Makefile.frag~	2015-09-16 15:49:38.000000000 +0300
++++ php-7.0.0RC3/sapi/litespeed/Makefile.frag	2015-09-27 21:26:36.783039512 +0300
+@@ -1,6 +1,6 @@
+ litespeed: $(SAPI_LITESPEED_PATH)
+ 
+-$(SAPI_LITESPEED_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_LITESPEED_OBJS)
++$(SAPI_LITESPEED_PATH): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_LITESPEED_OBJS)
+ 	$(BUILD_LITESPEED)
+ 
+ install-litespeed: $(SAPI_LITESPEED_PATH)
+--- php-7.0.0RC3/sapi/litespeed/config.m4~	2015-09-16 15:49:38.000000000 +0300
++++ php-7.0.0RC3/sapi/litespeed/config.m4	2015-09-27 21:27:36.182790123 +0300
+@@ -17,10 +17,10 @@
+     ;;
+   *cygwin*)
+     SAPI_LITESPEED_PATH=sapi/litespeed/php.exe
+-    BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
++    BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
+     ;;
+   *)
+-    BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
++    BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
+     ;;
+   esac
+ 
diff --git a/php-silent-session-cleanup.patch b/php-silent-session-cleanup.patch
index 5833736..2fdf68e 100644
--- a/php-silent-session-cleanup.patch
+++ b/php-silent-session-cleanup.patch
@@ -1,10 +1,10 @@
---- php-5.3.0/ext/session/mod_files.c~	2009-05-18 18:10:09.000000000 +0200
-+++ php-5.3.0/ext/session/mod_files.c	2009-08-07 08:41:53.029357590 +0200
-@@ -217,7 +217,6 @@
+--- php-7.0/ext/session/mod_files.c~	2015-05-21 17:57:06.000000000 +0300
++++ php-7.0/ext/session/mod_files.c	2015-05-23 11:18:54.466402493 +0300
+@@ -286,7 +286,6 @@
  
  	dir = opendir(dirname);
  	if (!dir) {
--		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ps_files_cleanup_dir: opendir(%s) failed: %s (%d)", dirname, strerror(errno), errno);
+-		php_error_docref(NULL, E_NOTICE, "ps_files_cleanup_dir: opendir(%s) failed: %s (%d)", dirname, strerror(errno), errno);
  		return (0);
  	}
  
diff --git a/php-systzdata.patch b/php-systzdata.patch
index df06b6f..a5a7b9d 100644
--- a/php-systzdata.patch
+++ b/php-systzdata.patch
@@ -1,7 +1,12 @@
 Add support for use of the system timezone database, rather
 than embedding a copy.  Discussed upstream but was not desired.
 
+(Few) upstream reports:
+https://bugs.php.net/bug.php?id=53320
+https://bugs.php.net/bug.php?id=54250
+
 History:
+r13: adapt for upstream changes to use PHP allocator
 r12: adapt for upstream changes for new zic
 r11: use canonical names to avoid more case sensitivity issues
      round lat/long from zone.tab towards zero per builtin db
@@ -20,9 +25,9 @@ r3: fix a crash if /usr/share/zoneinfo doesn't exist (Raphael Geissert)
 r2: add filesystem trawl to set up name alias index
 r1: initial revision
 
-diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/lib/parse_tz.c
---- php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata	2015-04-30 00:00:18.000000000 +0200
-+++ php-5.6.9RC1/ext/date/lib/parse_tz.c	2015-04-30 06:36:47.019617321 +0200
+diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/lib/parse_tz.c
+--- php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata	2015-08-18 23:39:24.000000000 +0200
++++ php-7.0.0RC1/ext/date/lib/parse_tz.c	2015-08-22 07:54:38.097258458 +0200
 @@ -20,6 +20,16 @@
  
  #include "timelib.h"
@@ -40,12 +45,12 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
  #include <stdio.h>
  
  #ifdef HAVE_LOCALE_H
-@@ -31,7 +41,12 @@
+@@ -32,8 +42,12 @@
+ #include <strings.h>
  #endif
  
- #define TIMELIB_SUPPORTS_V2DATA
-+
 +#ifndef HAVE_SYSTEM_TZDATA
+ #define TIMELIB_SUPPORTS_V2DATA
  #include "timezonedb.h"
 +#endif
 +
@@ -53,7 +58,7 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
  
  #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
  # if defined(__LITTLE_ENDIAN__)
-@@ -53,6 +68,10 @@ static int read_preamble(const unsigned
+@@ -55,6 +69,11 @@ static int read_preamble(const unsigned
  {
  	uint32_t version;
  
@@ -61,10 +66,11 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +		*tzf += 20;
 +		return 0;
 +	}
++
  	/* read ID */
  	version = (*tzf)[3] - '0';
  	*tzf += 4;
-@@ -296,7 +315,418 @@ void timelib_dump_tzinfo(timelib_tzinfo
+@@ -298,7 +317,418 @@ void timelib_dump_tzinfo(timelib_tzinfo
  	}
  }
  
@@ -102,11 +108,11 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +    const unsigned char *p = (const unsigned char *)str;
 +    uint32_t hash = 5381;
 +    int c;
-+    
++
 +    while ((c = tolower(*p++)) != '\0') {
 +        hash = (hash << 5) ^ hash ^ c;
 +    }
-+    
++
 +    return hash % LOCINFO_HASH_SIZE;
 +}
 +
@@ -434,9 +440,9 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +{
 +    if (timezonedb_system) {
 +        timelib_tzdb_index_entry *ent, lookup;
-+        
++
 +        lookup.id = (char *)timezone;
-+        
++
 +        ent = bsearch(&lookup, timezonedb_system->index,
 +                      timezonedb_system->index_size, sizeof lookup,
 +                      sysdbcmp);
@@ -484,7 +490,7 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
  {
  	int left = 0, right = tzdb->index_size - 1;
  #ifdef HAVE_SETLOCALE
-@@ -335,21 +765,87 @@ static int seek_to_tz_position(const uns
+@@ -337,21 +767,88 @@ static int seek_to_tz_position(const uns
  	return 0;
  }
  
@@ -501,9 +507,9 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +			return 0;
 +		}
 +
-+		(*tzf) = (unsigned char *)orig ;
++		(*tzf) = (unsigned char *)orig;
 +		*map = orig;
-+		return 1;
++        return 1;
 +	}
 +	else
 +#endif
@@ -569,11 +575,12 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +		return stat(fname, &st) == 0 && is_valid_tzfile(&st);
 +	}
 +#endif
++
 +	return (inmem_seek_to_tz_position(&tzf, timezone, tzdb));
  }
  
  static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
-@@ -374,24 +870,54 @@ static void read_64bit_header(const unsi
+@@ -376,24 +873,54 @@ static void read_64bit_header(const unsi
  timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb)
  {
  	const unsigned char *tzf;
@@ -607,8 +614,8 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +			 * if possible. */
 +
 +			if ((li = find_zone_info(system_location_table, timezone)) != NULL) {
-+				tmp->location.comments = strdup(li->comment);
-+                                strncpy(tmp->location.country_code, li->code, 2);
++				tmp->location.comments = timelib_strdup(li->comment);
++				strncpy(tmp->location.country_code, li->code, 2);
 +				tmp->location.longitude = li->longitude;
 +				tmp->location.latitude = li->latitude;
 +				tmp->bc = 1;
@@ -616,7 +623,7 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +			else {
 +				strcpy(tmp->location.country_code, "??");
 +				tmp->bc = 0;
-+				tmp->location.comments = strdup("");
++				tmp->location.comments = timelib_strdup("");
 +			}
 +
 +			/* Now done with the mmap segment - discard it. */
@@ -624,6 +631,7 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +		} else
 +#endif
 +		{
++			/* PHP-style - use the embedded info. */
 +			if (version == 2) {
 +				skip_64bit_preamble(&tzf, tmp);
 +				read_64bit_header(&tzf, tmp);
@@ -631,15 +639,14 @@ diff -up php-5.6.9RC1/ext/date/lib/parse_tz.c.systzdata php-5.6.9RC1/ext/date/li
 +				skip_64bit_types(&tzf, tmp);
 +				skip_posix_string(&tzf, tmp);
 +			}
-+			/* PHP-style - use the embedded info. */
 +			read_location(&tzf, tmp);
 + 		}
  	} else {
  		tmp = NULL;
  	}
-diff -up php-5.6.9RC1/ext/date/lib/timelib.m4.systzdata php-5.6.9RC1/ext/date/lib/timelib.m4
---- php-5.6.9RC1/ext/date/lib/timelib.m4.systzdata	2015-04-30 00:00:18.000000000 +0200
-+++ php-5.6.9RC1/ext/date/lib/timelib.m4	2015-04-30 06:32:08.549500385 +0200
+diff -up php-7.0.0RC1/ext/date/lib/timelib.m4.systzdata php-7.0.0RC1/ext/date/lib/timelib.m4
+--- php-7.0.0RC1/ext/date/lib/timelib.m4.systzdata	2015-08-18 23:39:24.000000000 +0200
++++ php-7.0.0RC1/ext/date/lib/timelib.m4	2015-08-22 07:47:34.854055364 +0200
 @@ -78,3 +78,17 @@ stdlib.h
  
  dnl Check for strtoll, atoll
diff --git a/php-tds.patch b/php-tds.patch
deleted file mode 100644
index ef036a7..0000000
--- a/php-tds.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- php-5.3.3/ext/sybase_ct/config.m4~	2010-07-07 13:15:24.000000000 +0300
-+++ php-5.3.3/ext/sybase_ct/config.m4	2010-07-24 19:21:13.897144810 +0300
-@@ -31,7 +31,7 @@
-   fi
-   
-   PHP_ADD_LIBPATH($SYBASE_CT_LIBDIR, SYBASE_CT_SHARED_LIBADD)
--  if test -f $SYBASE_CT_INCDIR/tds.h || test -f $SYBASE_CT_INCDIR/tds_sysdep_public.h; then
-+  if test -f $SYBASE_CT_INCDIR/tds.h || test -f $SYBASE_CT_INCDIR/tds_sysdep_public.h || test -f $SYBASE_CT_INCDIR/sybdb.h; then
-     PHP_ADD_LIBRARY(ct,, SYBASE_CT_SHARED_LIBADD)
-     SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lct"
-   elif test -f $SYBASE_CT_INCDIR/libsybct64; then
diff --git a/php-tld.patch b/php-tld.patch
index 28e3fe2..328752c 100644
--- a/php-tld.patch
+++ b/php-tld.patch
@@ -1,19 +1,17 @@
---- php-5.5.0alpha1/ext/standard/info.c~	2012-11-13 22:00:16.000000000 +0200
-+++ php-5.5.0alpha1/ext/standard/info.c	2012-11-18 23:37:48.607735302 +0200
-@@ -794,6 +794,17 @@
- 			zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
+--- php-7.0.1/ext/standard/info.c	2015-12-18 12:02:05.000000000 +0000
++++ php-7.0.1/ext/standard/info.c	2015-12-18 12:02:27.523443158 +0000
+@@ -965,6 +965,14 @@
+ 			zend_html_puts(zend_version, strlen(zend_version));
  		}
  		php_info_print_box_end();
 +		/* TLD Linux */
 +		php_info_print_box_start(0);
-+		if (!sapi_module.phpinfo_as_text) {
-+			php_info_print("<a href=\"http://www.tld-linux.org/\">");
-+		}
 +		php_info_print("This server is using TLD Linux.");
 +		if (!sapi_module.phpinfo_as_text)
 +			php_info_print("<br />More information at <a href=\"http://www.tld-linux.org/\">http://www.tld-linux.org/</a>.<br />\n");
 +		else
 +			php_info_print("\nMore information at http://www.tld-linux.org/.\n");
 +		php_info_print_box_end();
- 		efree(php_uname);
+ 		zend_string_free(php_uname);
  	}
+ 
diff --git a/php-zlib-for-getimagesize.patch b/php-zlib-for-getimagesize.patch
index 9a2bc9d..50a3ec3 100644
--- a/php-zlib-for-getimagesize.patch
+++ b/php-zlib-for-getimagesize.patch
@@ -2,8 +2,8 @@ make compressed .swf parsing possible,
 link core php with -lz for getimagesize()
 see also http://bugs.php.net/bug.php?id=29611
 
---- php-4.4.1/ext/standard/image.c	2005-07-27 14:22:36.000000000 +0300
-+++ /tmp/image.c	2006-01-06 19:14:00.000000000 +0200
+--- php-7.0/ext/standard/image.c~	2015-05-21 23:10:45.000000000 +0300
++++ php-7.0/ext/standard/image.c	2015-05-21 23:11:22.424948534 +0300
 @@ -31,7 +31,7 @@
  #endif
  #include "php_image.h"
@@ -31,12 +31,12 @@ see also http://bugs.php.net/bug.php?id=29611
  /* {{{ php_handle_swc
   */
  static struct gfxinfo *php_handle_swc(php_stream * stream TSRMLS_DC)
-@@ -1267,7 +1290,7 @@
- 			result = php_handle_swf(stream TSRMLS_CC);
+@@ -1321,7 +1321,7 @@
+ 			result = php_handle_swf(stream);
  			break;
  		case IMAGE_FILETYPE_SWC:
 -#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
 +#if HAVE_ZLIB
- 			result = php_handle_swc(stream TSRMLS_CC);
+ 			result = php_handle_swc(stream);
  #else
- 			php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled.");
+ 			php_error_docref(NULL, E_NOTICE, "The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled");
diff --git a/php.spec b/php.spec
index 9479ee1..aaff873 100644
--- a/php.spec
+++ b/php.spec
@@ -1,15 +1,11 @@
 # TODO 5.6:
-# - phpdbg: link with libphp_common
 # - enable --with-fpm-systemd, but ensure it checks for sd_booted()
 # - build with system libgd 2.1, see 73c5128
 # TODO 5.4:
-# - check php-sapi-ini-file.patch for safe mode removal
 # - update imap annotations patch (needs api porting)
 # - update imap myrights patch (needs api porting)
 # --with-libmbfl=DIR      MBSTRING: Use external libmbfl.  DIR is the libmbfl base install directory BUNDLED
 # --with-onig=DIR         MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix.
-# UNPACKAGED EXTENSION NOTES:
-# - com_dotnet is Win32-only
 # TODO:
 # - fileinfo extension bundles magic db in library: data_file.c (dump of magic.mgc) is 14M
 #   - 2.3M fileinfo.so php54-fileinfo-5.4.6-0.15.x86_64
@@ -17,86 +13,97 @@
 #   -  13K fileinfo.so php-pecl-fileinfo-1.0.4-8.amd64
 # - ttyname_r() misdetected http://bugs.php.net/bug.php?id=48820
 # - wddx: restore session support (not compiled in due DL extension check)
-# - deal with modules removed from php and not moved to PECL, still not obsoleted anywhere
-#   - removed from php 5.0 (currently in php4):
-#   db [pecl-svn], hyperwave [pecl-svn], java [pecl-svn], mcal [pecl-svn], qtdom [pecl-svn]
-#   - removed from php 5.1:
-#   oracle [pecl-svn]
-#   - removed from php 5.2:
-#   filepro [pecl-svn], hwapi [pecl-svn]
-# - make additional headers and checking added by mail patch configurable
 # - modularize standard (output from pure php -m)?
-# - lib64 patch obsolete by $PHP_LIBDIR ?
-# - WARNING: Phar: sha256/sha512 signature support disabled if ext/hash is
-#   built shared, also PHAR_HAVE_OPENSSL is false if openssl is built shared.
-#   make it runtime dep and add Suggests (or php warning messages)
 # - some mods should be shared:
 #$ php -m
 # [PHP Modules]
-#+Core
+# Core
 # date
-#+ereg
 # libxml
 # Reflection
 # standard
-# 
+#
 # Conditional build:
 %bcond_without	default_php	# use this PHP as default PHP in distro
+# - General options:
+%bcond_without	embed		# disable building Embedded API
+%bcond_with	gcov		# Enable Code coverage reporting
+%bcond_without	instantclient	# build Oracle oci8 extension module against oracle-instantclient package
 %bcond_with	interbase_inst	# use InterBase install., not Firebird	(BR: proprietary libs)
-%bcond_with	oci		# with Oracle oci8 extension module	(BR: proprietary libs)
-%bcond_with	instantclient	# build Oracle oci8 extension module against oracle-instantclient package
+%bcond_without	kerberos5	# without Kerberos5 support
+%bcond_with	mm		# without mm support for session storage
+%bcond_with	suhosin		# with suhosin patch, has little point in PHP>=5.3, see https://github.com/stefanesser/suhosin/issues/42#issuecomment-41728178
 %bcond_with	system_gd	# with system gd (imageantialias function is missing then)
 %bcond_with	system_libzip	# with system libzip (reported broken currently)
+%bcond_with	systemtap	# systemtap/DTrace support
+%bcond_with	tests		# default off; test process very often hangs on builders, approx run time 45m; perform "make test"
+%bcond_without	webp		# Without WebP support in GD extension (imagecreatefromwebp)
+%bcond_with	zts		# Zend Thread Safety
+# - SAPI
+%bcond_without	apache2		# disable building Apache 2.x SAPI
+%bcond_without	cgi		# disable CGI/FCGI SAPI
+%bcond_without	fpm		# disable FPM SAPI
+%bcond_without	litespeed	# build litespeed SAPI
+%bcond_with	milter		# disable Milter SAPI
+%bcond_without	phpdbg		# disable phpdbg SAPI
+# - Extensions
+%bcond_without	bcmath		# without bcmath extension module
+%bcond_without	bz2		# without bz2 extension module
+%bcond_without	calendar	# without calendar extension module
+%bcond_without	ctype		# without ctype extension module
 %bcond_without	curl		# without CURL extension module
+%bcond_without	dba		# without DBA extension module
+%bcond_without	dom		# without DOM extension module
 %bcond_without	enchant		# without Enchant extension module
+%bcond_without	ereg		# without ext/ereg support
+%bcond_without	exif		# without EXIF extension module
+%bcond_without	fileinfo	# without fileinfo extension module
 %bcond_without	filter		# without filter extension module
+%bcond_without	ftp		# without FTP extension module
+%bcond_without	gd		# without GD extension module
+%bcond_without	gettext		# without gettext extension module
+%bcond_without	gmp		# without gmp extension module
+%bcond_without	hash		# without hash extension module
+%bcond_without	iconv		# without iconv extension module
 %bcond_without	imap		# without IMAP extension module
 %bcond_without	interbase	# without InterBase extension module
 %bcond_without	intl		# without Intl extension module
-%bcond_without	kerberos5	# without Kerberos5 support
-%bcond_without	litespeed	# build litespeed module
+%bcond_without	json		# without json extension module
 %bcond_without	ldap		# without LDAP extension module
+%bcond_without	mbstring	# without mbstring extension module
+%bcond_without	mcrypt		# without mbcrypt extension module
 %bcond_without	mhash		# without mhash extension (supported by hash extension)
-%bcond_without	mm		# without mm support for session storage
-%bcond_without	mssql		# without MS SQL extension module
+%bcond_without	mysqli		# without mysqli support (Requires mysql >= 4.1)
 %bcond_without	mysqlnd		# without mysqlnd support in mysql related extensions
-%bcond_without	mysqli		# without mysqli support (Requires mysql > 4.1)
+%bcond_with	oci		# with Oracle oci8 extension module	(BR: proprietary libs)
 %bcond_without	odbc		# without ODBC extension module
 %bcond_without	opcache		# without Enable Zend OPcache extension support
 %bcond_without	openssl		# without OpenSSL support and OpenSSL extension (module)
+%bcond_without	pcntl		# without pcntl extension module
 %bcond_without	pcre		# without PCRE extension module
+%bcond_without	pdo		# without PDO extension module
+%bcond_without	pdo_dblib	# without PDO dblib extension module
+%bcond_without	pdo_mysql	# without PDO MySQL extension module
 %bcond_without	pdo_sqlite	# without PDO SQLite extension module
 %bcond_without	pgsql		# without PostgreSQL extension module
-%bcond_without	phar		# without phar extension module
+%bcond_without	phar		# without Phar extension module
+%bcond_without	posix		# without POSIX extension module
 %bcond_without	pspell		# without pspell extension module
+%bcond_without	readline	# without readline extension module
 %bcond_without	recode		# without recode extension module
+%bcond_without	session		# without session extension module
 %bcond_without	snmp		# without SNMP extension module
 %bcond_without	sqlite2		# without SQLite extension module
 %bcond_without	sqlite3		# without SQLite3 extension module
-%bcond_without	sybase_ct	# without Sybase-CT extension module
 %bcond_without	tidy		# without Tidy extension module
-%bcond_without	webp		# Without WebP support in GD extension (imagecreatefromwebp)
 %bcond_without	wddx		# without WDDX extension module
 %bcond_without	xmlrpc		# without XML-RPC extension module
-%bcond_with	apache1		# disable building Apache 1.3.x SAPI
-%bcond_without	apache2		# disable building Apache 2.x SAPI
-%bcond_with	zts		# Zend Thread Safety
-%bcond_without	cgi		# disable CGI/FCGI SAPI
-%bcond_without	fpm		# disable FPM
-%bcond_without	embed		# disable Embedded API
-%bcond_without	phpdbg		# disable phpdbg SAPI
-%bcond_with	milter		# disable Milter SAPI
-%bcond_with	suhosin		# with suhosin patch, has little point in PHP>=5.3, see https://github.com/stefanesser/suhosin/issues/42#issuecomment-41728178
-%bcond_with	tests		# default off; test process very often hangs on builders, approx run time 45m; perform "make test"
-%bcond_with	gcov		# Enable Code coverage reporting
-%bcond_with	type_hints	# experimental support for strict typing/casting
 
 %define apxs1		/usr/sbin/apxs1
 %define	apxs2		/usr/sbin/apxs
 
 # disable all sapis
 %if %{with gcov}
-%undefine	with_apache1
 %undefine	with_apache2
 %undefine	with_cgi
 %undefine	with_litespeed
@@ -112,51 +119,45 @@
 %undefine	with_milter
 %endif
 
-%ifnarch %{ix86} %{x8664} sparc sparcv9 alpha
+%ifnarch %{ix86} %{x8664} x32 sparc sparcv9 alpha
 # ppc disabled (broken on th-ppc)
 %undefine	with_interbase
 %endif
 
-%ifnarch %{ix86} %{x8664}
+%ifnarch %{ix86} %{x8664} x32
 # unsupported, see sapi/cgi/fpm/fpm_atomic.h
 %undefine	with_fpm
 %endif
 
-%if 0
-%if %{without apache1} && %{without apache2}
-ERROR: You need to select at least one Apache SAPI to build shared modules.
-%endif
-%endif
-
 # filter depends on pcre
 %if %{without pcre}
 %undefine	with_filter
 %endif
 
-%define		rel	1
 %define		orgname	php
-%define		ver_suffix 56
+%define		ver_suffix 70
 %define		php_suffix %{!?with_default_php:%{ver_suffix}}
 Summary:	PHP: Hypertext Preprocessor
 Summary(fr.UTF-8):	Le langage de script embarque-HTML PHP
 Summary(pl.UTF-8):	Język skryptowy PHP
 Summary(pt_BR.UTF-8):	A linguagem de script PHP
-Summary(ru.UTF-8):	PHP Версии 5 - язык препроцессирования HTML-файлов, выполняемый на сервере
-Summary(uk.UTF-8):	PHP Версії 5 - мова препроцесування HTML-файлів, виконувана на сервері
+Summary(ru.UTF-8):	PHP Версии 7 - язык препроцессирования HTML-файлов, выполняемый на сервере
+Summary(uk.UTF-8):	PHP Версії 7 - мова препроцесування HTML-файлів, виконувана на сервері
 Name:		%{orgname}%{php_suffix}
-Version:	5.6.17
-Release:	%{rel}%{?with_type_hints:.th}
+Version:	7.0.2
+Release:	0.1
 Epoch:		4
-License:	PHP
+# All files licensed under PHP version 3.01, except
+# Zend is licensed under Zend
+# TSRM is licensed under BSD
+License:	PHP 3.01 and Zend and BSD
 Group:		Libraries
 Source0:	http://www.php.net/distributions/%{orgname}-%{version}.tar.xz
-# Source0-md5:	5e080e4b7df5db24f1b64313f8114bd8
-Source2:	%{orgname}-mod_%{orgname}.conf
+# Source0-md5:	ce5964672e4ec0b66ff088a6bafde8c7
+Source2:	%{orgname}-mod_php.conf
 Source3:	%{orgname}-cgi-fcgi.ini
 Source4:	%{orgname}-apache.ini
 Source5:	%{orgname}-cli.ini
-# Taken from: http://browsers.garykeith.com/downloads.asp
-Source9:	%{orgname}_browscap.ini
 Source10:	%{orgname}-fpm.init
 Source11:	%{orgname}-fpm.logrotate
 Source12:	%{orgname}-branch.sh
@@ -166,7 +167,6 @@ Patch0:		%{orgname}-shared.patch
 Patch1:		%{orgname}-tld.patch
 Patch2:		%{orgname}-mail.patch
 Patch3:		%{orgname}-link-libs.patch
-Patch4:		%{orgname}-libpq_fs_h_path.patch
 Patch5:		%{orgname}-filter-shared.patch
 Patch6:		%{orgname}-build_modules.patch
 Patch7:		%{orgname}-sapi-ini-file.patch
@@ -174,13 +174,9 @@ Patch8:		milter.patch
 Patch9:		libtool-tag.patch
 Patch10:	%{orgname}-ini.patch
 Patch11:	embed.patch
-%if %{with type_hints}
-Patch12:	http://ilia.ws/patch/type_hint_53_v2.txt
-%endif
 Patch14:	%{orgname}-no_pear_install.patch
 Patch17:	%{orgname}-readline.patch
 Patch18:	%{orgname}-nohttpd.patch
-Patch20:	%{orgname}-uint32_t.patch
 Patch21:	%{orgname}-dba-link.patch
 Patch22:	%{orgname}-both-apxs.patch
 Patch23:	%{orgname}-builddir.patch
@@ -191,8 +187,6 @@ Patch27:	%{orgname}-config-dir.patch
 Patch29:	%{orgname}-fcgi-graceful.patch
 Patch31:	%{orgname}-fcgi-error_log-no-newlines.patch
 Patch34:	%{orgname}-libtool.patch
-Patch35:	%{orgname}-tds.patch
-Patch36:	%{orgname}-mysql-charsetphpini.patch
 Patch37:	%{orgname}-mysqli-charsetphpini.patch
 Patch38:	%{orgname}-pdo_mysql-charsetphpini.patch
 Patch39:	%{orgname}-use-prog_sendmail.patch
@@ -211,12 +205,14 @@ Patch55:	bug-52078-fileinode.patch
 Patch59:	%{orgname}-systzdata.patch
 Patch60:	%{orgname}-oracle-instantclient.patch
 Patch62:	mcrypt-libs.patch
-Patch63:	%{orgname}-mysql-nowarning.patch
 Patch65:	system-libzip.patch
 Patch66:	php-db.patch
 Patch67:	mysql-lib-ver-mismatch.patch
-Patch69:	fpm-conf-split.patch
+# https://bugs.php.net/bug.php?id=68344
+Patch68:	php-mysql-ssl-context.patch
 Patch70:	mysqlnd-ssl.patch
+Patch71:	libdb-info.patch
+Patch72:	phar-hash-shared.patch
 URL:		http://www.php.net/
 %{?with_interbase:%{!?with_interbase_inst:BuildRequires:	Firebird-devel >= 1.0.2.908-2}}
 %{?with_pspell:BuildRequires:	aspell-devel >= 2:0.50.0}
@@ -230,14 +226,15 @@ BuildRequires:	db-devel >= 4.0
 BuildRequires:	elfutils-devel
 %{?with_enchant:BuildRequires:	enchant-devel >= 1.1.3}
 %{?with_kerberos5:BuildRequires:	heimdal-devel}
+%{?with_fpm:BuildRequires:	libapparmor-devel}
 %{?with_system_libzip:BuildRequires:	libzip-devel >= 0.10.1-2}
 %{!?with_mysqlnd:BuildRequires:	mysql-devel}
 BuildRequires:	pkgconfig
 BuildRequires:	sed >= 4.0
-%if %{with mssql} || %{with sybase_ct}
+%if %{with pdo_dblib}
 BuildRequires:	freetds-devel >= 0.82
 %endif
-BuildRequires:	freetype-devel >= 2.5.1
+BuildRequires:	freetype-devel >= 1:2.5.1
 %if %{with system_gd}
 BuildRequires:	gd-devel >= 2.1
 %endif
@@ -249,15 +246,15 @@ BuildRequires:	libjpeg-devel
 BuildRequires:	libltdl-devel >= 1.4
 BuildRequires:	libmcrypt-devel >= 2.4.4
 BuildRequires:	libpng-devel >= 1.0.8
-%{?with_webp:BuildRequires:	libvpx-devel}
+%{?with_webp:BuildRequires:	libwebp-devel}
 BuildRequires:	tokyocabinet-devel
-BuildRequires:	libtool >= 2:2.2
+BuildRequires:	libtool >= 2:2.4.6
 BuildRequires:	libxml2-devel >= 1:2.7.6-4
 BuildRequires:	libxslt-devel >= 1.1.0
 %{?with_mm:BuildRequires:	mm-devel >= 1.3.0}
 %{?with_ldap:BuildRequires:	openldap-devel >= 2.3.0}
 %if %{with openssl} || %{with ldap}
-BuildRequires:	openssl-devel >= 0.9.7d
+BuildRequires:	openssl-devel >= 0.9.8
 %endif
 %{?with_gcov:BuildRequires:	lcov}
 %{?with_snmp:%{?with_tests:BuildRequires:	mibs-net-snmp}}
@@ -266,26 +263,22 @@ BuildRequires:	openssl-devel >= 0.9.7d
 BuildRequires:	pam-devel
 %{?with_pcre:BuildRequires:	pcre-devel >= 8.10}
 BuildRequires:	pkgconfig
-%{?with_pgsql:BuildRequires:	postgresql-backend-devel >= 7.2}
 %{?with_pgsql:BuildRequires:	postgresql-devel}
 BuildRequires:	readline-devel
 %{?with_recode:BuildRequires:	recode-devel >= 3.5d-3}
 BuildRequires:	rpm >= 4.4.9-56
 BuildRequires:	rpm-build >= 4.4.0
 BuildRequires:	rpmbuild(macros) >= 1.566
+%{?with_systemtap:BuildRequires:	systemtap-sdt-devel}
 BuildRequires:	tar >= 1:1.22
 BuildRequires:	xz
 %if %{with sqlite3} || %{with pdo_sqlite}
 BuildRequires:	sqlite3-devel >= 3.3.9
 %endif
-BuildRequires:	t1lib-devel
 %{?with_tidy:BuildRequires:	tidy-devel}
 %{?with_odbc:BuildRequires:	unixODBC-devel}
 %{?with_xmlrpc:BuildRequires:	xmlrpc-epi-devel >= 0.54.1}
 BuildRequires:	zlib-devel >= 1.0.9
-%if %{with apache1}
-BuildRequires:	apache1-devel
-%endif
 %if %{with apache2}
 BuildRequires:	apache-devel >= 2.0.52-2
 BuildRequires:	apr-devel >= 1:1.0.0
@@ -298,10 +291,10 @@ BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 %define		_sysconfdir			%{php_sysconfdir}
 
 # must be in sync with source. extra check ensuring that it is so is done in %%build
-%define		php_api_version		20131106
-%define		zend_module_api		20131226
-%define		zend_extension_api	220131226
-%define		php_pdo_api_version	20080721
+%define		php_api_version		20151012
+%define		zend_module_api		20151012
+%define		zend_extension_api	320151012
+%define		php_pdo_api_version	20150127
 
 # Extension versions
 %define		bz2ver		1.0
@@ -309,12 +302,12 @@ BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 %define		fileinfover	1.0.5
 %define		hashver		1.0
 %define		intlver		1.1.0
-%define		jsonver		1.2.1
+%define		jsonver		1.4.0
 %define		opcachever	7.0.6-dev
 %define		pharver		2.0.2
 %define		sqlite3ver	0.7-dev
-%define		zipver		1.12.5
-%define		phpdbgver	0.4.0
+%define		zipver		1.13.0
+%define		phpdbgver	0.5.0
 
 %define		_zend_zts		%{!?with_zts:0}%{?with_zts:1}
 %define		php_debug		%{!?debug:0}%{?debug:1}
@@ -381,24 +374,6 @@ PHP - це мова написання скриптів, що вбудовуют
 роботи з базами даних є доволі простим. Найбільш популярне
 використання PHP - заміна для CGI скриптів.
 
-%package -n apache1-mod_%{name}
-Summary:	PHP DSO module for Apache 1.3.x
-Summary(pl.UTF-8):	Moduł DSO (Dynamic Shared Object) PHP dla Apache 1.3.x
-Group:		Development/Languages/PHP
-Requires:	%{name}-common = %{epoch}:%{version}-%{release}
-Requires:	apache1(EAPI) >= 1.3.33-2
-Requires:	apache1-mod_mime
-Provides:	webserver(php) = %{version}
-Obsoletes:	apache-mod_php < 1:4.1.1
-Obsoletes:	apache1-mod_php < 4:5.3.28-7
-Obsoletes:	phpfi
-
-%description -n apache1-mod_%{name}
-PHP as DSO module for Apache 1.3.x.
-
-%description -n apache1-mod_%{name} -l pl.UTF-8
-PHP jako moduł DSO (Dynamic Shared Object) dla Apache 1.3.x.
-
 %package -n apache-mod_%{name}
 Summary:	PHP DSO module for Apache 2.x
 Summary(pl.UTF-8):	Moduł DSO (Dynamic Shared Object) PHP dla Apache 2.x
@@ -442,7 +417,6 @@ Provides:	php(fcgi)
 Provides:	webserver(php) = %{version}
 Obsoletes:	php-cgi < 4:5.3.28-7
 Obsoletes:	php-fcgi < 4:5.3.0
-Conflicts:	logrotate < 3.8.0
 
 %description cgi
 PHP as CGI or FastCGI program.
@@ -490,10 +464,12 @@ Requires(pre):	/bin/id
 Requires(pre):	/usr/sbin/useradd
 Requires:	%{name}-common = %{epoch}:%{version}-%{release}
 Requires:	rc-scripts
+Provides:	php(fcgi)
 Provides:	php(fpm)
 Provides:	user(http)
 Provides:	webserver(php) = %{version}
 Obsoletes:	php-fpm < 4:5.3.28-7
+Conflicts:	logrotate < 3.8.0
 
 %description fpm
 PHP FastCGI Process Manager.
@@ -536,17 +512,18 @@ Provides:	%{name}(zend_extension_api) = %{zend_extension_api}
 Provides:	%{name}(zend_module_api) = %{zend_module_api}
 Provides:	%{name}-core
 Provides:	%{name}-date
-Provides:	%{name}-ereg
+%{?with_ereg:Provides:	%{name}-ereg}
 Provides:	%{name}-reflection
 Provides:	%{name}-standard
 Provides:	php(core) = %{version}
 Provides:	php(date)
-Provides:	php(ereg)
+%{?with_ereg:Provides:	php(ereg)}
 Provides:	php(libxml)
 Provides:	php(reflection)
 Provides:	php(standard)
 %{!?with_mysqlnd:Obsoletes:	%{name}-mysqlnd}
 %{?with_pcre:%requires_ge_to	pcre pcre-devel}
+Suggests:	browscap
 Obsoletes:	php-common < 4:5.3.28-7
 Obsoletes:	php-pecl-domxml
 Conflicts:	php4-common < 3:4.4.4-8
@@ -577,16 +554,18 @@ Group:		Development/Languages/PHP
 Requires:	%{name}-common = %{epoch}:%{version}-%{release}
 Requires:	autoconf >= 2.13
 Requires:	automake
-Requires:	libtool >= 2:2.2
+Requires:	libtool >= 2:2.4.6
 %{?with_pcre:Requires:	pcre-devel >= 8.10}
 Requires:	shtool
 Provides:	php-devel = %{epoch}:%{version}-%{release}
+Obsoletes:	php-devel
 Obsoletes:	php-pear-devel
 Obsoletes:	php4-devel
 Obsoletes:	php52-devel
 Obsoletes:	php53-devel
 Obsoletes:	php54-devel
 Obsoletes:	php55-devel
+Obsoletes:	php56-devel
 
 %description devel
 The php-devel package lets you compile dynamic extensions to PHP.
@@ -1103,27 +1082,6 @@ databases support through FreeTDS library.
 Moduł PHP dodający obsługę baz danych MS SQL poprzez bibliotekę
 FreeTDS.
 
-%package mysql
-Summary:	MySQL database module for PHP
-Summary(pl.UTF-8):	Moduł bazy danych MySQL dla PHP
-Summary(pt_BR.UTF-8):	Um módulo para aplicações PHP que usam bancos de dados MySQL
-Group:		Libraries
-URL:		http://www.php.net/manual/en/book.mysql.php
-Requires:	%{name}-common = %{epoch}:%{version}-%{release}
-%{?with_mysqlnd:Requires:	%{name}-mysqlnd = %{epoch}:%{version}-%{release}}
-Provides:	php(mysql)
-Obsoletes:	php-mysql < 4:5.3.28-7
-
-%description mysql
-This is a dynamic shared object (DSO) for PHP that will add MySQL
-database support.
-
-%description mysql -l pl.UTF-8
-Moduł PHP umożliwiający dostęp do bazy danych MySQL.
-
-%description mysql -l pt_BR.UTF-8
-Um módulo para aplicações PHP que usam bancos de dados MySQL.
-
 %package mysqli
 Summary:	MySQLi module for PHP
 Summary(pl.UTF-8):	Moduł MySQLi dla PHP
@@ -1227,6 +1185,7 @@ Summary(pl.UTF-8):	Zend Optimizer+ - optymalizator kodu PHP
 Group:		Libraries
 URL:		https://wiki.php.net/rfc/optimizerplus
 Requires:	%{name}-common = %{epoch}:%{version}-%{release}
+Requires:	%{name}-pcre = %{epoch}:%{version}-%{release}
 Provides:	php(opcache) = %{opcachever}
 
 %description opcache
@@ -1474,6 +1433,7 @@ Group:		Libraries
 URL:		http://www.php.net/manual/en/book.phar.php
 Requires:	%{name}-common = %{epoch}:%{version}-%{release}
 Requires:	%{name}-spl = %{epoch}:%{version}-%{release}
+Requires:	%{name}-hash = %{epoch}:%{version}-%{release}
 Suggests:	%{name}-cli
 # zlib is required by phar program, but as phar cli is optional should the dep be too
 Suggests:	%{name}-zlib
@@ -1705,24 +1665,6 @@ baz danych. SQLite sam jest serwerem. Biblioteka SQLite czyta i
 zapisuje dane bezpośrednio z/do plików baz danych znajdujących się na
 dysku.
 
-%package sybase-ct
-Summary:	Sybase-CT extension module for PHP
-Summary(pl.UTF-8):	Moduł Sybase-CT dla PHP
-Group:		Libraries
-URL:		http://www.php.net/manual/en/book.sybase.php
-Requires:	%{name}-common = %{epoch}:%{version}-%{release}
-Provides:	php(sybase-ct)
-Obsoletes:	php-sybase
-Obsoletes:	php-sybase-ct < 4:5.3.28-7
-
-%description sybase-ct
-This is a dynamic shared object (DSO) for PHP that will add Sybase and
-MS SQL databases support through CT-lib.
-
-%description sybase-ct -l pl.UTF-8
-Moduł PHP dodający obsługę baz danych Sybase oraz MS SQL poprzez
-CT-lib.
-
 %package sysvmsg
 Summary:	SysV msg extension module for PHP
 Summary(pl.UTF-8):	Moduł SysV msg dla PHP
@@ -1970,26 +1912,21 @@ compression support to PHP.
 Moduł PHP umożliwiający używanie kompresji zlib.
 
 %prep
-%setup -q -n %{orgname}-%{version}%{?subver}
+%setup -q -n %{orgname}-%{version}
 cp -p php.ini-production php.ini
 %patch0 -p1
 %patch1 -p1
-%patch2 -p1
+#%patch2 -p1
 %patch3 -p1
-%patch4 -p1
 %patch5 -p1
 %patch6 -p1
 %patch7 -p1
-%patch8 -p1
+%{?with_milter:%patch8 -p1}
 %patch9 -p1
 %patch10 -p1
-%if %{with type_hints}
-%patch12 -p0
-%endif
 %patch14 -p1
 %patch17 -p1
 %patch18 -p1
-%patch20 -p1
 %patch21 -p1
 %patch22 -p1
 %patch23 -p1
@@ -2000,13 +1937,10 @@ cp -p php.ini-production php.ini
 %patch29 -p1
 %patch31 -p1
 %patch34 -p1
-%patch35 -p1
-%patch36 -p1
 %patch37 -p1
 %patch38 -p1
 %patch39 -p1
 %if %{with fpm}
-%patch69 -p1
 %patch41 -p1
 %patch42 -p1
 %endif
@@ -2026,17 +1960,22 @@ cp -p php.ini-production php.ini
 %patch59 -p1
 %patch60 -p1
 %patch62 -p1
-%patch63 -p1
 %{?with_system_libzip:%patch65 -p1}
 %patch66 -p1
 %patch67 -p1
+#%patch68 -p1
 %patch70 -p1
+%patch71 -p1
+%patch72 -p1
 
 sed -i -e '/PHP_ADD_LIBRARY_WITH_PATH/s#xmlrpc,#xmlrpc-epi,#' ext/xmlrpc/config.m4
 
 # cleanup backups after patching
 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
 
+# com_dotnet is Win32-only
+%{__rm} -r ext/com_dotnet
+
 # conflict seems to be resolved by recode patches
 %{__rm} ext/recode/config9.m4
 
@@ -2096,16 +2035,37 @@ mv Zend/tests/bug39438.phpt{,.disable}
 %{__rm} -r ext/sqlite3/tests
 %endif
 
+# ----- Manage known as failed test -------
+# affected by systzdata patch
+%{__rm} ext/date/tests/timezone_location_get.phpt
+%{__rm} ext/date/tests/timezone_version_get.phpt
+%{__rm} ext/date/tests/timezone_version_get_basic1.phpt
+# Should be skipped but fails sometime
+%{__rm} ext/standard/tests/file/file_get_contents_error001.phpt
+# fails sometimes
+%{__rm} ext/sockets/tests/mcast_ipv?_recv.phpt
+# causes stack exhausion
+%{__rm} Zend/tests/bug54268.phpt
+%{__rm} Zend/tests/bug68412.phpt
+
+# avoid issues when two builds run simultaneously
+%ifarch %{x8664}
+sed -e 's/64321/64322/' -i ext/openssl/tests/*.phpt
+%endif
+
 # skip XFAILs
 # no point testing stuff that is knowingly broken
-find -name '*.phpt' | xargs grep XFAIL -l | xargs rm -v
+find -name '*.phpt' | xargs grep '^--XFAIL--' -l | xargs rm -v
 
 env \
 %ifarch %{ix86}
-ix86= x8664=:
+ix86= x8664=: \
 %endif
 %ifarch %{x8664}
 ix86=: x8664= \
+%endif
+%ifarch x32
+ix86=: x8664=: \
 %endif
 	sh -xe %{_sourcedir}/skip-tests.sh
 
@@ -2165,7 +2125,7 @@ if test "$ver" != "%{jsonver}"; then
 	: Update the jsonver macro and rebuild.
 	exit 1
 fi
-ver=$(sed -n '/#define PHP_ZENDOPCACHE_VERSION /{s/.* "//;s/".*$//;p}' ext/opcache/ZendAccelerator.h)
+ver=$(awk '/#define PHP_ZENDOPCACHE_VERSION/ {print $3}' ext/opcache/ZendAccelerator.h | xargs)
 if test "$ver" != "%{opcachever}"; then
 	: Error: Upstream Zend Opcache version is now ${ver}, expecting %{opcachever}.
 	: Update the opcachever macro and rebuild.
@@ -2189,7 +2149,7 @@ if test "$ver" != "%{enchantver}"; then
 	: Update the enchantver macro and rebuild.
 	exit 1
 fi
-ver=$(awk '/#define PHP_HASH_EXTVER/ {print $3}' ext/hash/php_hash.h | xargs)
+ver=$(awk '/#define PHP_HASH_VERSION/ {print $3}' ext/hash/php_hash.h | xargs)
 if test "$ver" != "%{hashver}"; then
 	: Error: Upstream HASH version is now ${ver}, expecting %{hashver}.
 	: Update the hashver macro and rebuild.
@@ -2231,9 +2191,6 @@ fpm
 %if %{with embed}
 embed
 %endif
-%if %{with apache1}
-apxs1
-%endif
 %if %{with apache2}
 apxs2
 %endif
@@ -2263,10 +2220,6 @@ for sapi in $sapis; do
 	embed)
 		sapi_args='--disable-cli --disable-cgi --enable-embed'
 		;;
-	apxs1)
-		ver=$(rpm -q --qf '%{V}' apache1-devel)
-		sapi_args="--disable-cli --disable-cgi --with-apxs=%{apxs1} --with-apache-version=$ver"
-	;;
 	apxs2)
 		ver=$(rpm -q --qf '%{V}' apache-devel)
 		sapi_args="--disable-cli --disable-cgi --with-apxs2=%{apxs2} --with-apache-version=$ver"
@@ -2294,29 +2247,30 @@ for sapi in $sapis; do
 	--%{!?debug:dis}%{?debug:en}able-debug \
 	%{?with_zts:--enable-maintainer-zts} \
 	--enable-inline-optimization \
-	--enable-bcmath=shared \
-	--enable-calendar=shared \
-	--enable-ctype=shared \
-	--enable-dba=shared \
-	--enable-dom=shared \
-	--enable-exif=shared \
-	--enable-fileinfo=shared \
-	--enable-ftp=shared \
+	%{__enable_disable bcmath bcmath shared} \
+	%{__enable_disable calendar calendar shared} \
+	%{__enable_disable ctype ctype shared} \
+	%{__enable_disable dba dba shared} \
+	%{__enable_disable dom dom shared} \
+	%{?with_systemtap:--enable-dtrace} \
+	%{__enable_disable exif exif shared} \
+	%{__enable_disable fileinfo fileinfo shared} \
+	%{__enable_disable ftp ftp shared} \
 	--enable-gd-native-ttf \
 	%{?with_intl:--enable-intl=shared} \
 	--enable-libxml \
-	--enable-mbstring=shared,all \
+	%{__enable_disable mbstring mbstring shared,all} \
 	--enable-mbregex \
-	--enable-pcntl=shared \
-	--enable-pdo=shared \
-	--enable-json=shared \
-	--enable-hash=shared \
+	%{__enable_disable pcntl pcntl shared} \
+	%{__enable_disable pdo pdo shared} \
+	%{__enable_disable json json shared} \
+	%{__enable_disable hash hash shared} \
 	--enable-xmlwriter=shared \
 %if %{with fpm}
 	--with-fpm-user=http \
 	--with-fpm-group=http \
 %endif
-%if %{with mssql} || %{with sybase_ct}
+%if %{with pdo_dblib}
 	--with-pdo-dblib=shared \
 %endif
 %if %{with interbase} && %{without interbase_inst}
@@ -2324,16 +2278,16 @@ for sapi in $sapis; do
 %endif
 	%{?with_mhash:--with-mhash=yes} \
 	--with-mysql-sock=/var/lib/mysql/mysql.sock \
-	--with-pdo-mysql=shared,%{!?with_mysqlnd:/usr}%{?with_mysqlnd:mysqlnd} \
+	%{__with_without pdo_mysql pdo-mysql shared,%{!?with_mysqlnd:/usr}%{?with_mysqlnd:mysqlnd}} \
 	%{?with_oci:--with-pdo-oci=shared%{?with_instantclient:,instantclient,%{_libdir}}} \
 	%{?with_odbc:--with-pdo-odbc=shared,unixODBC,/usr} \
 	%{?with_pgsql:--with-pdo-pgsql=shared} \
 	%{?with_pdo_sqlite:--with-pdo-sqlite=shared,/usr} \
 	%{?with_webp:--with-vpx-dir=/usr} \
 	--without-libexpat-dir \
-	--enable-posix=shared \
+	%{__enable_disable posix posix shared} \
 	--enable-shared \
-	--enable-session=shared \
+	%{__enable_disable session session shared} \
 	--enable-shmop=shared \
 	--enable-simplexml=shared \
 	--enable-sysvmsg=shared \
@@ -2345,28 +2299,26 @@ for sapi in $sapis; do
 	%{?with_wddx:--enable-wddx=shared} \
 	--enable-xml=shared \
 	--enable-xmlreader=shared \
-	--with-bz2=shared \
+	%{__with_without bz2 bz2 shared} \
 	%{__with_without curl curl shared} \
 	--with-db4 \
-	--with-iconv=shared \
+	%{__with_without iconv iconv shared} \
 	%{?with_enchant:--with-enchant=shared,/usr} \
 	--with-freetype-dir=shared \
-	--with-gettext=shared \
-	--with-gd=shared%{?with_system_gd:,/usr} \
+	%{__with_without gettext gettext shared} \
+	%{__with_without gd gd shared%{?with_system_gd:,/usr}} \
 	--with-gdbm \
-	--with-gmp=shared \
+	%{__with_without gmp gmp shared} \
 	%{?with_imap:--with-imap=shared --with-imap-ssl} \
 	%{?with_interbase:--with-interbase=shared%{!?with_interbase_inst:,/usr}} \
 	--with-jpeg-dir=/usr \
 	%{?with_ldap:--with-ldap=shared --with-ldap-sasl} \
-	--with-mcrypt=shared \
+	%{__with_without mcrypt mcrypt shared} \
 	%{?with_mm:--with-mm} \
-	%{?with_mssql:--with-mssql=shared} \
 	%{?with_mysqlnd:--enable-mysqlnd=shared} \
-	--with-mysql=shared,%{!?with_mysqlnd:/usr}%{?with_mysqlnd:mysqlnd} \
 	%{?with_mysqli:--with-mysqli=shared,%{!?with_mysqlnd:/usr/bin/mysql_config}%{?with_mysqlnd:mysqlnd}} \
 	%{?with_oci:--with-oci8=shared%{?with_instantclient:,instantclient,%{_libdir}}} \
-	%{?with_opcache:--enable-opcache=shared} \
+	%{__enable_disable opcache opcache shared} \
 	%{?with_openssl:--with-openssl=shared} \
 	%{?with_kerberos5:--with-kerberos} \
 	--with-tcadb=/usr \
@@ -2377,14 +2329,12 @@ for sapi in $sapis; do
 	%{__enable_disable phar phar shared} \
 	--with-png-dir=/usr \
 	%{?with_pspell:--with-pspell=shared} \
-	--with-readline=shared \
+	%{__with_without readline readline shared} \
 	%{?with_recode:--with-recode=shared} \
-	--with-regex=system \
+	%{__with_without ereg regex system} \
 	%{?with_snmp:--with-snmp=shared} \
-	%{?with_sybase_ct:--with-sybase-ct=shared,/usr} \
 	%{!?with_pdo_sqlite:--without-pdo-sqlite} \
 	%{__with_without sqlite3 sqlite3 shared,/usr} \
-	--with-t1lib=shared \
 	%{?with_tidy:--with-tidy=shared} \
 	%{?with_odbc:--with-unixODBC=shared,/usr} \
 	%{__with_without xmlrpc xmlrpc shared,/usr} \
@@ -2412,12 +2362,8 @@ cp -af Makefile.cli Makefile
 %{__make} build-modules \
 	MYSQLND_SHARED_LIBADD="-lssl -lcrypto"
 
-%if %{with apache1}
-%{__make} libtool-sapi LIBTOOL_SAPI=sapi/apache/libphp5.la -f Makefile.apxs1
-%endif
-
 %if %{with apache2}
-%{__make} libtool-sapi LIBTOOL_SAPI=sapi/apache2handler/libphp5.la -f Makefile.apxs2
+%{__make} libtool-sapi LIBTOOL_SAPI=sapi/apache2handler/libphp7.la -f Makefile.apxs2
 %endif
 
 %if %{with litespeed}
@@ -2425,7 +2371,7 @@ cp -af Makefile.cli Makefile
 %endif
 
 %if %{with embed}
-%{__make} -f Makefile.embed libphp5.la
+%{__make} -f Makefile.embed libphp7.la
 %endif
 
 %if %{with phpdbg}
@@ -2478,7 +2424,7 @@ generate_inifiles() {
 		[ "$mod" = "spl" ] && conf="SPL.ini"
 		# session needs to be loaded before php-pecl-http, php-pecl-memcache, php-pecl-session_mysql
 		[ "$mod" = "session" ] && conf="Session.ini"
-		# mysqlnd needs to be loaded before mysql,mysqli,pdo_mysqli
+		# mysqlnd needs to be loaded before mysqli,pdo_mysqli
 		[ "$mod" = "mysqlnd" ] && conf="MySQLND.ini"
 		echo "+ $conf"
 		cat > conf.d/$conf <<-EOF
@@ -2508,6 +2454,7 @@ exit 1
 cat <<'EOF' > run-tests.sh
 #!/bin/sh
 export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2
+export SKIP_ONLINE_TESTS=1
 unset TZ LANG LC_ALL || :
 %{__make} test \
 	EXTENSION_DIR=modules \
@@ -2550,24 +2497,20 @@ cp -pf Makefile.cli Makefile
 	phpbuilddir=%{_libdir}/%{name}/build \
 	INSTALL_ROOT=$RPM_BUILD_ROOT
 
+# version the .phar files
+mv $RPM_BUILD_ROOT%{_bindir}/phar{,%{ver_suffix}}.phar
+mv $RPM_BUILD_ROOT%{_mandir}/man1/phar{,%{ver_suffix}}.phar.1
 # make link relative
-ln -sfn phar.phar $RPM_BUILD_ROOT%{_bindir}/phar
+ln -sfn phar%{ver_suffix}.phar $RPM_BUILD_ROOT%{_bindir}/phar
 
 # version suffix
 v=$(echo %{version} | cut -d. -f1-2)
 
-# install Apache1 DSO module
-%if %{with apache1}
-libtool --mode=install install -p sapi/apache/libphp5.la $RPM_BUILD_ROOT%{_libdir}/apache1
-mv $RPM_BUILD_ROOT%{_libdir}/apache1/libphp5{,-$v}.so
-ln -s libphp5-$v.so $RPM_BUILD_ROOT%{_libdir}/apache1/libphp5.so
-%endif
-
 # install Apache2 DSO module
 %if %{with apache2}
-libtool --mode=install install -p sapi/apache2handler/libphp5.la $RPM_BUILD_ROOT%{_libdir}/apache
-mv $RPM_BUILD_ROOT%{_libdir}/apache/libphp5{,-$v}.so
-ln -s libphp5-$v.so $RPM_BUILD_ROOT%{_libdir}/apache/libphp5.so
+libtool --mode=install install -p sapi/apache2handler/libphp7.la $RPM_BUILD_ROOT%{_libdir}/apache
+mv $RPM_BUILD_ROOT%{_libdir}/apache/libphp7{,-$v}.so
+ln -s libphp7-$v.so $RPM_BUILD_ROOT%{_libdir}/apache/mod_php.so
 %endif
 
 # install litespeed sapi
@@ -2597,11 +2540,11 @@ cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/php-cgi-fcgi.ini
 
 # install FCGI PM
 %if %{with fpm}
-install -d $RPM_BUILD_ROOT{%{_sysconfdir}/fpm.d,%{_sbindir}}
+install -d $RPM_BUILD_ROOT{%{_sysconfdir}/php-fpm.d,%{_sbindir}}
 libtool --mode=install install -p sapi/fpm/php-fpm $RPM_BUILD_ROOT%{_sbindir}/%{name}-fpm
 cp -p sapi/fpm/php-fpm.8 $RPM_BUILD_ROOT%{_mandir}/man8/%{name}-fpm.8
 cp -p sapi/fpm/php-fpm.conf $RPM_BUILD_ROOT%{_sysconfdir}
-cp -p sapi/fpm/php-fpm.conf-d $RPM_BUILD_ROOT%{_sysconfdir}/fpm.d/www.conf
+cp -p sapi/fpm/www.conf $RPM_BUILD_ROOT%{_sysconfdir}/php-fpm.d
 install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
 install -p %{SOURCE10} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-fpm
 install -d $RPM_BUILD_ROOT/etc/logrotate.d
@@ -2609,9 +2552,9 @@ cp -p %{SOURCE11} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}-fpm
 
 %{__sed} -i -e '
 	s#/usr/lib/php#%{php_extensiondir}#
-	s#/etc/php#%{_sysconfdir}#
+	s#/etc/php/#%{_sysconfdir}/#
 	s#@processname@#%{name}-fpm#g
-' $RPM_BUILD_ROOT{/etc/{rc.d/init.d/%{name}-fpm,logrotate.d/%{name}-fpm},%{_sysconfdir}/php-fpm.conf,%{_sysconfdir}/fpm.d/www.conf}
+' $RPM_BUILD_ROOT{/etc/{rc.d/init.d/%{name}-fpm,logrotate.d/%{name}-fpm},%{_sysconfdir}/php-fpm.conf,%{_sysconfdir}/php-fpm.d/www.conf}
 %endif
 
 # install Embedded API
@@ -2619,7 +2562,7 @@ cp -p %{SOURCE11} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}-fpm
 # we could use install-headers from Makefile.embed, but that would reinstall all headers
 # install-sapi installs to wrong dir, so just do it all manually
 install -d $RPM_BUILD_ROOT%{_includedir}/php/sapi/embed
-install -p libs/libphp5.so $RPM_BUILD_ROOT%{_libdir}
+install -p libs/libphp7.so $RPM_BUILD_ROOT%{_libdir}
 cp -p sapi/embed/php_embed.h $RPM_BUILD_ROOT%{_includedir}/php/sapi/embed
 %endif
 
@@ -2638,20 +2581,12 @@ ln -sf php $RPM_BUILD_ROOT%{_bindir}/php.cli
 %endif
 
 cp -p php.ini $RPM_BUILD_ROOT%{_sysconfdir}/php.ini
-
 cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/php-cli.ini
-cp -p %{SOURCE9} $RPM_BUILD_ROOT%{_sysconfdir}/browscap.ini
-
-%if %{with apache1}
-cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/apache/conf.d/70_mod_php.conf
-cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/php-apache.ini
-%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/apache1/libphp5.la
-%endif
 
 %if %{with apache2}
 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/httpd/conf.d/70_mod_php.conf
 cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/php-apache2handler.ini
-%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/apache/libphp5.la
+%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/apache/libphp7.la
 %endif
 
 # ensure that paths are correct for current php version and arch
@@ -2671,12 +2606,19 @@ install -d $RPM_BUILD_ROOT%{_sysconfdir}/{cgi-fcgi,cli,apache,apache2handler}.d
 mv $RPM_BUILD_ROOT%{_sysconfdir}/{conf.d/readline.ini,cli.d}
 
 # use system automake and {lib,sh}tool
-	ln -snf /usr/share/automake/config.{guess,sub} $RPM_BUILD_ROOT%{_libdir}/%{name}/build
-	for i in libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4; do
-		ln -snf %{_aclocaldir}/${i} $RPM_BUILD_ROOT%{_libdir}/%{name}/build
-	done
-	ln -snf %{_datadir}/libtool/config/ltmain.sh $RPM_BUILD_ROOT%{_libdir}/%{name}/build
+ln -snf /usr/share/automake/config.{guess,sub} $RPM_BUILD_ROOT%{_libdir}/%{name}/build
 ln -snf %{_bindir}/shtool $RPM_BUILD_ROOT%{_libdir}/%{name}/build
+for fn in libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4; do
+	f=%{_aclocaldir}/$fn
+	test -f $f || continue
+	ln -snf $f $RPM_BUILD_ROOT%{_libdir}/%{name}/build
+done
+for fn in ltmain.sh config/ltmain.sh build-aux/ltmain.sh; do
+	f=/usr/share/libtool/$fn
+	test -f $f || continue
+	ln -snf $f $RPM_BUILD_ROOT%{_libdir}/%{name}/build
+	break
+done
 sed -i -e '/^phpdir/ s,/php/build,/%{name}/build,' $RPM_BUILD_ROOT%{_bindir}/phpize
 
 # for php-pecl-mailparse
@@ -2696,16 +2638,6 @@ sed -i -e 's|libphp_common.la|$(libdir)/libphp_common.la|' $RPM_BUILD_ROOT%{_lib
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post -n apache1-mod_%{name}
-if [ "$1" = "1" ]; then
-	%service -q apache restart
-fi
-
-%postun -n apache1-mod_%{name}
-if [ "$1" = "0" ]; then
-	%service -q apache restart
-fi
-
 %post -n apache-mod_%{name}
 if [ "$1" = "1" ]; then
 	%service -q httpd restart
@@ -2724,7 +2656,7 @@ fi
 %service %{name}-fpm restart
 
 %preun fpm
-if [ "$1" = 0 ]; then
+if [ "$1" = "0" ]; then
 	%service %{name}-fpm stop
 	/sbin/chkconfig --del %{name}-fpm
 fi
@@ -2774,14 +2706,25 @@ for f in /etc/php/*.ini.rpmsave /etc/php/*.d/*.ini.rpmsave; do
 	fn=${fn%.rpmsave}
 	nf=%{_sysconfdir}/$dn/$fn
 	test -f "$nf" || continue
-	cp -vf $nf{,.rpmnew}
-	mv -vf $f $nf
+	cp -vfb $nf{,.rpmnew}
+	cp -vfb $f $nf
 	%{__sed} -i -e '
 		s#%{_libdir}/php#%{_libdir}/%{name}#
 		s#/etc/php#%{_sysconfdir}#
 	' $nf
 done
 
+%triggerpostun common -- %{name}-common < 4:5.6.4-2, php-common < 4:5.6.4-2
+# switch to browscap package if the ini file has original value
+%{__sed} -i -e 's#%{_sysconfdir}/browscap.ini#/usr/share/browscap/php_browscap.ini#' %{_sysconfdir}/php.ini
+# disable browscap, if optional package not present
+if [ ! -e /usr/share/browscap/php_browscap.ini ]; then
+	%{__sed} -i -e 's#^browscap = /usr/share/browscap/php_browscap.ini#;&#' %{_sysconfdir}/php.ini
+fi
+
+%triggerpostun -n apache-mod_%{name} -- apache-mod_%{name} < 4:7.0.0-2.RC4
+sed -i -e 's#modules/libphp[57].so#modules/mod_php.so#g' /etc/httpd/conf.d/*_mod_php.conf
+
 # common macros called at extension post/postun scriptlet
 %define	extension_scripts() \
 %post %1 \
@@ -2820,8 +2763,6 @@ fi
 %extension_scripts ldap
 %extension_scripts mbstring
 %extension_scripts mcrypt
-%extension_scripts mssql
-%extension_scripts mysql
 %extension_scripts mysqli
 %extension_scripts mysqlnd
 %extension_scripts oci8
@@ -2851,7 +2792,6 @@ fi
 %extension_scripts sockets
 %extension_scripts spl
 %extension_scripts sqlite3
-%extension_scripts sybase-ct
 %extension_scripts sysvmsg
 %extension_scripts sysvsem
 %extension_scripts sysvshm
@@ -2866,24 +2806,14 @@ fi
 %extension_scripts zip
 %extension_scripts zlib
 
-%if %{with apache1}
-%files -n apache1-mod_%{name}
-%defattr(644,root,root,755)
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/apache/conf.d/*_mod_php.conf
-%dir %{_sysconfdir}/apache.d
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-apache.ini
-%attr(755,root,root) %{_libdir}/apache1/libphp5.so
-%attr(755,root,root) %{_libdir}/apache1/libphp5-*.*.so
-%endif
-
 %if %{with apache2}
 %files -n apache-mod_%{name}
 %defattr(644,root,root,755)
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/httpd/conf.d/*_mod_php.conf
 %dir %{_sysconfdir}/apache2handler.d
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-apache2handler.ini
-%attr(755,root,root) %{_libdir}/apache/libphp5.so
-%attr(755,root,root) %{_libdir}/apache/libphp5-*.*.so
+%attr(755,root,root) %{_libdir}/apache/mod_php.so
+%attr(755,root,root) %{_libdir}/apache/libphp7-*.*.so
 %endif
 
 %if %{with litespeed}
@@ -2904,7 +2834,7 @@ fi
 %if %{with embed}
 %files embedded
 %defattr(644,root,root,755)
-%attr(755,root,root) %{_libdir}/libphp5.so
+%attr(755,root,root) %{_libdir}/libphp7.so
 %endif
 
 %files cli
@@ -2923,9 +2853,9 @@ fi
 %files fpm
 %defattr(644,root,root,755)
 %doc sapi/fpm/{CREDITS,LICENSE}
-%dir %{_sysconfdir}/fpm.d
+%dir %{_sysconfdir}/php-fpm.d
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-fpm.conf
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/fpm.d/www.conf
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-fpm.d/www.conf
 %attr(755,root,root) %{_sbindir}/%{name}-fpm
 %{_mandir}/man8/%{name}-fpm.8*
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/%{name}-fpm
@@ -2951,7 +2881,6 @@ fi
 %dir %{_sysconfdir}
 %dir %{_sysconfdir}/conf.d
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php.ini
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/browscap.ini
 %attr(755,root,root) %{_libdir}/libphp_common-*.so
 %dir %{php_extensiondir}
 
@@ -2969,28 +2898,36 @@ fi
 %{_mandir}/man1/php-config.1*
 %{_mandir}/man1/phpize.1*
 
+%if %{with bcmath}
 %files bcmath
 %defattr(644,root,root,755)
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/bcmath.ini
 %attr(755,root,root) %{php_extensiondir}/bcmath.so
+%endif
 
+%if %{with bz2}
 %files bz2
 %defattr(644,root,root,755)
 %doc ext/bz2/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/bz2.ini
 %attr(755,root,root) %{php_extensiondir}/bz2.so
+%endif
 
+%if %{with calendar}
 %files calendar
 %defattr(644,root,root,755)
 %doc ext/calendar/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/calendar.ini
 %attr(755,root,root) %{php_extensiondir}/calendar.so
+%endif
 
+%if %{with ctype}
 %files ctype
 %defattr(644,root,root,755)
 %doc ext/calendar/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ctype.ini
 %attr(755,root,root) %{php_extensiondir}/ctype.so
+%endif
 
 %if %{with curl}
 %files curl
@@ -3000,18 +2937,22 @@ fi
 %attr(755,root,root) %{php_extensiondir}/curl.so
 %endif
 
+%if %{with dba}
 %files dba
 %defattr(644,root,root,755)
 %doc ext/dba/{CREDITS,README}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/dba.ini
 %attr(755,root,root) %{php_extensiondir}/dba.so
+%endif
 
+%if %{with dom}
 %files dom
 %defattr(644,root,root,755)
 %doc ext/dom/{CREDITS,TODO}
 %doc ext/dom/examples
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/dom.ini
 %attr(755,root,root) %{php_extensiondir}/dom.so
+%endif
 
 %if %{with enchant}
 %files enchant
@@ -3021,17 +2962,21 @@ fi
 %attr(755,root,root) %{php_extensiondir}/enchant.so
 %endif
 
+%if %{with exif}
 %files exif
 %defattr(644,root,root,755)
 %doc ext/exif/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/exif.ini
 %attr(755,root,root) %{php_extensiondir}/exif.so
+%endif
 
+%if %{with fileinfo}
 %files fileinfo
 %defattr(644,root,root,755)
 %doc ext/fileinfo/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/fileinfo.ini
 %attr(755,root,root) %{php_extensiondir}/fileinfo.so
+%endif
 
 %if %{with filter}
 %files filter
@@ -3041,41 +2986,53 @@ fi
 %attr(755,root,root) %{php_extensiondir}/filter.so
 %endif
 
+%if %{with ftp}
 %files ftp
 %defattr(644,root,root,755)
 %doc ext/ftp/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ftp.ini
 %attr(755,root,root) %{php_extensiondir}/ftp.so
+%endif
 
+%if %{with gd}
 %files gd
 %defattr(644,root,root,755)
 %doc ext/gd/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gd.ini
 %attr(755,root,root) %{php_extensiondir}/gd.so
+%endif
 
+%if %{with gettext}
 %files gettext
 %defattr(644,root,root,755)
 %doc ext/gettext/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gettext.ini
 %attr(755,root,root) %{php_extensiondir}/gettext.so
+%endif
 
+%if %{with gmp}
 %files gmp
 %defattr(644,root,root,755)
 %doc ext/gmp/{CREDITS,README,TODO}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gmp.ini
 %attr(755,root,root) %{php_extensiondir}/gmp.so
+%endif
 
+%if %{with hash}
 %files hash
 %defattr(644,root,root,755)
 %doc ext/hash/{CREDITS,README}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/hash.ini
 %attr(755,root,root) %{php_extensiondir}/hash.so
+%endif
 
+%if %{with iconv}
 %files iconv
 %defattr(644,root,root,755)
 %doc ext/iconv/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/iconv.ini
 %attr(755,root,root) %{php_extensiondir}/iconv.so
+%endif
 
 %if %{with imap}
 %files imap
@@ -3101,11 +3058,13 @@ fi
 %attr(755,root,root) %{php_extensiondir}/intl.so
 %endif
 
+%if %{with json}
 %files json
 %defattr(644,root,root,755)
 %doc ext/json/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/json.ini
 %attr(755,root,root) %{php_extensiondir}/json.so
+%endif
 
 %if %{with ldap}
 %files ldap
@@ -3115,32 +3074,22 @@ fi
 %attr(755,root,root) %{php_extensiondir}/ldap.so
 %endif
 
+%if %{with mbstring}
 %files mbstring
 %defattr(644,root,root,755)
 %doc ext/mbstring/{CREDITS,README*}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mbstring.ini
 %attr(755,root,root) %{php_extensiondir}/mbstring.so
+%endif
 
+%if %{with mcrypt}
 %files mcrypt
 %defattr(644,root,root,755)
 %doc ext/mcrypt/{CREDITS,TODO}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mcrypt.ini
 %attr(755,root,root) %{php_extensiondir}/mcrypt.so
-
-%if %{with mssql}
-%files mssql
-%defattr(644,root,root,755)
-%doc ext/mssql/CREDITS
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mssql.ini
-%attr(755,root,root) %{php_extensiondir}/mssql.so
 %endif
 
-%files mysql
-%defattr(644,root,root,755)
-%doc ext/mysql/CREDITS
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mysql.ini
-%attr(755,root,root) %{php_extensiondir}/mysql.so
-
 %if %{with mysqli}
 %files mysqli
 %defattr(644,root,root,755)
@@ -3189,11 +3138,13 @@ fi
 %attr(755,root,root) %{php_extensiondir}/openssl.so
 %endif
 
+%if %{with pcntl}
 %files pcntl
 %defattr(644,root,root,755)
 %doc ext/pcntl/{CREDITS,README}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pcntl.ini
 %attr(755,root,root) %{php_extensiondir}/pcntl.so
+%endif
 
 %if %{with pcre}
 %files pcre
@@ -3203,13 +3154,15 @@ fi
 %attr(755,root,root) %{php_extensiondir}/pcre.so
 %endif
 
+%if %{with pdo}
 %files pdo
 %defattr(644,root,root,755)
 %doc ext/pdo/{CREDITS,README,TODO}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo.ini
 %attr(755,root,root) %{php_extensiondir}/pdo.so
+%endif
 
-%if %{with mssql} || %{with sybase_ct}
+%if %{with pdo_dblib}
 %files pdo-dblib
 %defattr(644,root,root,755)
 %doc ext/pdo_dblib/{CREDITS,README}
@@ -3225,11 +3178,13 @@ fi
 %attr(755,root,root) %{php_extensiondir}/pdo_firebird.so
 %endif
 
+%if %{with pdo_mysql}
 %files pdo-mysql
 %defattr(644,root,root,755)
 %doc ext/pdo_mysql/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_mysql.ini
 %attr(755,root,root) %{php_extensiondir}/pdo_mysql.so
+%endif
 
 %if %{with oci}
 %files pdo-oci
@@ -3278,16 +3233,18 @@ fi
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/phar.ini
 %attr(755,root,root) %{php_extensiondir}/phar.so
 %attr(755,root,root) %{_bindir}/phar
-%attr(755,root,root) %{_bindir}/phar.phar
+%attr(755,root,root) %{_bindir}/phar%{ver_suffix}.phar
 %{_mandir}/man1/phar.1*
-%{_mandir}/man1/phar.phar.1
+%{_mandir}/man1/phar%{ver_suffix}.phar.1
 %endif
 
+%if %{with posix}
 %files posix
 %defattr(644,root,root,755)
 %doc ext/posix/CREDITS
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/posix.ini
 %attr(755,root,root) %{php_extensiondir}/posix.so
+%endif
 
 %if %{with pspell}
 %files pspell
@@ -3297,11 +3254,13 @@ fi
 %attr(755,root,root) %{php_extensiondir}/pspell.so
 %endif
 
+%if %{with readline}
 %files readline
 %defattr(644,root,root,755)
 %doc ext/readline/{CREDITS,README*}
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cli.d/readline.ini
 %attr(755,root,root) %{php_extensiondir}/readline.so
+%endif
 
 %if %{with recode}
 %files recode
@@ -3311,12 +3270,14 @@ fi
 %attr(755,root,root) %{php_extensiondir}/recode.so
 %endif
 
+%if %{with session}
 %files session
 %defattr(644,root,root,755)
 %doc ext/session/CREDITS
 %doc ext/session/mod_files.sh
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/Session.ini
 %attr(755,root,root) %{php_extensiondir}/session.so
+%endif
 
 %files shmop
 %defattr(644,root,root,755)
@@ -3366,14 +3327,6 @@ fi
 %attr(755,root,root) %{php_extensiondir}/sqlite3.so
 %endif
 
-%if %{with sybase_ct}
-%files sybase-ct
-%defattr(644,root,root,755)
-%doc ext/sybase_ct/CREDITS
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sybase_ct.ini
-%attr(755,root,root) %{php_extensiondir}/sybase_ct.so
-%endif
-
 %files sysvmsg
 %defattr(644,root,root,755)
 %doc ext/sysvmsg/CREDITS
diff --git a/skip-tests.sh b/skip-tests.sh
index 8d76b12..a090b7d 100644
--- a/skip-tests.sh
+++ b/skip-tests.sh
@@ -1,8 +1,6 @@
 #!/bin/sh
-# timezone_location_get: Test that timezone_location_get returns a correct array of information
-mv ext/date/tests/timezone_location_get.phpt{,.skip}
 # DBA DB4 magic_quotes_runtime Test (info: DB4 handler used)
-mv ext/dba/tests/dba_db4_010.phpt{,.skip}
+#mv ext/dba/tests/dba_db4_010.phpt{,.skip}
 # DBA TCADB handler test
 mv ext/dba/tests/dba_tcadb.phpt{,.skip}
 # enchant_broker_describe() function
@@ -11,50 +9,6 @@ $x86 && mv ext/enchant/tests/broker_describe.phpt{,.skip}
 $x86 && mv ext/enchant/tests/broker_request_dict.phpt{,.skip}
 # bug #13181, leaving a context frees the broker resources
 $x86 && mv ext/enchant/tests/bug13181.phpt{,.skip}
-# Test ereg() function : basic functionality (with $regs)
-mv ext/ereg/tests/ereg_basic_001.phpt{,.skip}
-# Test ereg() function : basic functionality  (without $regs)
-mv ext/ereg/tests/ereg_basic_002.phpt{,.skip}
-# Test ereg() function : error conditions - test bad regular expressions
-mv ext/ereg/tests/ereg_error_002.phpt{,.skip}
-# Test ereg_replace() function : basic functionality
-mv ext/ereg/tests/ereg_replace_basic_001.phpt{,.skip}
-# Test ereg_replace() function : error conditions - bad regular expressions
-mv ext/ereg/tests/ereg_replace_error_002.phpt{,.skip}
-# Test ereg_replace() function : usage variations - unexpected type arg 1
-mv ext/ereg/tests/ereg_replace_variation_001.phpt{,.skip}
-# Test ereg() function : usage variations  - unexpected type arg 1
-mv ext/ereg/tests/ereg_variation_001.phpt{,.skip}
-# Test eregi() function : basic functionality (with $regs)
-mv ext/ereg/tests/eregi_basic_001.phpt{,.skip}
-# Test eregi() function : basic functionality  (without $regs)
-mv ext/ereg/tests/eregi_basic_002.phpt{,.skip}
-# Test eregi() function : error conditions - test bad regular expressions
-mv ext/ereg/tests/eregi_error_002.phpt{,.skip}
-# Test ereg() function : basic functionality
-mv ext/ereg/tests/eregi_replace_basic_001.phpt{,.skip}
-# Test eregi_replace() function : error conditions - bad regular expressions
-mv ext/ereg/tests/eregi_replace_error_002.phpt{,.skip}
-# Test eregi_replace() function : usage variations - unexpected type arg 1
-mv ext/ereg/tests/eregi_replace_variation_001.phpt{,.skip}
-# Test eregi() function : usage variations  - unexpected type arg 1
-mv ext/ereg/tests/eregi_variation_001.phpt{,.skip}
-# Test split() function : basic functionality - test a number of simple split, specifying a limit
-mv ext/ereg/tests/split_basic_001.phpt{,.skip}
-# Test split() function : basic functionality - test a number of simple split, without specifying a limit
-mv ext/ereg/tests/split_basic_002.phpt{,.skip}
-# Test split() function : error conditions - test bad regular expressions
-mv ext/ereg/tests/split_error_002.phpt{,.skip}
-# Test split() function : usage variations  - unexpected type for arg 1
-mv ext/ereg/tests/split_variation_001.phpt{,.skip}
-# Test spliti() function : basic functionality - test a number of simple spliti, specifying a limit
-mv ext/ereg/tests/spliti_basic_001.phpt{,.skip}
-# Test spliti() function : basic functionality - test a number of simple spliti, without specifying a limit
-mv ext/ereg/tests/spliti_basic_002.phpt{,.skip}
-# Test spliti() function : error conditions - test bad regular expressions
-mv ext/ereg/tests/spliti_error_002.phpt{,.skip}
-# Test spliti() function : usage variations  - unexpected type for arg 1
-mv ext/ereg/tests/spliti_variation_001.phpt{,.skip}
 # Bug #60150 (Integer overflow during the parsing of invalid exif header)
 $ix86 mv ext/exif/tests/bug60150.phpt{,.skip}
 # Bug #52209 (INPUT_ENV returns NULL for set variables (CLI))
@@ -119,10 +73,6 @@ mv ext/snmp/tests/snmpset.phpt{,.skip}
 mv ext/snmp/tests/snmpwalk.phpt{,.skip}
 # SOAP Server 9: setclass and setpersistence(SOAP_PERSISTENCE_SESSION)
 mv ext/soap/tests/server009.phpt{,.skip}
-# Multicast support: IPv4 receive options
-mv ext/sockets/tests/mcast_ipv4_recv.phpt{,.skip}
-# Multicast support: IPv6 receive options
-mv ext/sockets/tests/mcast_ipv6_recv.phpt{,.skip}
 # socket_import_stream: Test with multicasting
 mv ext/sockets/tests/socket_import_stream-3.phpt{,.skip}
 # Test function getservbyname()
diff --git a/spl-shared.patch b/spl-shared.patch
index 8c10277..9aea6c4 100644
--- a/spl-shared.patch
+++ b/spl-shared.patch
@@ -1,11 +1,11 @@
---- php-5.3.1/ext/spl/config.m4~	2009-11-26 23:54:34.000000000 +0000
-+++ php-5.3.1/ext/spl/config.m4	2009-11-27 08:04:05.788823797 +0000
+--- php-7.0/ext/spl/config.m4~	2015-05-21 17:57:06.000000000 +0300
++++ php-7.0/ext/spl/config.m4	2015-05-23 11:25:19.609715006 +0300
 @@ -22,6 +22,6 @@
    CPPFLAGS=$old_CPPFLAGS
    AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed])
    AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support]) 
--  PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no)
-+  PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, $ext_shared)
+-  PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
++  PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
    PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
    PHP_ADD_EXTENSION_DEP(spl, pcre, true)
 --- php-5.3.1/ext/spl/spl_iterators.c~	2009-07-04 20:31:27.000000000 +0000
-- 
2.49.0