• Resolved grahambudd

    (@grahambudd)


    Under 4.x there appears to be an error when the plugin tries to save notifications to the database. The “dismissed” value is being set as a blank string rather than an int.

    Here is an example of the database error we’re seeing (this is under 4.0.11):

    WordPress database error Incorrect integer value: ” for column site-2019.fb_aioseo_notifications.dismissed at row 1 for query INSERT INTO fb_aioseo_notifications
    SET slug = ‘5ff3826ec3b3c’, title = ‘Physical Robots.txt File Detected’, content = ‘AIOSEO has detected a physical robots.txt file in the root folder of your WordPress installation. We recommend removing this file as it could cause conflicts with WordPress\’ dynamically generated one. AIOSEO can import this file and delete it, or you can simply delete it.’, type = ‘error’, level = ‘[\”all\”]’, notification_id = NULL, notification_name = ‘robots-physical-file’, start = ‘2021-01-04 21:02:38’, end = NULL, button1_label = ‘Import and Delete’, button1_action = ‘https://action#tools/import-robots-txt?redirect=aioseo-tools’, button2_label = ‘Delete’, button2_action = ‘https://action#tools/delete-robots-txt?redirect=aioseo-tools’, dismissed = ”, created = ‘2021-01-04 21:02:38’, updated = ‘2021-01-04 21:02:38’

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter grahambudd

    (@grahambudd)

    If it is helpful, I tracked down the public static function addNotification function in Notification.php and I see this code around line 170:

    
    // Set the dismissed status to false.
    $fields['dismissed'] = 0;
    

    If I change this to something like: $fields['dismissed'] = 5; then the notifications do get written (albeit with a dismissed status of 1). I highly suspect this is due to PHP shenanigans around bools and truthiness.

    Thread Starter grahambudd

    (@grahambudd)

    I think I’ve found the culprit. In the set function in Model.php, around line 250 there is: $key = $this->transform( $key, true );

    If I log $key immediately before this step, the dismissed value of 0 is present. When I log $key immediately after this line, dismissed is blank.

    Within the transform function in Model.php there is this (around line 200):

    
    foreach ( $this->booleanFields as $field ) {
    	if ( isset( $data[ $field ] ) && '' === $data[ $field ] ) {
    		unset( $data[ $field ] );
    	} elseif ( isset( $data[ $field ] ) ) {
    		$data[ $field ] = (bool) $data[ $field ];
    	}
    }
    

    When dismissed is 0, this results in it being set as false, which is then blank and causes the database error when writing to the database. I’m not sure the best solution, if removing dismissed from the set of booleanFields is better, or if refactoring the database write to handle this is preferable.

    Thread Starter grahambudd

    (@grahambudd)

    This issue also impacts other saves of content. For example trying to save a custom description on a page yields a similar error and no data are saved:

    WordPress database error Incorrect integer value: ” for column site-2019.fb_aioseo_posts.twitter_use_og at row 1 for query UPDATE fb_aioseo_posts
    SET id = ‘1854’, post_id = 1288, title = NULL, description = ‘Testing to see if custom meta descriptions save or not.’, keywords = ‘[]’, keyphrases = ‘{\”focus\”:[],\”additional\”:[]}’, page_analysis = ‘{\”analysis\”:{\”basic\”:{\”lengthContent\”:{\”title\”:\”Content Length\”,\”description\”:\”This is far below the recommended minimum of words.\”,\”score\”:-20,\”maxScore\”:9,\”error\”:1},\”isInternalLink\”:{\”title\”:\”Internal links\”,\”description\”:\”We couldn\’t find any internal links in your content. Add internal links in your content.\”,\”score\”:3,\”maxScore\”:9,\”error\”:1},\”isExternalLink\”:{\”title\”:\”External links\”,\”description\”:\”No outbound links were found. Link out to external resources.\”,\”score\”:3,\”maxScore\”:9,\”error\”:1},\”errors\”:3},\”title\”:{\”titleLength\”:{\”title\”:\”SEO Title length\”,\”description\”:\”The title is too short.\”,\”score\”:6,\”maxScore\”:9,\”error\”:1},\”errors\”:1},\”readability\”:{\”contentHasAssets\”:{\”error\”:1,\”title\”:\”Images\\/Videos in content\”,\”description\”:\”You are not using rich media like images or videos.\”,\”score\”:1,\”maxScore\”:5},\”passiveVoice\”:{\”title\”:\”Passive Voice\”,\”description\”:\”You\’re using enough active voice. That\’s great!\”,\”score\”:9,\”maxScore\”:9,\”error\”:0},\”subheadingsDistribution\”:{\”title\”:\”Subheading distribution\”,\”description\”:\”You are not using any subheadings, but your text is short enough and probably doesn\’t need them.\”,\”score\”:9,\”maxScore\”:9,\”error\”:0},\”errors\”:1}}}’, canonical_url = NULL, og_title = NULL, og_description = NULL, og_object_type = ‘activity’, og_image_type = ‘default’, og_image_custom_url = NULL, og_image_custom_fields = NULL, og_custom_image_width = NULL, og_custom_image_height = NULL, og_video = ”, og_custom_url = NULL, og_article_section = NULL, og_article_tags = ‘[]’, twitter_use_og = ”, twitter_card = ‘summary’, twitter_image_type = ‘default’, twitter_image_custom_url = NULL, twitter_image_custom_fields = NULL, twitter_title = NULL, twitter_description = NULL, seo_score = ’61’, schema_type = ‘none’, schema_type_options = ‘{\”webPage\”:{\”webPageType\”:\”WebPage\”},\”article\”:{\”articleType\”:\”BlogPosting\”},\”book\”:[],\”course\”:[],\”event\”:[],\”jobPosting\”:[],\”music\”:[],\”person\”:[],\”product\”:[],\”recipe\”:[],\”restaurant\”:[],\”service\”:[],\”software\”:[],\”video\”:[]}’, pillar_content = ”, robots_default = ‘1’, robots_noindex = ”, robots_noarchive = ”, robots_nosnippet = ”, robots_nofollow = ”, robots_noimageindex = ”, robots_noodp = ”, robots_notranslate = ”, robots_max_snippet = ‘-1’, robots_max_videopreview = -1, robots_max_imagepreview = ‘large’, tabs = ‘{\”tab\”:\”general\”,\”tab_social\”:\”facebook\”,\”tab_sidebar\”:\”general\”,\”tab_modal\”:\”general\”,\”tab_modal_social\”:\”facebook\”}’, images = NULL, image_scan_date = ‘2021-01-04 22:39:52’, priority = ‘default’, frequency = ‘default’, videos = NULL, video_thumbnail = NULL, video_scan_date = NULL, location = NULL, local_seo = ‘{\”businessInfo\”:{\”name\”:\”\”,\”urls\”:{\”website\”:\”\”,\”aboutPage\”:\”\”,\”contactPage\”:\”\”},\”address\”:{\”line1\”:\”\”,\”line2\”:\”\”,\”zip\”:\”\”,\”city\”:\”\”,\”state\”:\”\”,\”country\”:\”\”},\”contact\”:{\”email\”:\”\”,\”phone\”:\”\”,\”fax\”:\”\”},\”ids\”:{\”vatID\”:\”\”,\”taxID\”:\”\”,\”chamberID\”:\”\”},\”payment\”:{\”priceIndication\”:\”\”,\”currenciesAccepted\”:\”\”,\”methodsAccepted\”:\”\”},\”areaServed\”:\”\”},\”openingHours\”:{\”show\”:false,\”closedLabel\”:\”\”,\”open24h\”:false,\”open24hLabel\”:\”\”,\”open247\”:false,\”use24hFormat\”:false,\”twoSets\”:false,\”timezone\”:\”\”,\”hours\”:[]}}’, updated = ‘2021-01-04 22:40:23’
    WHERE 1 = 1 AND
    id = ‘1854’
    /* 1 = 1 */ made by AIOSEO\Plugin\Common\Utils\Database::run

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Database error with notifications’ is closed to new replies.