We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    Just updated a site to 1.0.15 and have it installed on PHP 5.5.x

    I just modified the site for MYSQLI compatibility and turned on error reporting, I am now getting the following error:
    $modx->makeList() is deprecated function
    Snippet - Ditto
    F:/wamp/www/MYFOLDER/assets/snippets/ditto/extenders/tagging.extender.inc.php(line:330)


    The line of code that is referred to:
    $output = $modx->makeList($tagList, $ulroot='ditto_tag_list', $ulprefix='ditto_tag_', $type='', $ordered=false, $tablevel=0);


    Any savvy PHP'ers out there that know a fix for this ?

    Any help appreciated smiley

    This question has been answered by kp52. See the first response.

    • discuss.answer
      • 16278
      • 928 Posts
      This list-formatting utility function seems to have been moved from the main document parser into a set of "deprecated core functions" along with some old Etomite database calls in Evo 1.0.11. See https://github.com/modxcms/evolution/commit/ab52e6335b3538cff4afc00a7689975d2cdef3f1 and http://tracker.modx.com/issues/9720.

      The function doesn't make any database calls, so switching to mysqli shouldn't make it deprecated. A text search for "makeList" in the 1.0.15 files brings up only the Ditto tagging extender and the deprecated functions class as hits; maybe the author of the revision thought it was an ugly and unused feature that could be safely swept under the carpet together with the Etomite stuff? You'd have to ask in the GitHub issues.

      You could add the function to the tagging extender by inserting the code below into tagging.extender.inc.php before line 338 (Tagging Parameters section) and changing the call in line 330 from $output = $modx->makeList to $output = $this->makeList. (Not tested!).

      ;) KP

          function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) {
              // first find out whether the value passed is an array
              if (!is_array($array)) {
                  return "<ul><li>Bad list</li></ul>";
              }
              if (!empty ($type)) {
                  $typestr= " style='list-style-type: $type'";
              } else {
                  $typestr= "";
              }
              $tabs= "";
              for ($i= 0; $i < $tablevel; $i++) {
                  $tabs .= "\t";
              }
              $listhtml= $ordered == true ? $tabs . "<ol class='$ulroot'$typestr>\n" : $tabs . "<ul class='$ulroot'$typestr>\n";
              foreach ($array as $key => $value) {
                  if (is_array($value)) {
                      $listhtml .= $tabs . "\t<li>" . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix, $type, $ordered, $tablevel +2) . $tabs . "\t</li>\n";
                  } else {
                      $listhtml .= $tabs . "\t<li>" . $value . "</li>\n";
                  }
              }
              $listhtml .= $ordered == true ? $tabs . "</ol>\n" : $tabs . "</ul>\n";
              return $listhtml;
          }
      
        • 13226
        • 953 Posts
        @KP

        Thanks for your feedback

        I am not a PHP'er so will pass this info on to a programmer I know

        I wouldn't know where to start if there are errors after modifying the code smiley
          • 13226
          • 953 Posts
          UPDATE:

          This problem is now resolved - based on the info provided by KP (Thanks again)

          To note is: this change is only required for display mode 2 - ul/li list. It is the only display mode that uses the makelist function.

          File: assets/snippets/ditto/extenders/tagging.extender.inc.php

          Line 330 changed from:
          $output = $modx->makeList($tagList, $ulroot='ditto_tag_list', $ulprefix='ditto_tag_', $type='', $ordered=false, $tablevel=0);
          To
          $output = $this->makeList($tagList, $ulroot='ditto_tag_list', $ulprefix='ditto_tag_', $type='', $ordered=false, $tablevel=0);

          Added the "Makelist function" to the file, removes the requirement to call the function from the Evo core

          After making the changes an error was displayed referencing how "templates" are called.

          The following changes were made to the file: "assets/snippets/ditto/classes/template.class.inc.php"

          CHANGE:
          // ---------------------------------------------------
          // Function: fetch
          // Get a template, based on version by Doze
          // 
          // http://forums.modx.com/thread/41066/support-comments-for-ditto?page=2#dis-post-237942
          // ---------------------------------------------------
          function fetch($tpl){

          INTO THIS:
          // ---------------------------------------------------
          // Function: fetch
          // Get a template, based on version by Doze
          // 
          // http://forums.modx.com/thread/41066/support-comments-for-ditto?page=2#dis-post-237942
          // ---------------------------------------------------
          static function fetch($tpl){


          The files are attached if anyone is interested

          The error reporting now no-longer displays any errors - my config is set as: "Detect all errors except E_NOTICE"

          I am not a programmer so I don't know if it's relevant, but, the changes work for both database types: MYSQL & MYSQLI

          Just for info - the modifications were not carried out by me personally, they were completed by a PHP developer [ed. note: iusemodx last edited this post 8 years, 9 months ago.]
            • 20413
            • 2,877 Posts
            Thanks for sharing @iusemodx smiley
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 13226
              • 953 Posts
              No problem "mrhaw" smiley

              Just for info:

              Yama has kindly updated the Ditto files on GitHub, as can be seen here