Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

bug with the gallery


Reply


25 Posts   12048 Views

Avatar
Christy

Community Member, 58 Posts

4 July 2008 at 2:00pm

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?

Avatar
Willr

Forum Moderator, 5513 Posts

4 July 2008 at 2:08pm

<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?

Avatar
Christy

Community Member, 58 Posts

4 July 2008 at 2:37pm

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

Thanks

Avatar
Willr

Forum Moderator, 5513 Posts

4 July 2008 at 3:21pm

try changing that to

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

Basically check it exists before you check its not a number

Avatar
Christy

Community Member, 58 Posts

4 July 2008 at 4:36pm

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

Avatar
Willr

Forum Moderator, 5513 Posts

4 July 2008 at 4:49pm

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

Avatar
Christy

Community Member, 58 Posts

4 July 2008 at 5:09pm

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 />
^

Avatar
Willr

Forum Moderator, 5513 Posts

4 July 2008 at 6:47pm

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!