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.
Did it indicate which line the error is on?
Sure did!
ManageAttachments.controller.php
Line: 218
Hummm .... try adding the following line just above that line ( in ManaageAttachments.controller.php )
$modSettings['attachmentUploadDir'] = !empty($modSettings['attachmentUploadDir']) ?: array();
and lets see what happens
Well, it must be progress! ;D Now the error is:
Warning: in_array() expects parameter 2 to be array, bool given
Humm .... this is why
@emanuele is updating this code for 2.0 :D
Just for a test, try using
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.
Maybe...
Line 190:
if (isset($this->_req->post->attachmentUploadDir))
to:
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.
This code also removes the original error, and results in no directory creation (which you probably expected).
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.
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.
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!
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?
I don't think this one is tracked yet for 1.1.6. Not sure about 2.0.
Tracked: https://github.com/elkarte/Elkarte/issues/3298