• Resolved andy1pitt

    (@andy1pitt)


    I had to migrate my site to a new service. After I did that, my site was functional, but I couldn’t add pages or posts without getting a critical error message. I tried disabling all plugins and went back to the stock WP Theme and got the same result. Enabling the WP debug function, I found the following critical error message:

    “Warning
    : Attempt to read property “post_type” on null in
    /var/www/wp-admin/includes/post.php
    on line
    723
    Fatal error
    : Uncaught Error: Attempt to assign property “post_content” on null in /var/www/wp-admin/includes/post.php:762 Stack trace: #0 /var/www/wp-admin/post-new.php(66):get_default_post_to_edit(‘page’, true) #1 {main} thrown in /var/www/wp-admin/includes/post.php on line 762

    Would appreciate any help to resolve this. Thanks In Advance

    • This topic was modified 2 years, 9 months ago by andy1pitt.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    Since the problem can be caused by any number of things, check the error log on your server. If you can’t find the log, please contact your host. Meantime, enable wp_debug and wp_debug_log and after an error, look at wp-content/debug.log to see if anything gets logged there. https://ww.wp.xz.cn/support/article/debugging-in-wordpress/

    You may also try:
    manually resetting your plugins (no Dashboard access required). If that resolves the issue, reactivate each one individually until you find the cause.
    – If that does not resolve the issue, access your server via SFTP or FTP, or a file manager in your hosting account’s control panel, navigate to /wp-content/themes/ and rename the directory of your currently active theme. This will force the default theme to activate and hopefully rule-out a theme-specific issue (theme functions can interfere like plugins).`

    Also review:
    https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-critical-error-in-wordpress/ https://kinsta.com/knowledgebase/there-has-been-a-critical-error-on-your-website/

    Thread Starter andy1pitt

    (@andy1pitt)

    I did enable debug log. This seems to be the fatal error. Not sure how to interpret this.

    [04-Sep-2023 11:44:22 UTC] WordPress database error Duplicate entry ‘0’ for key ‘PRIMARY’ for query INSERT INTO wp_0d4by0kan6_posts (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) VALUES (1, ‘2023-09-04 11:44:22’, ‘0000-00-00 00:00:00’, ”, ”, ‘Auto Draft’, ”, ‘auto-draft’, ‘post’, ‘open’, ‘open’, ”, ”, ”, ”, ‘2023-09-04 11:44:22’, ‘0000-00-00 00:00:00’, 0, 0, ”, ”) made by wp_dashboard, do_meta_boxes, wp_dashboard_quick_press, get_default_post_to_edit, wp_insert_post
    [04-Sep-2023 11:44:23 UTC] PHP Fatal error: Uncaught RuntimeException: Unable to release actions from claim id 0. in /var/www/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:1030

    Thread Starter andy1pitt

    (@andy1pitt)

    I deactivated all my plugins and got the following critical error from the debug log:

    [04-Sep-2023 12:41:24 UTC] WordPress database error Duplicate entry ‘0’ for key ‘PRIMARY’ for query INSERT INTO wp_0d4by0kan6_posts (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) VALUES (1, ‘2023-09-04 12:41:24’, ‘0000-00-00 00:00:00’, ”, ”, ‘Auto Draft’, ”, ‘auto-draft’, ‘post’, ‘open’, ‘open’, ”, ”, ”, ”, ‘2023-09-04 12:41:24’, ‘0000-00-00 00:00:00’, 0, 0, ”, ”) made by wp_dashboard, do_meta_boxes, wp_dashboard_quick_press, get_default_post_to_edit, wp_insert_post
    [04-Sep-2023 12:41:46 UTC] WordPress database error Duplicate entry ‘0’ for key ‘PRIMARY’ for query INSERT INTO wp_0d4by0kan6_posts (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) VALUES (1, ‘2023-09-04 12:41:46’, ‘0000-00-00 00:00:00’, ”, ”, ‘Auto Draft’, ”, ‘auto-draft’, ‘page’, ‘closed’, ‘closed’, ”, ”, ”, ”, ‘2023-09-04 12:41:46’, ‘0000-00-00 00:00:00’, 0, 0, ”, ”) made by get_default_post_to_edit, wp_insert_post
    [04-Sep-2023 12:41:46 UTC] PHP Warning: Attempt to read property “post_type” on null in /var/www/wp-admin/includes/post.php on line 748
    [04-Sep-2023 12:41:46 UTC] PHP Fatal error: Uncaught Error: Attempt to assign property “post_content” on null in /var/www/wp-admin/includes/post.php:787
    Stack trace: 0 /var/www/wp-admin/post-new.php(66): get_default_post_to_edit(‘page’, true) 1 {main}

    thrown in /var/www/wp-admin/includes/post.php on line 787

    Moderator bcworkz

    (@bcworkz)

    Did you also switch to a default Twenty* theme when you tried deactivating all plugins? Themes can also be a cause of critical errors. Default themes have been thoroughly tested to be fully compatible with core WP.

    WordPress database error Duplicate entry ‘0’ for key ‘PRIMARY’

    Something could be wrong with your DB configuration. The primary key column is supposed to auto-increment, so should never have a ‘0’ value.

    Open the phpMyAdmin app, usually accessed through your hosting account. Navigate in the left sidebar to your WP DB. Expand the table listings with the + icon. Click on the wp_0d4by0kan6_posts table. Click the “ID” at the table column head. The column ordering should be lowest to highest. There mustn’t be any records with ‘0’ ID values. Click on the little triangle icon that appeared. This reverses to column ordering. Note the highest ID so far assigned.

    If there were any 0 ID values, assign incrementally higher values for any such records. You should always make a backup copy of any table before making any sort of data change through phpMyAdmin.

    Go to the Operations tab. In Table Options, set the AUTO_INCREMENT value to be one more than the highest assigned value. Click the related Go button.

    Next go to the Structure tab. The ID entry should have both a gold and grey keys assigned. If not, The gold PRIMARY key can be assigned or changed through the Indexes box below the table structure listing. The grey key is for indexing. There are normally several columns assigned for indexing. Which they are would not cause a critical error, but could affect performance.

    In the table structure list, the ID entry should be set to AUTO_INCREMENT in the Extra column. If not, click “change” for ID and check mark the A.I. box, then save.

    With your DB properly configured and using no plugins and a default theme, the errors you’ve been getting should no longer occur.

    • This reply was modified 2 years, 9 months ago by bcworkz.
    Thread Starter andy1pitt

    (@andy1pitt)

    Thank you so very much. I did as you suggested, and it resolved the problem.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Critical Error Message when adding Posts or Pages’ is closed to new replies.