From bdf304dbd75568e4ddd65b936e9304e9c97fdc85 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Tue, 18 Nov 2014 16:21:24 -0800 Subject: [PATCH] Make ob_start function signature PHP 5.6 compatible Summary: The `erase` parameter was removed in PHP 5.4. There is now a `flags` parameter. We didn't use `erase` and we don't use `flags` yet either (that is for another issue). But we are call compatible now. Fixes #3694 Reviewed By: @paulbiss Differential Revision: D1677599 Signature: t1:1677599:1415836259:d232548c902e1fdb8a0a3e0cb59d96e7e961253b --- hphp/runtime/ext/std/ext_std_output.cpp | 14 ++++++++++++-- hphp/runtime/ext/std/ext_std_output.h | 7 ++++++- hphp/runtime/ext/std/ext_std_output.php | 8 ++++---- .../slow/ext_output/output_handler_constants.php | 5 +++++ .../ext_output/output_handler_constants.php.expect | 4 ++++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/hphp/runtime/ext/std/ext_std_output.cpp b/hphp/runtime/ext/std/ext_std_output.cpp index db1cf6255a085..8e9661bb0571f 100644 --- a/hphp/runtime/ext/std/ext_std_output.cpp +++ b/hphp/runtime/ext/std/ext_std_output.cpp @@ -35,11 +35,17 @@ const int64_t k_PHP_OUTPUT_HANDLER_CLEAN = 2; const int64_t k_PHP_OUTPUT_HANDLER_FLUSH = 4; const int64_t k_PHP_OUTPUT_HANDLER_END = 8; const int64_t k_PHP_OUTPUT_HANDLER_FINAL = 8; +const int64_t k_PHP_OUTPUT_HANDLER_CLEANABLE = 16; +const int64_t k_PHP_OUTPUT_HANDLER_FLUSHABLE = 32; +const int64_t k_PHP_OUTPUT_HANDLER_REMOVABLE = 64; +const int64_t k_PHP_OUTPUT_HANDLER_STDFLAGS = + k_PHP_OUTPUT_HANDLER_CLEANABLE | k_PHP_OUTPUT_HANDLER_FLUSHABLE | + k_PHP_OUTPUT_HANDLER_REMOVABLE; bool HHVM_FUNCTION(ob_start, const Variant& callback /* = null */, int chunk_size /* = 0 */, - bool erase /* = true */) { - // ignoring chunk_size and erase + int flags /* = k_PHP_OUTPUT_HANDLER_STDFLAGS */) { + // ignoring chunk_size and flags for now if (!callback.isNull()) { CallCtx ctx; @@ -278,6 +284,10 @@ void StandardExtension::initOutput() { INTCONST(PHP_OUTPUT_HANDLER_FLUSH); INTCONST(PHP_OUTPUT_HANDLER_END); INTCONST(PHP_OUTPUT_HANDLER_FINAL); + INTCONST(PHP_OUTPUT_HANDLER_CLEANABLE); + INTCONST(PHP_OUTPUT_HANDLER_FLUSHABLE); + INTCONST(PHP_OUTPUT_HANDLER_REMOVABLE); + INTCONST(PHP_OUTPUT_HANDLER_STDFLAGS); #undef INTCONST loadSystemlib("std_output"); diff --git a/hphp/runtime/ext/std/ext_std_output.h b/hphp/runtime/ext/std/ext_std_output.h index 9b122e614c61e..6ad6c596a32a3 100644 --- a/hphp/runtime/ext/std/ext_std_output.h +++ b/hphp/runtime/ext/std/ext_std_output.h @@ -30,9 +30,14 @@ extern const int64_t k_PHP_OUTPUT_HANDLER_CLEAN; extern const int64_t k_PHP_OUTPUT_HANDLER_FLUSH; extern const int64_t k_PHP_OUTPUT_HANDLER_END; extern const int64_t k_PHP_OUTPUT_HANDLER_FINAL; +extern const int64_t k_PHP_OUTPUT_HANDLER_CLEANABLE; +extern const int64_t k_PHP_OUTPUT_HANDLER_FLUSHABLE; +extern const int64_t k_PHP_OUTPUT_HANDLER_REMOVABLE; +extern const int64_t k_PHP_OUTPUT_HANDLER_STDFLAGS; bool HHVM_FUNCTION(ob_start, const Variant& output_callback = uninit_null(), - int chunk_size = 0, bool erase = true); + int chunk_size = 0, + int flags = k_PHP_OUTPUT_HANDLER_STDFLAGS); void HHVM_FUNCTION(ob_clean); void HHVM_FUNCTION(ob_flush); bool HHVM_FUNCTION(ob_end_clean); diff --git a/hphp/runtime/ext/std/ext_std_output.php b/hphp/runtime/ext/std/ext_std_output.php index e6b7f215be32f..7bae71d1ef1f1 100644 --- a/hphp/runtime/ext/std/ext_std_output.php +++ b/hphp/runtime/ext/std/ext_std_output.php @@ -9,7 +9,7 @@ * Alternatively, ob_end_clean() will silently discard the buffer contents. * Warning Some web servers (e.g. Apache) change the working directory of a * script when calling the callback function. You can change it back by e.g. - * chdir(dirname($_SERVER['SCRIPT_FILENAME'])) in the callback function. + * chdir(dirname($_SERVER['SCRIPT_FILENAME'])) in the callback function. * Output buffers are stackable, that is, you may call ob_start() while * another ob_start() is active. Just make sure that you call ob_end_flush() * the appropriate number of times. If multiple output callback functions are @@ -53,7 +53,7 @@ <<__Native>> function ob_start(mixed $output_callback = null, int $chunk_size = 0, - bool $erase = true): bool; + int $flags = PHP_OUTPUT_HANDLER_STDFLAGS): bool; /* This function discards the contents of the output buffer. This function * does not destroy the output buffer like ob_end_clean() does. @@ -106,7 +106,7 @@ function ob_end_flush(): bool; * servers, especially on Win32, will still buffer the output from your script * until it terminates before transmitting the results to the browser. Server * modules for Apache like mod_gzip may do buffering of their own that will - * cause flush() to not result in data being sent immediately to the client. + * cause flush() to not result in data being sent immediately to the client. * Even the browser may buffer its input before displaying it. Netscape, for * example, buffers text until it receives an end-of-line or the beginning of * a tag, and it won't render tables until the tag of the outermost @@ -118,7 +118,7 @@ function ob_end_flush(): bool; <<__Native>> function flush(): void; -/* Gets the current buffer contents and delete current output buffer. +/* Gets the current buffer contents and delete current output buffer. * ob_get_clean() essentially executes both ob_get_contents() and * ob_end_clean(). * @return mixed - Returns the contents of the output buffer and end output diff --git a/hphp/test/slow/ext_output/output_handler_constants.php b/hphp/test/slow/ext_output/output_handler_constants.php index 0f4fb0d74992b..411ae2bb1dd91 100644 --- a/hphp/test/slow/ext_output/output_handler_constants.php +++ b/hphp/test/slow/ext_output/output_handler_constants.php @@ -9,3 +9,8 @@ var_dump(PHP_OUTPUT_HANDLER_END); var_dump(PHP_OUTPUT_HANDLER_FINAL); + +var_dump(PHP_OUTPUT_HANDLER_CLEANABLE); +var_dump(PHP_OUTPUT_HANDLER_FLUSHABLE); +var_dump(PHP_OUTPUT_HANDLER_REMOVABLE); +var_dump(PHP_OUTPUT_HANDLER_STDFLAGS); diff --git a/hphp/test/slow/ext_output/output_handler_constants.php.expect b/hphp/test/slow/ext_output/output_handler_constants.php.expect index 6aecb7fe94856..bfd28909afa57 100644 --- a/hphp/test/slow/ext_output/output_handler_constants.php.expect +++ b/hphp/test/slow/ext_output/output_handler_constants.php.expect @@ -5,3 +5,7 @@ int(2) int(4) int(8) int(8) +int(16) +int(32) +int(64) +int(112)