We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 727
    • 502 Posts
    Sorry if this is in the wrong place.

    If you mark a document to be published at a certain date and time, then when that date and time arrives you get something like this:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `topdog`.modx_site_content.pub_date < 1156982246 AND `topdog`.modx_site_co' at line 1 »
          SQL: UPDATE `topdog`.modx_site_content SET published=1, publishedon=1156982246, publishedby= WHERE `topdog`.modx_site_content.pub_date < 1156982246 AND `topdog`.modx_site_content.pub_date!=0 
    


    This bug is already in the tracker here: http://modxcms.com/bugs/task/406

    I tried the fix that zenmaster posted and I can confirm that it doesn’t work. Therefore I think the problem zenmaster was fixing is unrelated. I guess that is the only fix that was commited to the repository.

    OK, so I wanted to try the fix that jdavies posted in that bug report. However I cannot find the function "checkPublishStatus" and the typo "publihsedBy". So here are my questions:

    1. Can someone please point me to the location where I can try the changes mentioned by jdavies?

    2. Can we can ensure this problem doesn’t fall through the cracks because the bug tracker at first glance appears to show a fix as being commited?

    I tried to log in to the bug tracker but I guess it uses seperate accounts to the forum. sad

    I’m using 0.9.2.1.

    Thanks!!

    Andy

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The problem with the query is that the publishedby value is not getting set. Check line 475 (or thereabouts);
      ...publishedby=".$this->getLoginUserID()."...


      The getLoginUserID() function:
        function getLoginUserID(){
          if($this->isFrontend() && isset($_SESSION['webValidated'])) {
            return $_SESSION['webInternalKey'];
          }
          else if($this->isBackend() && isset($_SESSION['mgrValidated'])) {
            return $_SESSION['mgrInternalKey'];
          }
        }

      Now this means that this value will only be set if a web user is logged on. Which will (besides having no value if the page viewer is not logged in as a web user) actually serve no purpose at all, since a web user’s ID will be meaningless in the context of who published a document. My take on this would be that the document’s creator (createdby) should be used here. A different manager user ID would be appropriate if someone else manually publishes the document, but for the autopublish function the only appropriate "publisher" id would be the creator’s.
      ...publishedby=".$this->documentObject['createdby']."...

      (the spelling error occurs in line 481, the "unpublish" query)

        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Hm. That won’t work, because the document object is not set yet in the parser. I guess it would take a query to get the createdby value for this document.

        Maybe it would be better for the publishedby to be set to the creator when the document is saved, even if it’s not published. Then if the document is manually published, that gets updated anyway.

        In any case, simply removing that assignment from the query won’t hurt, it will just leave the publishedby at 0.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 727
          • 502 Posts
          Thanks, but which file do I need to edit? grin

          Andy
            • 727
            • 502 Posts
            Ok, I found it - manager/includes/document.parser.class.inc.php

            Andy