[PHP-CVS] svn: /php/php-src/trunk/ main/main.c main/output.c sapi/cli/php_cli_server.c
mike Tue, 31 Jan 2012 08:51:24 + Revision: http://svn.php.net/viewvc?view=revisionrevision=322963 Log: fix headers print to stdout/stderr if no output written; need to make some more testsbefore committing to PHP_5_4; fix crashes and invalid usage of output control in cli server while passing by Changed paths: U php/php-src/trunk/main/main.c U php/php-src/trunk/main/output.c U php/php-src/trunk/sapi/cli/php_cli_server.c Modified: php/php-src/trunk/main/main.c === --- php/php-src/trunk/main/main.c 2012-01-31 07:17:05 UTC (rev 322962) +++ php/php-src/trunk/main/main.c 2012-01-31 08:51:24 UTC (rev 322963) @@ -1738,12 +1738,11 @@ } else { php_output_end_all(TSRMLS_C); } - php_output_deactivate(TSRMLS_C); } zend_end_try(); - /* 4. Send the set HTTP headers (note: This must be done AFTER php_output_discard_all() / php_output_end_all() !!) */ + /* 4. Shutdown output layer (send the set HTTP headers, cleanup output handlers, etc.) */ zend_try { - sapi_send_headers(TSRMLS_C); + php_output_deactivate(TSRMLS_C); } zend_end_try(); /* 5. Reset max_execution_time (no longer executing php code after response sent) */ Modified: php/php-src/trunk/main/output.c === --- php/php-src/trunk/main/output.c 2012-01-31 07:17:05 UTC (rev 322962) +++ php/php-src/trunk/main/output.c 2012-01-31 08:51:24 UTC (rev 322963) @@ -103,6 +103,29 @@ static int (*php_output_direct)(const char *str, size_t str_len) = php_output_stderr; /* }}} */ +/* {{{ void php_output_header(TSRMLS_D) */ +static void php_output_header(TSRMLS_D) +{ + if (!SG(headers_sent)) { + if (!OG(output_start_filename)) { + if (zend_is_compiling(TSRMLS_C)) { + OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C); + OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C); + } else if (zend_is_executing(TSRMLS_C)) { + OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C); + OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C); + } +#if PHP_OUTPUT_DEBUG + fprintf(stderr, !!! output started at: %s (%d)\n, OG(output_start_filename), OG(output_start_lineno)); +#endif + } + if (!php_header(TSRMLS_C)) { + OG(flags) |= PHP_OUTPUT_DISABLED; + } + } +} +/* }}} */ + /* {{{ void php_output_startup(void) * Set up module globals and initalize the conflict and reverse conflict hash tables */ PHPAPI void php_output_startup(void) @@ -149,6 +172,9 @@ { php_output_handler **handler = NULL; + php_output_header(TSRMLS_C); + + OG(flags) ^= PHP_OUTPUT_ACTIVATED; OG(active) = NULL; OG(running) = NULL; @@ -161,7 +187,6 @@ zend_stack_destroy(OG(handlers)); } - OG(flags) ^= PHP_OUTPUT_ACTIVATED; } /* }}} */ @@ -1045,26 +1070,20 @@ } if (context.out.data context.out.used) { + php_output_header(TSRMLS_C); + + if (!(OG(flags) PHP_OUTPUT_DISABLED)) { #if PHP_OUTPUT_DEBUG - fprintf(stderr, ::: sapi_write('%s', %zu)\n, context.out.data, context.out.used); + fprintf(stderr, ::: sapi_write('%s', %zu)\n, context.out.data, context.out.used); #endif - if (!SG(headers_sent) php_header(TSRMLS_C)) { - if (zend_is_compiling(TSRMLS_C)) { - OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C); - OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C); - } else if (zend_is_executing(TSRMLS_C)) { - OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C); - OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C); + sapi_module.ub_write(context.out.data, context.out.used TSRMLS_CC); + + if (OG(flags) PHP_OUTPUT_IMPLICITFLUSH) { + sapi_flush(TSRMLS_C); } -#if PHP_OUTPUT_DEBUG - fprintf(stderr, !!! output started at: %s (%d)\n, OG(output_start_filename), OG(output_start_lineno)); -#endif + + OG(flags) |= PHP_OUTPUT_SENT; } - sapi_module.ub_write(context.out.data, context.out.used TSRMLS_CC); - if (OG(flags) PHP_OUTPUT_IMPLICITFLUSH) { -
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ main/main.c main/output.c sapi/cli/php_cli_server.c
mike Tue, 31 Jan 2012 09:58:26 + Revision: http://svn.php.net/viewvc?view=revisionrevision=322964 Log: MFH: r322963 fix headers print to stdout/stderr if no output written; fix crashes and invalid usage of output control in cli server while passing by Changed paths: _U php/php-src/branches/PHP_5_4/ U php/php-src/branches/PHP_5_4/main/main.c U php/php-src/branches/PHP_5_4/main/output.c U php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c Property changes on: php/php-src/branches/PHP_5_4 ___ Modified: svn:mergeinfo - /php/php-src/trunk:284726,322419,322421,322423 + /php/php-src/trunk:284726,322419,322421,322423,322963 Modified: php/php-src/branches/PHP_5_4/main/main.c === --- php/php-src/branches/PHP_5_4/main/main.c2012-01-31 08:51:24 UTC (rev 322963) +++ php/php-src/branches/PHP_5_4/main/main.c2012-01-31 09:58:26 UTC (rev 322964) @@ -1738,12 +1738,11 @@ } else { php_output_end_all(TSRMLS_C); } - php_output_deactivate(TSRMLS_C); } zend_end_try(); - /* 4. Send the set HTTP headers (note: This must be done AFTER php_output_discard_all() / php_output_end_all() !!) */ + /* 4. Shutdown output layer (send the set HTTP headers, cleanup output handlers, etc.) */ zend_try { - sapi_send_headers(TSRMLS_C); + php_output_deactivate(TSRMLS_C); } zend_end_try(); /* 5. Reset max_execution_time (no longer executing php code after response sent) */ Modified: php/php-src/branches/PHP_5_4/main/output.c === --- php/php-src/branches/PHP_5_4/main/output.c 2012-01-31 08:51:24 UTC (rev 322963) +++ php/php-src/branches/PHP_5_4/main/output.c 2012-01-31 09:58:26 UTC (rev 322964) @@ -103,6 +103,29 @@ static int (*php_output_direct)(const char *str, size_t str_len) = php_output_stderr; /* }}} */ +/* {{{ void php_output_header(TSRMLS_D) */ +static void php_output_header(TSRMLS_D) +{ + if (!SG(headers_sent)) { + if (!OG(output_start_filename)) { + if (zend_is_compiling(TSRMLS_C)) { + OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C); + OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C); + } else if (zend_is_executing(TSRMLS_C)) { + OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C); + OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C); + } +#if PHP_OUTPUT_DEBUG + fprintf(stderr, !!! output started at: %s (%d)\n, OG(output_start_filename), OG(output_start_lineno)); +#endif + } + if (!php_header(TSRMLS_C)) { + OG(flags) |= PHP_OUTPUT_DISABLED; + } + } +} +/* }}} */ + /* {{{ void php_output_startup(void) * Set up module globals and initalize the conflict and reverse conflict hash tables */ PHPAPI void php_output_startup(void) @@ -149,6 +172,9 @@ { php_output_handler **handler = NULL; + php_output_header(TSRMLS_C); + + OG(flags) ^= PHP_OUTPUT_ACTIVATED; OG(active) = NULL; OG(running) = NULL; @@ -161,7 +187,6 @@ zend_stack_destroy(OG(handlers)); } - OG(flags) ^= PHP_OUTPUT_ACTIVATED; } /* }}} */ @@ -1045,26 +1070,20 @@ } if (context.out.data context.out.used) { + php_output_header(TSRMLS_C); + + if (!(OG(flags) PHP_OUTPUT_DISABLED)) { #if PHP_OUTPUT_DEBUG - fprintf(stderr, ::: sapi_write('%s', %zu)\n, context.out.data, context.out.used); + fprintf(stderr, ::: sapi_write('%s', %zu)\n, context.out.data, context.out.used); #endif - if (!SG(headers_sent) php_header(TSRMLS_C)) { - if (zend_is_compiling(TSRMLS_C)) { - OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C); - OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C); - } else if (zend_is_executing(TSRMLS_C)) { - OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C); - OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C); + sapi_module.ub_write(context.out.data, context.out.used TSRMLS_CC); + + if (OG(flags) PHP_OUTPUT_IMPLICITFLUSH) { + sapi_flush(TSRMLS_C); } -#if PHP_OUTPUT_DEBUG - fprintf(stderr, !!! output
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c
mike Tue, 31 Jan 2012 10:47:21 + Revision: http://svn.php.net/viewvc?view=revisionrevision=322966 Log: fix usage of php_output_(de)activate; I guess this code doesn't bother about one more hack; Changed paths: U php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c U php/php-src/trunk/sapi/cli/php_cli_server.c Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c === --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c 2012-01-31 10:47:11 UTC (rev 322965) +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c 2012-01-31 10:47:21 UTC (rev 322966) @@ -1755,11 +1755,22 @@ int err = 0; zval *style = NULL; zend_try { + if (!SG(sapi_started)) { + php_output_activate(TSRMLS_C); + } php_output_start_user(NULL, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC); php_info_print_style(TSRMLS_C); MAKE_STD_ZVAL(style); php_output_get_contents(style TSRMLS_CC); php_output_discard(TSRMLS_C); + if (!SG(sapi_started)) { + static int (*send_header_func)(sapi_headers_struct * TSRMLS_DC); + send_header_func = sapi_module.send_headers; + /* we don't want the header to be sent now */ + sapi_module.send_headers = sapi_cli_server_discard_headers; + php_output_deactivate(TSRMLS_C); + sapi_module.send_headers = send_header_func; + } if (style Z_STRVAL_P(style)) { char *block = pestrndup(Z_STRVAL_P(style), Z_STRLEN_P(style), 1); php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new(block, block, Z_STRLEN_P(style)); Modified: php/php-src/trunk/sapi/cli/php_cli_server.c === --- php/php-src/trunk/sapi/cli/php_cli_server.c 2012-01-31 10:47:11 UTC (rev 322965) +++ php/php-src/trunk/sapi/cli/php_cli_server.c 2012-01-31 10:47:21 UTC (rev 322966) @@ -1755,11 +1755,22 @@ int err = 0; zval *style = NULL; zend_try { + if (!SG(sapi_started)) { + php_output_activate(TSRMLS_C); + } php_output_start_user(NULL, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC); php_info_print_style(TSRMLS_C); MAKE_STD_ZVAL(style); php_output_get_contents(style TSRMLS_CC); php_output_discard(TSRMLS_C); + if (!SG(sapi_started)) { + static int (*send_header_func)(sapi_headers_struct * TSRMLS_DC); + send_header_func = sapi_module.send_headers; + /* we don't want the header to be sent now */ + sapi_module.send_headers = sapi_cli_server_discard_headers; + php_output_deactivate(TSRMLS_C); + sapi_module.send_headers = send_header_func; + } if (style Z_STRVAL_P(style)) { char *block = pestrndup(Z_STRVAL_P(style), Z_STRLEN_P(style), 1); php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new(block, block, Z_STRLEN_P(style)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/pdo_sqlite/sqlite_driver.c branches/PHP_5_4/ext/pdo_sqlite/sqlite_driver.c trunk/ext/pdo_sqlite/sqlite_driver.c
On 01/31/2012 02:14 AM, Pierre Joye wrote: - struct pdo_sqlite_collation *collation; - while (H-collations) { + struct pdo_sqlite_collation *collation; collation = H-collations; H-collations = collation-next; Why would this change fix anything? You are just tightening the scope of collation there? This compiled perfectly with gcc before this change. -Rasmus -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/pdo_sqlite/sqlite_driver.c branches/PHP_5_4/ext/pdo_sqlite/sqlite_driver.c trunk/ext/pdo_sqlite/sqlite_driver.c
hi, GCC is only being very bad at considering part of C99 as default. Cheers, On Tue, Jan 31, 2012 at 4:45 PM, Rasmus Lerdorf ras...@lerdorf.com wrote: On 01/31/2012 02:14 AM, Pierre Joye wrote: - struct pdo_sqlite_collation *collation; - while (H-collations) { + struct pdo_sqlite_collation *collation; collation = H-collations; H-collations = collation-next; Why would this change fix anything? You are just tightening the scope of collation there? This compiled perfectly with gcc before this change. -Rasmus -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php