We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20113
    • 5 Posts
    Greetings,

    We currently have two modx installations where one is our staging site and the other the production site. Content is edited on our staging site and once approved we overwrite the production file system + database with that of the staging site. Everything is working nicely except where we create content that is to be published at a later date using the ’Document Settings -> Page Settings -> Publish date’ attribute. Once the published date arrives, content is published on the staging site as expected. The production site on the other hand seems to ignore the date, and the content remains unpublished (ie published=0).

    The only work around at the moment is after the published date has passed we re-save the content which forces the following code in ’save_content.processor.php’ to update the database:

            if ($pub_date < $currentdate) {
                    $published = 1;
            }
            elseif ($pub_date > $currentdate) {
                    $published = 0;
            }


    I have setup a test environment on a different box hosting copies of our staging and productions sites. The problem persists, and I am unsure how to procede.

    Any help is appreciated,

    -momelod
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      I would double-check your configuration settings for your install. Since you’re on two different servers, can you check the date on each (e.g. "date" on the linux command line, "SELECT NOW()" within SQL). Maybe there’s a discrepancy, e.g. timezone. Just a thought...
        • 20113
        • 5 Posts
        Both production and staging are hosting on the same physical box.
          • 7231
          • 4,205 Posts
          I am guessing it is an issue with the modx cache file on the production server. Since you say it works once re-saved, and the saving process forces the cache for that document to refresh I am guessing that would be the case. The solution would be to clear the modx cache as part of the migration process. I am not sure how to do this, I read about a few methods but not sure what the correct way to do it would be.

          I am guessing here since this is out of my league wink
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 3749
            • 24,544 Posts
            The cache is cleared on install. I always to an upgrade install when moving stuff from the staging to the production server.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 20113
              • 5 Posts
              It’s not a cache problem, the last set of our promotion is to delete the cache ie. `rm assets/cache/doc*`.

                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Can you outline for us the exact steps you take when moving code from staging to production? You have 2 separate directories, one for prod, one for staging... each directory has it’s own files (and caches)... is each install running in its own database? How do you go about copying the database? Are you using sqldump? Can you verify that the values in the documents’ publish date fields are the same after you copy from staging to prod?

                It’s always a bit tricky integrating a CMS into a dev/qa/staging/prod type of flow.
                  • 7231
                  • 4,205 Posts
                  What about the siteCache.idx.php cache file? I think it keeps a site map of all documents so if the new document was created it will not know about it unless it is refreshed.

                  I tested it by removing a document reference and sure enough the published document disappeared from the front-end of the site.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 20113
                    • 5 Posts
                    Here is our promotion script which outlines the exact steps taken. I thought i would share it since someone else may also find it useful. You mentioned that the sitePublishing.idx.php and siteCache.idx.php should also be copied from staging? Our script does copy those files over, but Im unclear as how to refresh them.


                    #! /bin/bash
                    
                    #
                    # stg2prod.sh - promotion script from staging environment to production.
                    #
                    
                    #
                    # Set script wide variables
                    #
                    
                    DATE=`date +%F-%T`
                    BACKUPDIR="/var/lib/backups/SITENAME/stg2prod"
                    DB_USER="modx"
                    DB_PASSWD="xxxxxxxxxx"
                    DB_HOST="localhost"
                    DB_SOURCE="modx_stg"
                    DB_DESTINATION="modx_prod"
                    HTDOCS_SOURCE="/var/vhosts/SITENAME-STG"
                    HTDOCS_DESTINATION="/var/vhosts/SITENAME-PROD"
                    
                    #
                    # Display confirmation prompt
                    #
                    
                    echo -e "\n\nPROMOTING STG to PROD $DATE\n"
                    echo -n "Would you like to continue? (y/n): "
                    
                    #
                    # Read and process confirmation
                    #
                    
                    read CONFIRMATION
                    echo
                    
                    case "$CONFIRMATION"
                    in
                            y) echo "Proceeding";;
                            n) echo "Aborting"
                               exit 0;;
                            *) echo "Invalid response, Aborting"
                               exit 1;;
                    esac
                    
                    #
                    # Perform a database backup, and create an archive of the document root.
                    #
                    
                    echo "Backing up to $BACKUPDIR .."
                    
                    if mysqldump -u $DB_USER -p$DB_PASSWD $DB_SOURCE > $BACKUPDIR/$DATE-$DB_SOURCE.sql && \
                    mysqldump -u $DB_USER -p$DB_PASSWD $DB_DESTINATION > $BACKUPDIR/$DATE-$DB_DESTINATION.sql && \
                    tar czf $BACKUPDIR/$DATE-httpdocs-$DB_SOURCE.tar.gz $HTDOCS_SOURCE && \
                    tar czf $BACKUPDIR/$DATE-httpdocs-$DB_DESTINATION.tar.gz $HTDOCS_DESTINATION
                    then
                            echo " Backups completed."
                    else
                            echo " Backups FAILED, aborting."
                            exit 255
                    fi
                    
                    echo -n "Backup up selected tables from $DB_SOURCE .."
                    if mysqldump -u $DB_USER -p$DB_PASSWD $DB_SOURCE \
                            modx_active_users \
                            modx_categories \
                            modx_documentgroup_names \
                            modx_event_log \
                            modx_manager_users \
                            modx_maxigallery \
                            modx_member_groups \
                            modx_membergroup_access \
                            modx_membergroup_names \
                            modx_site_htmlsnippets \
                            modx_site_keywords \
                            modx_site_metatags \
                            modx_site_module_access \
                            modx_site_module_depobj \
                            modx_site_modules \
                            modx_site_plugin_events \
                            modx_site_plugins \
                            modx_site_snippets \
                            modx_site_templates \
                            modx_site_tmplvar_access \
                            modx_site_tmplvar_templates \
                            modx_site_tmplvars \
                            modx_site_content \
                            modx_site_tmplvar_contentvalues \
                            modx_document_groups \
                            modx_keyword_xref \
                            modx_site_content_metatags \
                            modx_system_eventnames \
                            modx_system_settings \
                            modx_user_attributes \
                            modx_user_messages \
                            modx_user_roles \
                            modx_user_settings \
                            modx_web_groups \
                            modx_web_user_attributes \
                            modx_web_user_settings \
                            modx_web_users \
                            modx_webgroup_access \
                            modx_webgroup_names \
                            modx_manager_log > /tmp/$DB_SOURCE.sql
                    then
                            echo " Done."
                    else
                            echo " Failed, aborting."
                            exit 1
                    fi
                    
                    echo -n "Updating $DB_SOURCE htdocs with new contetnt from $DB_DESTINATION htdocs .."
                    if /bin/cp -a $HTDOCS_SOURCE/* $HTDOCS_DESTINATION
                    then
                            echo " Done."
                            /bin/cp -a $HTDOCS_SOURCE/manager/includes/config.inc.php-prod $HTDOCS_SOURCE/manager/includes/config.inc.php
                    else
                            echo " Failed, aborting."
                            exit 2
                    fi
                    
                    echo -n "Updating $DB_DESTINATION database with new records from $DB_SOURCE database .."
                    if mysql -u $DB_USER -p$DB_PASSWD $DB_DESTINATION < /tmp/$DB_SOURCE.sql
                    then
                            echo " Done."
                    else
                            echo " Failed, aborting."
                            exit 3
                    fi
                    
                    echo -n "Removing stale cache .."
                    rm $HTDOCS_DESTINATION/docid*
                    
                    echo " Done."
                    
                    echo "Promotion complete!"
                    
                      • 7231
                      • 4,205 Posts
                      Take a look at manager/actions/refresh_site.dynamic.php and manager/processors/cache_sync.class.processor.php These are the functions (that I know of) that will resync the cache.

                      Again, I am just shooting in the dark here and could be sending you in the wrong direction. To see if it is the cache, clear the cache immediately (before any document editing) after going from staging->live and see if a document that should be published but was not showing suddenly appears. If it does, then it is the cache.
                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don&#39;t know what it is.
                        Do you, Mr. Jones? - [bob dylan]