admin管理员组

文章数量:1122832

I have this little php I call from jqGrid url that I use inside an admin's wordpress plugin:

require_once($_SERVER['DOCUMENT_ROOT'] . '/xDl21my20/wp-load.php');
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
add_action( 'shutdown', function() {
   while ( @ob_end_flush() );
} );

global $wpdb;

ob_start();
$sql_select = "SELECT * FRON TABLE ORDER BY ID ASC";

$results = $wpdb->get_results($sql_select, OBJECT);

return json_encode($results);
ob_get_clean();

but I see I don't receive any results and looking in the log I see this error:

[02-Jan-2022 09:05:32 UTC] PHP Notice:  ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/..../wp-includes/functions.php on line 5107

So since I added that remove_action as I read in other issues, it should have bypassed the ob_end_flush issue but it didn't... Maybe I forgot something or could be that related to PHP version installed PHP Version 7.4.27?... Any direction would be appreciated... cheers!!!

btw, zlib_compression is on in php.ini

I have this little php I call from jqGrid url that I use inside an admin's wordpress plugin:

require_once($_SERVER['DOCUMENT_ROOT'] . '/xDl21my20/wp-load.php');
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
add_action( 'shutdown', function() {
   while ( @ob_end_flush() );
} );

global $wpdb;

ob_start();
$sql_select = "SELECT * FRON TABLE ORDER BY ID ASC";

$results = $wpdb->get_results($sql_select, OBJECT);

return json_encode($results);
ob_get_clean();

but I see I don't receive any results and looking in the log I see this error:

[02-Jan-2022 09:05:32 UTC] PHP Notice:  ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/..../wp-includes/functions.php on line 5107

So since I added that remove_action as I read in other issues, it should have bypassed the ob_end_flush issue but it didn't... Maybe I forgot something or could be that related to PHP version installed PHP Version 7.4.27?... Any direction would be appreciated... cheers!!!

btw, zlib_compression is on in php.ini

Share Improve this question edited Jan 2, 2022 at 10:53 Luigino asked Jan 2, 2022 at 10:33 LuiginoLuigino 1035 bronze badges 2
  • So the original code was without the action? if thats the case you have a ob_get_clean() after a return, return, well, returns the value (in this case a json string) and stops there, no other code after return is being executed. But in genereal this code is strange, why there is a return? how do you access this code? why is there even ob_start() or any ob_ for that matter? – Buttered_Toast Commented Jan 2, 2022 at 12:19
  • Hi Buttered_Toast. - that "SELECT" is just a sample select from a certain table that returns some rows... - before to add ob_start() and ob_get_clean() it was without ob_start() neither ob_get_clean() but I got still the error.... - I added ob_start() and ob_get_clean() because I thought that error could be cause by $wpdb->get_results() which runs thanks to wp-load.php inclusion without success anyway... – Luigino Commented Jan 2, 2022 at 14:45
Add a comment  | 

1 Answer 1

Reset to default 0

Found the solution at the problem: using "return" wasn't the right way... have to use "echo" in this way because it isn't a function but a simple PHP that gives back an object. Thanks again to all

本文标签: pluginsobendflush() failed to send buffer of zlib output compression (0) in external php