We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39411
    • 4 Posts
    so i've placed [-[!Gallery]-] in my resource (parameters doesnt matter)
    this is supposed to show all albums (and it shows laugh) but if you have request var (default is galAlbum) and set it to id which doesnt exist
    like /gallery?galAlbum=99 (assuming u doesnt have album with ID 99 ) page wont load and shows you fatal error:

    Warning: Invalid argument supplied for foreach() in lalala/modx/core/cache/includes/elements/modsnippet/18.include.cache.php on line #103#

    Fatal error: Cannot use string offset as an array in lalala/modx/core/cache/includes/elements/modsnippet/18.include.cache.php on line #2#

    these lines is:
    #103#(line 103 in original snippet) foreach ($data['items'] as $item) {
    #162#(line 162 in original snippet) $placeholderPrefix.'id' => $data['album']['id'],

    i've quick fixed by adding

    if (empty($data)) return '';
    right after line 48: $data = $modx->call('galItem','getList',array(&$modx,$scriptProperties));

    TLDR: if u call gallery with non-existing album - it breaks with fatal error on ur site
    latest modx, latest gallery
    there's a fix [ed. note: fen1kz last edited this post 11 years, 5 months ago.]
      • 36724
      • 13 Posts
      Hi Fen1kz,

      thanks a lot for this q&d fix, works like charm.

      Have you filed a bug report as well?
        • 39411
        • 4 Posts
        hey, sorry i dont know where to bugreport this, so i posted only via this forum =(
          • 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
            • 39411
            • 4 Posts
            huh, thank you, posted bug @ github https://github.com/splittingred/Gallery/issues/240