We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22815
    • 1,097 Posts
    Anton, thank you for sharing your experiences, and solutions. I can’t see any particular reason why your fix should screw anything up, although you would be advised to test fully - particularly to see whether any non-public pages are visible to the public, given that there’s some potential impact on doc groups.

    For the record, 4.1.21-standard is at present the latest released version of MySQL 4. This fault is apparently not present in the latest released version of MySQL 5.

    MySQL have released a bugfix patch, although I wouldn’t imagine many people here are keen to (or able to) recompile MySQL and reinstall it on their servers. Indeed, most hosts don’t fancy doing that either. Anyone in Anton’s camp is currently dependent on MySQL releasing a new version, cPanel/similar bundling it in their next package, and then your host installing the new cPanel/similar package. I have no idea how long a period that will take.

    I would appreciate it if anyone in the same situation could try Anton’s fixes and confirm whether they resolve the issue.
      No, I don't know what OpenGeek's saying half the time either.
      MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
      Forum: Where to post threads about add-ons | Forum Rules
      Like MODx? donate (and/or share your resources)
      Like me? See my Amazon wishlist
      MODx "Most Promising CMS" - so appropriate!
      • 1828
      • 137 Posts
      Thanks Paul. I’m sure I can’t be the only one affected by this bug. Will do some more testing and hope for the best.

      Anton
        • 1828
        • 137 Posts
        A quick update on this:

        I also had to apply the same patch the document.parser.class.inc.php file in the following functions:

        getAllChildren()
        getActiveChildren()
        getDocumentChildren()
        getDocuments()

        I have a few sites running with this and all are sorting trees and menus correctly, with no obvious side-effects, ATM.

        Anton
          • 17883
          • 1,039 Posts
          Man, you´re my hero cool Searching since last thursday because of this weird behaviour (my provider thought I am crazy) -> I changed the files above and now it´s working.

          Attention: This also affects ditto, in classes/functions.class.inc.php line around 250.

          Just to be sure this ist found via the forum search (I searched a lot): Keywords: sorting problem,Wrong sorting ditto, Wayfinder, MySQL 4.1.21

          My provider also updated to PHP 4.4.4., first I thought that could be the reason.

            • 1828
            • 137 Posts
            HTH! smiley

            BTW, do we need to log this issue somewhere else to ensure this is attended to in the next release?

            Anton
              • 25663 MODX Staff
              • 12,272 Posts
              If it’s not already logged, definitely. smiley
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 1828
                • 137 Posts
                I did a few quick searches in "bugs & supports" but couldn’t see it in there. I don’t have access to login to that section. Is someone else here able to do it?

                Anton
                  • 17883
                  • 1,039 Posts
                    • 15826
                    • 160 Posts
                    Okay, I’m having this problem and had some issues with the following part of the patch:

                    I also had to apply the same patch the document.parser.class.inc.php file in the following functions:

                    getAllChildren()
                    getActiveChildren()
                    getDocumentChildren()
                    getDocuments()

                    I have a few sites running with this and all are sorting trees and menus correctly, with no obvious side-effects, ATM.

                    I managed to do the getAllChildren section okay, and the getActiveChildren okay but this part threw errors, which means I screwed it up somehow:

                      function getDocumentChildren($parentid=0, $published=1, $deleted=0, $fields="*", $where='', $sort="menuindex", $dir="ASC", $limit="") {
                        $limit = ($limit != "") ? "LIMIT $limit" : "";
                        $tblsc = $this->getFullTableName("site_content");
                        $tbldg = $this->getFullTableName("document_groups");
                        // modify field names to use sc. table reference
                        $fields = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$fields)));
                        $sort = ($sort=="") ? "":'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$sort)));
                        if ($where!='') $where = 'AND '.$where;
                        // get document groups for current user
                        if($docgrp = $this->getUserDocGroups()) $docgrp = implode(",",$docgrp);
                        // build query
                        $access = ($this->isFrontend() ? "sc.privateweb=0":"1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").
                          (!$docgrp ? "":" OR dg.document_group IN ($docgrp)");
                        $sql = "SELECT DISTINCT $fields
                          FROM $tblsc sc
                          LEFT JOIN $tbldg dg on dg.document = sc.id
                          WHERE sc.parent = '$parentid' AND sc.published=$published AND sc.deleted=$deleted $where
                          AND ($access) ".
                          GROUP BY sc.id
                          ($sort ? " ORDER BY $sort $dir ":"")." $limit ";
                        $result = $this->dbQuery($sql);
                        $resourceArray = array();
                        for($i=0;$i<@$this->recordCount($result);$i++)  {
                          array_push($resourceArray,@$this->fetchRow($result));
                        }
                        return $resourceArray;
                      }
                    
                      function getDocuments($ids=array(), $published=1, $deleted=0, $fields="*", $where='', $sort="menuindex", $dir="ASC", $limit="") {
                        if(count($ids)==0) {
                          return false;
                        } else {
                          $limit = ($limit != "") ? "LIMIT $limit" : ""; // LIMIT capabilities - rad14701
                          $tblsc = $this->getFullTableName("site_content");
                          $tbldg = $this->getFullTableName("document_groups");
                          // modify field names to use sc. table reference
                          $fields = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$fields)));
                          $sort = ($sort=="") ? "":'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$sort)));
                          if ($where!='') $where = 'AND '.$where;
                          // get document groups for current user
                          if($docgrp = $this->getUserDocGroups()) $docgrp = implode(",",$docgrp);
                          $access = ($this->isFrontend() ? "sc.privateweb=0":"1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").
                            (!$docgrp ? "":" OR dg.document_group IN ($docgrp)");
                          $sql = "SELECT DISTINCT $fields FROM $tblsc sc
                            LEFT JOIN $tbldg dg on dg.document = sc.id
                            WHERE (sc.id IN (".join($ids, ",").") AND sc.published=$published AND sc.deleted=$deleted $where)
                            AND ($access) ".
                            GROUP BY sc.id
                            ($sort ? " ORDER BY $sort $dir":"")." $limit ";
                          $result = $this->dbQuery($sql);
                          $resourceArray = array();
                          for($i=0;$i<@$this->recordCount($result);$i++)  {
                            array_push($resourceArray,@$this->fetchRow($result));
                          }
                          return $resourceArray;
                        }
                      }
                    


                    I also couldn’t find this to save my soul, and it’s the sort order in Ditto I’m working to fix:

                    Attention: This also affects ditto, in classes/functions.class.inc.php line around 250.

                    Any help would be greatly appreciated.
                      "I’d love to change the world but I can’t find the source code . . ."

                      Custom ModX Templates
                      • 15826
                      • 160 Posts
                      *bump*

                      Please help with last post. Thank you.
                        "I’d love to change the world but I can’t find the source code . . ."

                        Custom ModX Templates