Skip to main content
Topic: Attachment Directory management error (Read 5549 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Attachment Directory management error

php7.3, nginx 1.15.8, mariadb 10.3. Fresh 1.1.5 install. When attempting to change Choose the method for the management of the attachment directories to Auto Subdivide by months and years and checking box Create new directories within a base directory, there is an error "in_array() expects parameter 2 to be array, string given". Anyone know a fix? Thanks!

Edit: the offending feature seems to be checking the Auto Subdivide. Choosing the option fails to create a subdirectory, and naturally attachment uploads fail. 

Re: Attachment Directory management error

Reply #1
Did it indicate which line the error is on? 

Squish squish. squish, squish, squish.
Find a bug,
Make a wish.


Re: Attachment Directory management error

Reply #3
Hummm .... try adding the following line just above that line ( in ManaageAttachments.controller.php )
Code: [Select]
					$modSettings['attachmentUploadDir'] = !empty($modSettings['attachmentUploadDir']) ?: array();
and lets see what happens
Squish squish. squish, squish, squish.
Find a bug,
Make a wish.

Re: Attachment Directory management error

Reply #4
Hummm .... try adding the following line just above that line ( in ManaageAttachments.controller.php )
Code: [Select]
					$modSettings['attachmentUploadDir'] = !empty($modSettings['attachmentUploadDir']) ?: array();
and lets see what happens
 
 Well, it must be progress!  ;D Now the error is:


Code: [Select]
Warning: in_array() expects parameter 2 to be array, bool given

Re: Attachment Directory management error

Reply #5
Humm .... this is why @emanuele is updating this code for 2.0 :D

Just for a test, try using
Code: [Select]
					if (empty($modSettings['attachmentUploadDir']))
{
$modSettings['attachmentUploadDir'] = array();
}
else
{
$test = @Util::unserialize($modSettings['attachmentUploadDir']);
if ($test === false)
{
$modSettings['attachmentUploadDir'] = array($modSettings['attachmentUploadDir']);
}
else
{
$modSettings['attachmentUploadDir'] = $test;
}
}
instead of the other single line I gave you.
Squish squish. squish, squish, squish.
Find a bug,
Make a wish.

Re: Attachment Directory management error

Reply #6
Maybe...
Line 190:
Code: [Select]
if (isset($this->_req->post->attachmentUploadDir))
to:
Code: [Select]
			if (isset($this->_req->post->attachmentUploadDir) ||
!empty($this->_req->post->use_subdirectories_for_attachments))
Bugs creator.
Features destroyer.
Template killer.

Re: Attachment Directory management error

Reply #7
Maybe...
Line 190:
Code: [Select]
if (isset($this->_req->post->attachmentUploadDir))
to:
Code: [Select]
			if (isset($this->_req->post->attachmentUploadDir) ||
!empty($this->_req->post->use_subdirectories_for_attachments))
 
 Tried this. There was no error managing the settings. However, setting it to Auto subdivided by month and year resulted in no directory created and, of course, inability to upload.

Re: Attachment Directory management error

Reply #8
Humm .... this is why @emanuele is updating this code for 2.0 :D

Just for a test, try using
Code: [Select]
					if (empty($modSettings['attachmentUploadDir']))
{
$modSettings['attachmentUploadDir'] = array();
}
else
{
$test = @Util::unserialize($modSettings['attachmentUploadDir']);
if ($test === false)
{
$modSettings['attachmentUploadDir'] = array($modSettings['attachmentUploadDir']);
}
else
{
$modSettings['attachmentUploadDir'] = $test;
}
}
instead of the other single line I gave you.
 
 
This code also removes the original error, and results in no directory creation (which you probably expected). 

Re: Attachment Directory management error

Reply #9
Yeah so the code is a bit broken ....  but I think you know that  O:-)

FYI what I personally do is create directories for each year, and I manually create them :(  I don't really see the need for monthly separation unless you were on a site that created an enormous number of attachments.   I break it down by year just to simplify my backup scripts.

In 2.0 the plan was to simply that code, it simply allows to many options which causes complications for everyone.

Squish squish. squish, squish, squish.
Find a bug,
Make a wish.

Re: Attachment Directory management error

Reply #10
Yeah so the code is a bit broken ....  but I think you know that  O:-)
 
 So it is. It's difficult casting stones unless one happens to be a professional coder, in which case said individual would write their own stuff. Suffice that to say the work you guys do is much appreciated! Elk is awesome software, even better is question response. 

FYI what I personally do is create directories for each year, and I manually create them :(  I don't really see the need for monthly separation unless you were on a site that created an enormous number of attachments.  I break it down by year just to simplify my backup scripts.

In 2.0 the plan was to simply that code, it simply allows to many options which causes complications for everyone.
 
 My sites are probably more image oriented than most. Still, "enormous" wouldn't be a great numeric descriptor regarding them. You have a good plan there. It would be cool if the software truly auto sorted even by year. But it is no biggie if it doesn't.

Thanks spuds!

Re: Attachment Directory management error

Reply #11
I think the most common limit to avoid is the usually 10k files per directory that is enforced for ftp in certain configurations (i.e. the ftp returns only the first 10k files). Though this limit is not always present, so it's a kind of case-by-case.
Apart from that, it could be wise to avoid to have more than 10k files in a directory just to remain sane.
Bugs creator.
Features destroyer.
Template killer.

Re: Attachment Directory management error

Reply #12
I think the most common limit to avoid is the usually 10k files per directory that is enforced for ftp in certain configurations (i.e. the ftp returns only the first 10k files). Though this limit is not always present, so it's a kind of case-by-case.
Apart from that, it could be wise to avoid to have more than 10k files in a directory just to remain sane.
 
 That said, is there a way to move files from a specific timeframe to a different directory? Or move specific files?

 

Re: Attachment Directory management error

Reply #13
I don't think this one is tracked yet for 1.1.6. Not sure about 2.0.