Commit 78b7842a by pupi1985

Fix database overflow issue when trying to insert content words

parent 7ed3f6a0
......@@ -48,6 +48,7 @@ $maximaDefaults = array(
'QA_DB_MAX_BLOB_FILE_NAME_LENGTH' => 255,
'QA_DB_MAX_META_TITLE_LENGTH' => 40,
'QA_DB_MAX_META_CONTENT_LENGTH' => 8000,
'QA_DB_MAX_WORD_COUNT' => 255, // The field is currently a TINYINT so it shouldn't exceed this value
// How many records to retrieve for different circumstances. In many cases we retrieve more records than we
// end up needing to display once we know the value of an option. Wasteful, but allows one query per page.
......
......@@ -166,8 +166,12 @@ function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $
{
if (count($wordidcounts)) {
$rowstoadd = array();
foreach ($wordidcounts as $wordid => $count)
foreach ($wordidcounts as $wordid => $count) {
if ($count > QA_DB_MAX_WORD_COUNT) {
$count = QA_DB_MAX_WORD_COUNT;
}
$rowstoadd[] = array($postid, $wordid, $count, $type, $questionid);
}
qa_db_query_sub(
'INSERT INTO ^contentwords (postid, wordid, count, type, questionid) VALUES #',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment