Commit f53fb140 authored by jcisio's avatar jcisio Committed by amateescu
Browse files

Issue #2735127 by amateescu, jcisio: New custom link replacing old one

parent 14dbecfe
......@@ -89,9 +89,28 @@ class XmlSitemapCustomAddForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Take into account that databases use wildly different names for their
// data types.
$db_type = $this->connection->databaseType();
switch ($db_type) {
case 'mysql':
$type = 'UNSIGNED';
break;
case 'pgsql':
$type = 'BIGINT';
break;
case 'sqlite':
$type = 'INTEGER';
break;
default:
$type = 'INT';
break;
}
$query = $this->connection->select('xmlsitemap', 'x');
$query->addExpression('MAX(id)');
$id = $query->execute()->fetchField();
$query->addExpression("MAX(CAST(id AS $type))");
$query->condition('type', 'custom');
$id = (int) $query->execute()->fetchField();
$link = array(
'id' => $id + 1,
'loc' => '',
......
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