Commit 61c1e2a8 authored by flocondetoile's avatar flocondetoile Committed by gbyte.co

Issue #2655432 by flocondetoile: SQLSTATE[42000]: Syntax error or access...

Issue #2655432 by flocondetoile: SQLSTATE[42000]: Syntax error or access violation after upgrading to 8.x-1.7
parent 3f2f5845
......@@ -24,7 +24,7 @@ function simplesitemap_schema() {
'size' => 'big',
'not null' => TRUE,
),
'generated' => array(
'sitemap_created' => array(
'description' => 'Timestamp of sitemap chunk generation.',
'type' => 'int',
'default' => 0,
......@@ -111,3 +111,16 @@ function simplesitemap_update_8105() {
'not null' => TRUE,
));
}
/**
* Changing column name to 'sitemap_created', as 'generated' is a reserved word since MySQL 5.7.6.
*/
function simplesitemap_update_8106() {
db_change_field('simplesitemap', 'generated', 'sitemap_created', array(
'description' => 'Timestamp of sitemap chunk generation.',
'type' => 'int',
'default' => 0,
'not null' => TRUE,
));
}
......@@ -160,12 +160,12 @@ class Simplesitemap {
$values[] = array(
'id' => $chunk_id,
'sitemap_string' => $chunk_data->sitemap_string,
'generated' => $chunk_data->generated,
'sitemap_created' => $chunk_data->sitemap_created,
);
}
$query = db_insert('simplesitemap')
->fields(array('id', 'sitemap_string', 'generated'));
->fields(array('id', 'sitemap_string', 'sitemap_created'));
foreach ($values as $record) {
$query->values($record);
}
......
......@@ -77,14 +77,14 @@ class SitemapGenerator {
foreach(array_chunk($this->links, $max_links) as $sitemap_id => $sitemap_links) {
$sitemaps[] = (object)[
'sitemap_string' => $this->generate_sitemap_chunk($sitemap_links),
'generated' => $timestamp,
'sitemap_created' => $timestamp,
];
}
}
else {
$sitemaps[] = (object)[
'sitemap_string' => $this->generate_sitemap_chunk($this->links),
'generated' => $timestamp,
'sitemap_created' => $timestamp,
];
}
return $sitemaps;
......@@ -110,7 +110,7 @@ class SitemapGenerator {
$writer->startElement('sitemap');
$writer->writeElement('loc', $GLOBALS['base_url'] . '/sitemaps/'
. $chunk_id . '/' . 'sitemap.xml');
$writer->writeElement('lastmod', date_iso8601($chunk_data->generated));
$writer->writeElement('lastmod', date_iso8601($chunk_data->sitemap_created));
$writer->endElement();
}
$writer->endElement();
......
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