• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Can anyone help me debug/fix these errors in the server log? "must be of the type array".

Phases

Active member
#1
EDIT: Actually I think this is from an album the user had trouble with yesterday that now appears deleted but when I try to access it on the site, I get this error in the browser rather than a 'page not found' like I would otherwise. I take it the random feature is trying to find it, and the 'view all albums' pages, like it wasn't deleted cleanly.. So, I guess please close this, don't think it's a problem with this code.

Original below..

I see this from an unsupported plugin (that I want to keep!) in my server error logs. Any chance this is a pretty easy fix?

Code:
ErrorException: Argument 1 passed to XfRu_UserAlbums_ControllerPublic_Images::assertCanManageImages() must be of the type array, boolean given, called in /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Images.php on line 24 and defined - library/XfRu/UserAlbums/ControllerPublic/Images.php:211
Generated By: Unknown Account, 3 minutes ago
Code:
Stack Trace
#0 /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Images.php(211): XenForo_Application::handlePhpError(4096, 'Argument 1 pass...', '/var/www/bspeak...', 211, Array)
#1 /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Images.php(24): XfRu_UserAlbums_ControllerPublic_Images->assertCanManageImages(false)
#2 /var/www/bspeaking/library/XenForo/FrontController.php(337): XfRu_UserAlbums_ControllerPublic_Images->actionManageImages()
#3 /var/www/bspeaking/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#4 /var/www/bspeaking/index.php(13): XenForo_FrontController->run()
#5 {main}
Code:
Request State
array(3) {
["url"] => string(90) "http://www.ballisticallyspeaking.com/useralbums/palmetto-arms-pa-15-ar-15.10/manage-images"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
Attached is the PHP file.

I'd love any help!
 

Attachments

Last edited:

Phases

Active member
#3
Awesome thank you. There are a couple different types of errors (I think) but that was the main one. Made the change, cleared the log, will watch for errors. Usually doesn't take long. Thanks for helping out!
 

Phases

Active member
#4
Ok, hope you don't mind more, or get to feeling like you're getting sucked into too much, bail at any point! Got the same error for this line. I'm going to try to work it out on my own, its a bit more complicated than the last though and I'm already tryin to wrap my brain around it..


Code:
$images = $imagesModel->prepareImages($imagesModel->getImagesByAlbumId($albumId, $album['album_type']), $album);
Code:
ErrorException: Argument 1 passed to XfRu_UserAlbums_Model_Images::getImageParams() must be of the type array, boolean given, called in /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Images.php on line 32 and defined - library/XfRu/UserAlbums/Model/Images.php:22
Generated By: Unknown Account, 10 minutes ago
Stack Trace
#0 /var/www/bspeaking/library/XfRu/UserAlbums/Model/Images.php(22): XenForo_Application::handlePhpError(4096, 'Argument 1 pass...', '/var/www/bspeak...', 22, Array)
#1 /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Images.php(32): XfRu_UserAlbums_Model_Images->getImageParams(false, Array, Array)
#2 /var/www/bspeaking/library/XenForo/FrontController.php(337): XfRu_UserAlbums_ControllerPublic_Images->actionManageImages()
#3 /var/www/bspeaking/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#4 /var/www/bspeaking/index.php(13): XenForo_FrontController->run()
#5 {main}
Request State
array(3) {
["url"] => string(89) "http://www.ballisticallyspeaking.com/useralbums/palmetto-arms-pa-15-ar-15.9/manage-images"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 

Phases

Active member
#5
Surely not as simple as:

Code:
if ($album) {
$images = $imagesModel->prepareImages($imagesModel->getImagesByAlbumId($albumId, $album['album_type']), $album);
}
I edited it to that, will watch for errors, seems to still work fine.
 

Nobita.Kun

Well-known member
#6
Code:
if($album)
{
$this->assertCanManageImages($album);
}
Replace by:
Code:
if(!$album)
{
return $this->responseNoPermission(); // error because request album don't exists
}
$this->assertCanManageImages($album);
 

Phases

Active member
#8
So far so good with those errors. The others I were talking about are still popping up. Again, feel free to bail! But it is 3 errors in two files, same error name. I think.

Undefined offset: 0

One file has same error for line (I think?) 500 and another error for 501.


First:
Code:
ErrorException: Undefined offset: 0 - library/XfRu/UserAlbums/Model/Images.php:500 (and 501 in diff error)
Generated By: Unknown Account, 10 minutes ago
Stack Trace
#0 /var/www/bspeaking/library/XfRu/UserAlbums/Model/Images.php(500): XenForo_Application::handlePhpError(8, 'Undefined offse...', '/var/www/bspeak...', 500, Array)
#1 /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Image.php(59): XfRu_UserAlbums_Model_Images->getImageNeighbours(NULL, 43)
#2 /var/www/bspeaking/library/XenForo/FrontController.php(337): XfRu_UserAlbums_ControllerPublic_Image->actionViewImage()
#3 /var/www/bspeaking/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#4 /var/www/bspeaking/index.php(13): XenForo_FrontController->run()
#5 {main}
Request State
array(3) {
["url"] => string(83) "http://www.ballisticallyspeaking.com/useralbums/imp-22cal-short-0-jpg.43/view-image"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
Lines 500 and 501:

Code:
'prev' => ($prev != $imageId) ? $images[$prev] : $images[$last],        
'next' => ($next != $imageId) ? $images[$next] : $images[$first],
Maybe change that to if($prev) { } and if($next) {} ? I do see the image trying to be viewed is a lone image in the album.

Second:
Code:
ErrorException: Undefined offset: 0 - library/SplendidNetwork/XfRuAlbumsMore/Model/Albums.php:58
Generated By: Unknown Account, 2 minutes ago
Stack Trace
#0 /var/www/bspeaking/library/SplendidNetwork/XfRuAlbumsMore/Model/Albums.php(58): XenForo_Application::handlePhpError(8, 'Undefined offse...', '/var/www/bspeak...', 58, Array)
#1 /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Image.php(54): SplendidNetwork_XfRuAlbumsMore_Model_Albums->assertAlbumValidAndViewable(16, '')
#2 /var/www/bspeaking/library/XenForo/FrontController.php(337): XfRu_UserAlbums_ControllerPublic_Image->actionViewImage()
#3 /var/www/bspeaking/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#4 /var/www/bspeaking/index.php(13): XenForo_FrontController->run()
#5 {main}
Request State
array(3) {
["url"] => string(71) "http://www.ballisticallyspeaking.com/useralbums/pa-15-jpg.42/view-image"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
58:
Code:
list($album) = $this->limitAlbumsOnType(array($album));
Maybe:
Code:
list($album) = if ($album) { $this->limitAlbumsOnType(array($album)); }
Maybe?

Again, appreciate any help and I realize this is more than you meant to do, so bail at any point. But it's working so far, thanks so much! So far, none of the other errors have yet returned.

Php files attached, as txt
 

Attachments

Last edited:

Nobita.Kun

Well-known member
#9
Look like $album give `false` so you must check $album before processing.
Example:
Code:
public function getImageNeighbours($album, $imageId)
    {
        $images = $this->prepareImages($this->getImagesByAlbumId($album['album_id']), $album);
Should be:
Code:
public function getImageNeighbours($album, $imageId)
    {
       if(!$album) { return false; }
 $images = $this->prepareImages($this->getImagesByAlbumId($album['album_id']), $album);
 

Phases

Active member
#10
Great thank you, made that change! Then, in the second one I changed:

list($album) = $this->limitAlbumsOnType(array($album));

to

if ($album) { list($album) = $this->limitAlbumsOnType(array($album)); }

Though I'm not sure that will do anything. Monitoring log
 

Phases

Active member
#11
Ok, it looks like the "second one" is still happening, regardless of my if $album encapsulation. But looks, so far, like all other are gone.
 

Phases

Active member
#12
Ok, the good news is, all the errors you've helped me fix have not returned! The bad? The one is still lingering.

ErrorException: Undefined offset: 0 - library/SplendidNetwork/XfRuAlbumsMore/Model/Albums.php:58
Generated By: Unknown Account, 2 minutes ago
Stack Trace
#0 /var/www/bspeaking/library/SplendidNetwork/XfRuAlbumsMore/Model/Albums.php(58): XenForo_Application::handlePhpError(8, 'Undefined offse...', '/var/www/bspeak...', 58, Array)
#1 /var/www/bspeaking/library/XfRu/UserAlbums/ControllerPublic/Image.php(54): SplendidNetwork_XfRuAlbumsMore_Model_Albums->assertAlbumValidAndViewable(16, '')
#2 /var/www/bspeaking/library/XenForo/FrontController.php(337): XfRu_UserAlbums_ControllerPublic_Image->actionViewImage()
#3 /var/www/bspeaking/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#4 /var/www/bspeaking/index.php(13): XenForo_FrontController->run()
#5 {main}
Request State
array(3) {
["url"] => string(71) "http://www.ballisticallyspeaking.com/useralbums/pa-15-jpg.42/view-image"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
58:
Code:
list($album) = $this->limitAlbumsOnType(array($album));
I tried:
Code:
list($album) = if ($album) { $this->limitAlbumsOnType(array($album)); }
But that didn't work, I wouldn't expect it would. Is it a problem with the array?
 

Phases

Active member
#13
Alright forever later one more did show. But it's from a default XF file and I really don't think we want to mess with that. Looks like something I might not be too worried about anyway?

ErrorException: Fatal Error: Call to undefined method SplendidNetwork_XfRuAlbumsMore_Model_Albums::responseException() -library/XenForo/Controller.php:824
Generated By: Unknown Account, 55 minutes ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
["url"] => string(68) "http://www.ballisticallyspeaking.com/useralbums/ar-jpg.46/view-image"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
824:
Code:
return $this->responseException($this->responseNoPermission());
of library/XenForo/Controller.php
 

Nobita.Kun

Well-known member
#14
Ok, the good news is, all the errors you've helped me fix have not returned! The bad? The one is still lingering.



58:
Code:
list($album) = $this->limitAlbumsOnType(array($album));
I tried:
Code:
list($album) = if ($album) { $this->limitAlbumsOnType(array($album)); }
But that didn't work, I wouldn't expect it would. Is it a problem with the array?
If album given don't exist you should be return `null` or `false` :)
 

Phases

Active member
#15
I changed it to this:
Code:
if (!$album) { return false; }
list($album) =  $this->limitAlbumsOnType(array($album));
return $album;
and get the same error still on the list($album) = line.

But I think it might have to do with a bug in the plugin where when users set the album to "members only" they can't see their own albums. That's how I triggered it. So. I wonder if I fix that bug if this will fix. Or, disable the portion where they can make it "members only" period.

What do you think of the other error I posted? That was pointing to a default XF file, I don't think that's anything we should mess with and it. These are mostly harmless anyway, yes?

I appreciate all your help, you got the biggest concerns that I was about to uninstall over, fixed!
 
Last edited: