Sudden problem writing a new kb article

Please report bugs here!

Moderator: Thorsten

Post Reply
MRi
Posts: 61
Joined: Mon Sep 22, 2014 12:52 pm

Sudden problem writing a new kb article

Post by MRi »

We changed nothing. The KB ist running unchanged on version 3.0.12 since 1 year.

We can't create new articles.
After enabling debug mode I see that inserting a record into the DB failed.

Code: Select all

phpMyFAQ\Faq->addRecord() in line 140: INSERT INTO kb_faqdata VALUES (479, 'de', 1481, 0, 'no', 0, '', 'Test ', '\n\n\n\n\n
Test\n\n', 'Hugo', 'support@Hugo.de', 'n', '20230425125101', '', 0, '00000000000000', '99991231235959', '2023-04-25 12:51:01', '')
1292: Incorrect datetime value: '' for column `xyz`.`kb_faqdata`.`created` at row 1/home/www/site/src/phpMyFAQ/Changelog.php:
When I test the code in my phpMyAdmin I get the same error.
The last parameter / column is empty and the MySQL DB doesn't like that.

We never had such problems. Is there a major setting of MySQL that may have changed, by another admin?

EDIT: I just verified that NO_ZERO_DATE isn't set in SQL_MODE
EDIT 2: The last column is the changed column. I added a fixed value for the changed column but no vail.

Code: Select all

     $recordData = [
            'lang' => $recordLang,
...
	    // MRi: added created
	    // Fixed data
	    'created' => '2023-01-01 01:01:01'
        ];
MRi
Posts: 61
Joined: Mon Sep 22, 2014 12:52 pm

Re: Sudden problem writing a new kb article

Post by MRi »

Strange the last 2 columns didn't match in the insert
I just changed the statement

Code: Select all

 public function addRecord(array $data, $newRecord = true)
    {
        if ($newRecord) {
            $recordId = $this->config->getDb()->nextId(Database::getTablePrefix() . 'faqdata', 'id');
        } else {
            $recordId = $data['id'];
        }

        // Add new entry
        $query = sprintf(
            "INSERT INTO %sfaqdata VALUES
            (%d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s')",
            Database::getTablePrefix(),
            $recordId,
            $data['lang'],
            $this->getSolutionId(),
            0,
            $data['active'],
            $data['sticky'],
            $this->config->getDb()->escape($data['keywords']),
            $this->config->getDb()->escape($data['thema']),
            $this->config->getDb()->escape($data['content']),
            $this->config->getDb()->escape($data['author']),
            $data['email'],
            $data['comment'],
            $data['date'],
            $data['linkState'],
            $data['linkDateCheck'],
            $data['dateStart'],
            $data['dateEnd'],
	    // MRi: switched this two lines because the DB shows this sequence and we get an SQL error
            $data['notes'],
	    	date('Y-m-d H:i:s')
        );
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Sudden problem writing a new kb article

Post by Thorsten »

Hi,

the last column is the notes one, not the created one. Is that different on your installation?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
MRi
Posts: 61
Joined: Mon Sep 22, 2014 12:52 pm

Re: Sudden problem writing a new kb article

Post by MRi »

Seams so. But I can't see a reason.
When I look into the PHPMyAdmin notes is the column before created. I see this in the column list on the right side in PhpMyAdmin where the list of fields show up.

How can this happen? Really nothing was done since a year...

OK Reason found. I will change the sequence in my installati0on. Sometimes such statement are clearer when the column names are defined in the INSERT to. I never relay on the sequence of the columns in the DB.

Thanks
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Sudden problem writing a new kb article

Post by Thorsten »

Hi,

okay, but good hint, I'll improve the INSERT query to avoid this.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
planagainst
Posts: 1
Joined: Wed Dec 20, 2023 8:50 am
Contact:

Re: Sudden problem writing a new kb article

Post by planagainst »

Thorsten wrote: Sat Apr 29, 2023 5:45 pm Hi,

okay, but good hint, I'll improve the INSERT query to avoid this.

bye
Thorsten
Is there any new update for this issue?
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Sudden problem writing a new kb article

Post by Thorsten »

Hi,

as far as I remember I fixed it a couple of months ago in 3.1 and 3.2

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply