Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » bug with the gallery

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2 3 4
Go to End
Author Topic: 11469 Views
  • Christy
    Avatar
    Community Member
    57 Posts

    Re: bug with the gallery Link to this post

    I have loaded the Gallery module and loading the page generates the following error with Firefox. With IE the error message flicks up and then the page displays with no photos showing. SS ver 2.2.2

    XML Parsing Error: junk after document element

    <b>Notice</b>: Undefined index: start in <b>C:\wamp\www\silverstripe-v2.2.2\gallery\code\GalleryPage.php</b>; on line <b>381</b><br />

    Is there a solution for this please?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: bug with the gallery Link to this post

    <b>Notice</b>: Undefined index: start in <b>C:\wamp\www\silverstripe-v2.2.2\gallery\code\GalleryPage.php</b>;; on line <b>381</b>

    What is on like 381 of GalleryPage.php in your version?

  • Christy
    Avatar
    Community Member
    57 Posts

    Re: bug with the gallery Link to this post

    if( ! is_numeric( $_REQUEST['start'] ) )

    Thanks

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: bug with the gallery Link to this post

    try changing that to

    if(isset($_REQUEST['start']) && !is_numeric( $_REQUEST['start'] ))

    Basically check it exists before you check its not a number

  • Christy
    Avatar
    Community Member
    57 Posts

    Re: bug with the gallery Link to this post

    the result is a long list of errors starting with

    Notice: Undefined index: start in C:\wamp\www\silverstripe-v2.2.2\gallery\code\GalleryPage.php on line 383

    FATAL ERROR: DATABASE ERROR: Couldn't run query: SELECT `File`.ID, `File`.ClassName, `File`.Created, `File`.LastEdited, `File`.Name, `File`.Title, `File`.Content, `File`.ParentID, `File`.Filename, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName, `File`.PopupWidth, `File`.PopupHeight, `File`.Embed, `File`.LimitDimensions FROM `File` WHERE (`Filename` REGEXP '[.](png|jpg|jpeg|gif)$' AND `ParentID` = '18') ORDER BY `File`.`Title` ASC LIMIT ,30 | 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 '30' at line 1
    At line 431 in C:\wamp\www\silverstripe-v2.2.2\sapphire\core\model\Database.php

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: bug with the gallery Link to this post

    Ok I looked the code up and so lets change that whole if else bit ..

    if(isset($_REQUEST['start']) && !is_numeric( $_REQUEST['start'] )) {
    $start = ($this->MediaPerPage) ? $this->MediaPerPage : 0;
    }
    else {
    $start = $_REQUEST['start'] + $this->MediaPerPage;
    }

    Thats how that lines 365 -> currently 368 should work - added the isset round the $_REQUEST then also if MediaPerPage isnt defined (which Im guessing its not in your case) we want it to not throw that giant error so we can give it a value to use.

    This should work

  • Christy
    Avatar
    Community Member
    57 Posts

    Re: bug with the gallery Link to this post

    I replaced row 381 with above and the error message is now

    XML Parsing Error: junk after document element
    Location: http://localhost/silverstripe-v2.2.2/lime-rock-album?flush=1
    Line Number 2, Column 1:<b>Notice</b>: Undefined index: start in <b>C:\wamp\www\silverstripe-v2.2.2\gallery\code\GalleryPage.php</b>; on line <b>386</b><br />
    ^

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: bug with the gallery Link to this post

    sorry I completely misread the code and posted it without actually thinking. This is the current code

    if( ! is_numeric( $_REQUEST['start'] ) ) $_REQUEST['start'] = 0;
    $limit = $_REQUEST['start'] . "," . $this->MediaPerPage;

    So basically what its doing at the moment is that if start is defined as a int use it else it is 0. So ignore that last piece of code. What we want to do is 1st check start exists, then if start exists check if its a numeric number. Probably a cleaner way to do this but however

    if(isset($_REQUEST['start'])) {
    $_REQUEST['start'] = (is_numeric($_REQUEST['start'])) ? $_REQUEST['start'] : 0;
    }
    $limit = $_REQUEST['start'] . "," . $this->MediaPerPage;

    try that!

    11469 Views
Page: 1 2 3 4
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.