• Resolved [email protected]

    (@pauleffigycomau)


    Hi – Thought this might help someone. I had a problem recently with get a “Document not found” error when updating a previously working document.

    Looking at the entry in the database I noticed that the post_content for the new upload was being saved as <!-- WPDR $post_id --> where post_id was just the id of the document, I assume for Gutenberg compatibility.

    I was able to ‘fix’ the issue by modifying the ‘extract_document_id’ function found at line 2637 of class_wp_document_revisions.php by modifying the grep in the preg_match to include the spaces.

    Example:
    Before – preg_match( '/<!-- WPDR ([(0-9]+) -->/', $post_content, $id );
    After – preg_match( '/<!-- WPDR\s([(0-9]+)\s-->/', $post_content, $id );

    Maybe the plugin could be updated to include this change.

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor nwjames

    (@nwjames)

    @pauleffigycomau,
    Thank you very much for raising this issue.

    The change in format is due to implementing the Short Description now available that can be displayed in the blocks/shortcodes provided in the plug-ins. The format is meant to be compatible with Gutenburg – but is not currently usable with it. It makes use of the “Classic editor”.

    However you have identified a problematic statement.

    Could I ask you to do an experiment for me please?

    Could you revert that statement and confirm that you have the Not Found problem.

    Then can you change the statement to be:
    preg_match( '/<!-- WPDR ([0-9]+) -->/', $post_content, $id );

    and let me know if this now works please.

    Thanks in advance,
    Neil James

    Thread Starter [email protected]

    (@pauleffigycomau)

    I can confirm your change works – though I found the fix was not to include the \s in the preg_match but that the original string ([(0-9]+)has an ( just before the 0.

    Removing the opening bracket resolves the issue.

    Cheers
    Paul

    Plugin Contributor nwjames

    (@nwjames)

    @pauleffigycomau,
    Thank you very much for doing the test for me.

    Clearly my orginal code was incorrect, but my tests did not show the bug.

    I will be proposing this fix to go into a version 3.4.1 in the newxt few days since others may be suffering from the same issue.

    Regards,
    Neil James

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Document could not be found fixed’ is closed to new replies.