Skip to content

Commit

Permalink
Make ob_start function signature PHP 5.6 compatible
Browse files Browse the repository at this point in the history
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 facebook#3694

Reviewed By: @paulbiss

Differential Revision: D1677599

Signature: t1:1677599:1415836259:d232548c902e1fdb8a0a3e0cb59d96e7e961253b
  • Loading branch information
JoelMarcey authored and hhvm-bot committed Nov 19, 2014
1 parent e1d0569 commit bdf304d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
14 changes: 12 additions & 2 deletions hphp/runtime/ext/std/ext_std_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
7 changes: 6 additions & 1 deletion hphp/runtime/ext/std/ext_std_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions hphp/runtime/ext/std/ext_std_output.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 </table> tag of the outermost
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions hphp/test/slow/ext_output/output_handler_constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 4 additions & 0 deletions hphp/test/slow/ext_output/output_handler_constants.php.expect
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ int(2)
int(4)
int(8)
int(8)
int(16)
int(32)
int(64)
int(112)

0 comments on commit bdf304d

Please sign in to comment.