问题
I am running a website using Joomla! 2.5.9 for 7 months. Everything was going fine until this week. On monday and today(Friday) web site fails to run because of ****_session
table has been broken down. I don't have a chance to take a look at logs about what is wrong.
Anyway, I repaired the table on Monday and everything was normal until today. Today it repeated the same error. Then I repaired again. I don't want the table to be broken and don't want to repair it again.
I want to know if there is a vulnerability about Joomla! or there is something else on server side.
回答1:
For some reason, I get this error sometimes, so I have automated a fix with a cron job:
<?php
$sites = array('http://www.yoursite.com', 'http://www.yourothersite.com');
foreach($sites as $site) {
$content = file_get_contents($site);
if (strpos($content, 'error') !== false) {
mail('myself@myself.com', 'Error found: '.$site,
$site.' reported an error:<br/><br/>'.$content,
'From: Myself <myself@myself.com>');
}
if (strpos($content, 'jtablesession::Store Failed') !== false) {
// run repair table
$con = mysql_connect('localhost', 'user', 'pass');
mysql_select_db('yoursite_db_name', $con);
// you might want to add an if here, if you have many sites to check
mysql_query('REPAIR TABLE `yourprefix_session`', $con);
mysql_close($con);
mail('myself@myself.com', 'Repaired #__session', 'From: Myself <myself@myself.com>');
}
}
?>
Keep in mind that I use this only for Joomla 1.5 sites. You may want to change the errors searched if they are different for 2.5 or 3.0.
回答2:
I have made a page which repairs the table manually when crashed.
<?php
//file = repair/index.php
include '../configuration.php'; //has JConfig class
$cfg = new JConfig();
$mysqli = new mysqli($cfg->host, $cfg->user, $cfg->password, $cfg->db);
if($mysqli->query('REPAIR TABLE prefix_session'))
echo 'Hey!';
else
echo 'An error occured call zkanoca';
?>
when I call http://example.com/repair it is OK.
回答3:
I also lost a site to a corrupt "session" table in MySQL. The solutions I found were all WAY too complicated for what is a very simple and predictable problem, as documented here:
https://www.akeebabackup.com/documentation/admin-tools/database-tools.html
Simply, the session table needs periodic cleaning. Once it crashes, it can no longer be accessed using PHPmyAdmin (since the table is crashed, it cannot be accessed). Since the table is corrupt, and since the site cannot be accessed, you cannot access the Admin Tools either.
So, through the cpanel, using PHPmyAdmin, in the database section, in the SQL tab for the site's DB, I typed:
REPAIR TABLE [prefix]_session
and then clicked Go
Problem solved. Site reappeared.
来源:https://stackoverflow.com/questions/18909940/why-does-joomla-2-5-session-table-corrupt