SocialEngine 4: MySQLi Extension Gives Apache 500 Error

There has been a bug discovered in the MySQLi extension for PHP that causes a Segmentation fault error on some installations of PHP when the mysqli_result::fetch_fields function is used.
Error occurred on a Linux server using the following software:

1 PHP Version: PHP 5.3.6
2 Operating System: CentOS release 5.6 (Final)
3 Mysql Version : 5.0.92-community

The error manifests in a few ways:

  • 1 At step 3 of the installation process, the process terminates and users are forwarded to step 1.
  • 2 At step 2 of the upgrade process, a 500 error is thrown by Apache. In the error logs you may see errors like:
    Premature end of script headers: index.php, referer:

    On some servers, the 500 error is masked by a “Page Not Found” message from SocialEngine.

    • 3 The Other Tools > Requirement and Dependency Check page of the package manager will produce similar results as #2.


If you are experiencing this error while performing an upgrade, download the attached to this article and extract its contents.

Next, using an FTP client, upload the application folder into your SocialEngine root directory, so that the application/libraries/Engine/Sanity/Test/MysqlEngine.php file is overwritten.

To apply the patch manually, make the following changes:

Edit the file application/libraries/Engine/Sanity/Test/MysqlEngine.php and around line 82, locate the lines of code that look like this:

// Try to list engines try { $data = $adapter->query('SHOW ENGINES')->fetchAll(); } catch( Exception $e ) { return $this->_error('badAdapter'); } [/code] Replace this block of code with:


// Try to list engines if( $adapter instanceof Zend_Db_Adapter_Mysqli ){ 
// Fixes MySQLI segfault in fetch_fields() with SHOW ENGINES $connection = $adapter->getConnection(); 
$result = mysqli_query($connection, 'SHOW ENGINES'); 
if ( !$result instanceof mysqli_result ){ return $this->_error('badAdapter'); } 
$data = array(); while ( $row = $result->fetch_array() ){ $data[] = $row; } } else { try { $data = $adapter->query('SHOW ENGINES')->fetchAll(); } catch( Exception $e ) { return $this->_error('badAdapter'); } }


Looking for quality Social Engine Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , , , , , , | Posted under SocialEngine | RSS 2.0

Author Spotlight

Andrew Cross

Hi, I'm Andrew. A am a 26, ICT Administrator which offers support to company's around the South Wales Area. I have created a few social sites for myself and other company's. So far 2 out of 3 have been successful using the powerful SocialEngine Script. I continue to try and help the community of SocialEngine by giving Support and Technical Help where possible.

Leave a Reply

Your email address will not be published. Required fields are marked *