Support Center

Bug in MySQLi extension causes Apache 500 error

We recently discovered a bug 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:
 

PHP Version: PHP 5.3.6
Operating System: CentOS release 5.6 (Final)
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: http://domain.com/install/manage/select) 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.

 

Fix:

If you are experiencing this error while performing an upgrade, download the engine4_r9166.zip attached to this article and extract it's 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'); 
}

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'); 
  } 
} 
Attachments
support@socialengine.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete?b_id=14386