Module: Folder Sync

eschava

Joined: 2013-08-03
Posts: 1
Posted: Sat, 2013-08-03 15:52

Guys,
if I got it correctly folder_sync copies all files to some gallery internal folder, right? So all photos are duplicated
Could it instead create symlink to external file?

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Mon, 2013-08-05 01:53

Technically speaking Folder Sync does NOT create any other files; it's Gallery that does all the processing/resizing, thus it creates other files (I wouldn't call them duplicates). Once Folder Sync processed all files, you can certainly delete original files that you have uploaded (provided that you didn't enable "Process deleted items").

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Mon, 2013-08-05 02:01

@zahaim - there are two issue I see there. First, I can't get a lock on a temp file to prevent multiple simultaneous executions. I will add the proper error handling to see what's going on there. Second, you have an issue with timezone settings.

 
zahaim

Joined: 2013-08-01
Posts: 6
Posted: Mon, 2013-08-05 22:05

Hi siburny,
Thanks for your quick reply. As far as the first issue is concerned (Warning: flock() expects parameter 1 to be resource, boolean given) I resolved it by changing permissions on my server.

Now, no matter if I run the cron as a httpdusr or admin, I've got the message regarding timezone and Notice: Undefined offset: 1 in /share/HDA_DATA/Web/gallery3/system/libraries/I18n.php on line 60.
I am trying to figure out where to put 'Europe/Berlin' to resolve timezone error, I have already done it in gallery3's settings and restarted apache but nothing changed.

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Mon, 2013-08-05 22:12

The timezone setting needs to go in your php.ini:

date.timezone = "Europe/Berlin"
 
zahaim

Joined: 2013-08-01
Posts: 6
Posted: Tue, 2013-08-06 21:54

hello jnash,
Thanks. Look at this - all the files having date.timezone :
[/share/HDA_DATA/Web/gallery3] # find . -name "*php*" | xargs grep -l "date.timezone"
./php.ini
./system/config/locale.php
./index.php
./modules/gallery/helpers/gallery_event.php

and the lines :
[/share/HDA_DATA/Web/gallery3] # find . -name "*php*" | xargs cat | grep "date.timezone"
date.timezone = "Europe/Berlin"
$config['timezone'] = ini_get('date.timezone');<?php defined('SYSPATH') OR die('No direct access allowed.');
if (!ini_get("date.timezone")) {
ini_set("date.timezone", "Europe/Berlin");
if (!get_cfg_var("date.timezone")) {
Kohana_Log::add("error", "date.timezone setting not detected in " .

It seems to be done in all php config files though.

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Wed, 2013-08-07 00:15

Can you also check through a web? I've seen systems where two different config files are used for CGI and CLI. Just put a small info.php file, put "<?php phpinfo();" in it, and hit it through web.

 
zahaim

Joined: 2013-08-01
Posts: 6
Posted: Wed, 2013-08-07 22:49

Hi siburny,
It's OK though the web as well. I've found a fix http://galleryproject.org/node/106233 but I did not work as well.
I am still investigating...

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Thu, 2013-08-08 00:49

One more thing I just noticed in your error output:

Kohana_PHP_Exception [ 2 ]: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead
/share/HDA_DATA/Web/gallery3/modules/gallery/config/locale.php [ 36 ]

PHP thinks you are in "CEST/2.0/DST". So somewhere it's still set to wrong timezone.

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Thu, 2013-08-08 00:51

Can you paste the output for the following commands:

php -i | grep ini

and

php -i | grep timezone

Like I said, it's possible that PHP loads different INI-file for command-line interface.

 
zahaim

Joined: 2013-08-01
Posts: 6
Posted: Sun, 2013-08-11 22:40

OK, so I got it work.

First, I followed your instruction and found that the timezone was not set in another php.ini file that php was actually using. So I inserted it.

Then, I found the following line in the logfile :

2013-08-11 16:00:23 +02:00 --- error: Kohana_PHP_Exception [ 2 ]: date_default_timezone_set() expects parameter 1 to be string, array given
/share/HDA_DATA/Web/gallery3/system/core/Kohana.php [ 165 ]

I went to Kohana.php and found:
date_default_timezone_set(Kohana::config("Europe/Berlin"));
so I replaced it with:
date_default_timezone_set("Europe/Berlin");

The value must have been put there while I tried to replace the procedure of get to set timezone I guess and I did not make it properly.

Anyways, thank you a lot for the support and good luck with the very best module for gallery3. Cheers!

 
zahaim

Joined: 2013-08-01
Posts: 6
Posted: Sun, 2013-08-11 23:47

One more little thing... Is there a log file of photos being processed by the script?

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Mon, 2013-08-12 00:05

Hmm, there is no option like that right now. The easiest would to be add a couple of print statements to output status info.

 
pabloalcantara

Joined: 2013-08-19
Posts: 1
Posted: Mon, 2013-08-19 19:48

When I try to run "/mnt/ext/opt/apache/bin/php /share/HDA_DATA/Web/gallery3/modules/folder_sync/cron.php", it genarates this:

Then the error message attached happens.
and then nothing happens.

Background info:

php version: PHP 5.3.26 (cli) (built: Jun 24 2013 03:31:29)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

Gallery version: 3.0.1 (tryied with 3.0.9, same error)

Nas system: QNAP TS219 II

Any help would be aprecieted

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Tue, 2013-08-20 00:56

For some reason Gallery thinks it's not installed, and directs you to the "installer" link

 
kinsham

Joined: 2012-04-03
Posts: 6
Posted: Wed, 2013-12-04 20:34

Am I correct that the cron job must run as the same user as Apache2? In my case www-data.

and that MySQL must also be configured to have permissions for this user?

Chris

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Wed, 2013-12-04 20:44

Yes, cron job must run as Apache user to avoid the problem with file permissions down the road. As for MySQL, you don't have to do anything beyond setting up Gallery script itself. Since this is a plugin, it will use the same information as Gallery is using.

 
kinsham

Joined: 2012-04-03
Posts: 6
Posted: Wed, 2013-12-04 21:58

That's what I have. I'm having trouble because folder_sync is creating new folders at the 4th level of album hierarchy as root:root 755 and hence PHP as www-data is unable to write to it.

Chris

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Wed, 2013-12-04 22:09

If you ran the cron job as root at least once or just executed it in console as root, then it already created folders with "root:root" permissions. You need to fix that by changing the owner back to www-data.

 
kinsham

Joined: 2012-04-03
Posts: 6
Posted: Wed, 2013-12-04 22:53

I can see why that would cause this problem but the cron job runs as www-data at least that's what ps -ef is showing me so I'm a bit puzzled. The folder did not exist until the cron job created it.

I set up/ran the cron job in Webmin so don't use a console.

Just to experiment I created a new folder at the top of the source tree and had cron run. folder_sync correctly created a new folder as www-data:www-data (correct) 755 which I guess is OK too. So it seems that the behavior is different depending on the hierarchical level of the folder to be added.

Chris

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Thu, 2013-12-05 01:59

If parent folder was "root:root" with 755 permissions, then cronjob started as www-data would not have write access to that folder in the first place, so it wouldn't be able to create more folders with "root:root" owner.

At this point, just change the owner of the created folders to www-data, and you'll be fine.

 
AngusCS

Joined: 2005-09-13
Posts: 10
Posted: Tue, 2013-12-10 07:11

I know this is a little old now, but way back on the 22 of December last year you posted this in response to ecar's undefined index errors from running the cron job...

siburny wrote:
First set of warning has something to do with your particular PHP installation: it doesn't supply $_SERVER in the command line mode.

...but that was all you said. Is there a way to fix this as I am getting what appear to the php newbie to be similar issues. I can run cron.php from the browser and it keeps going until it throws an exception (file type or file limit I assume), but I cannot run the cron job as I get errors similar to the errors shown above (from ecar's post).

Is there anything I can do to change the syntax of the cron job to allow config.php to find the base url???

My job syntax is php /home/username/public_html/FOLDER/Gallery/modules/folder_sync/cron.php

My error is:

<br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>45</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_FILENAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Warning</b>: strpos() [<a href='function.strpos'>function.strpos</a>]: Empty needle in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>45</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_FILENAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Warning</b>: strpos() [<a href='function.strpos'>function.strpos</a>]: Empty needle in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> ErrorException [ 0 ]: Cannot modify header information - headers already sent by (output started at /home/username/public_html/FOLDER/Gallery/application/config/config.php:45)
/home/username/public_html/FOLDER/Gallery/modules/gallery/views/kohana/error.php [ 45 ]
#0 [internal function]: gallery_error_Core::error_handler(2, 'Cannot modify h...', '/home/username/...', 45, Array)
#1 /home/username/public_html/FOLDER/Gallery/modules/gallery/views/kohana/error.php(45): header('HTTP/1.1 500 In...')
#2 /home/username/public_html/FOLDER/Gallery/system/core/Kohana_Exception.php(186): include('/home/username/...')
#3 /home/username/public_html/FOLDER/Gallery/system/libraries/Kohana_PHP_Exception.php(95): Kohana_Exception_Core::handle(Object(Kohana_PHP_Exception))
#4 [internal function]: Kohana_PHP_Exception_Core::shutdown_handler(NULL)
#5 /home/username/public_html/FOLDER/Gallery/system/core/Event.php(208): call_user_func_array(Array, Array)
#6 /home/username/public_html/FOLDER/Gallery/system/core/Kohana.php(553): Event_Core::run('system.shutdown')
#7 [internal function]: Kohana_Core::shutdown()
#8 {main}

As stated I am a PHP newbie and know only enough about Linux to spell it...

I have only recently moved my Gallery to a hosted Linux solution recently. Before I was on Apache on Windows...

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Tue, 2013-12-10 14:57

Let me first explain why you get that error, then we can troubleshoot. From the stacktrace you posted above, it looks like the problem is in "error" view. Gallery throws an exception, then tries to show to you using "error" view, but there is another error in the that view. So bottom line, we don't see the original error. But why "error" view errors out, I don't know - it's not supposed to show "html" errors in command-line mode.

To troubleshoot, please navigate to /modules/gallery/view/Kohana/error.php, and then add the following right before line #11:

echo php_sapi_name();exit;

Then execute cronjob, and tell us what it outputs. On my system, I see "cli" printed in the output.

 
AngusCS

Joined: 2005-09-13
Posts: 10
Posted: Wed, 2013-12-11 07:46

Thanks for your prompt reply (time zones will play with us, I am in Australia).

Added the code at line 10, executed the job and received the output below (by the way my path is /modules/gallery/views/Kohana/error.php but I assumed the correct file).

<br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>45</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_FILENAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Warning</b>: strpos() [<a href='function.strpos'>function.strpos</a>]: Empty needle in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>45</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Notice</b>: Undefined index: SCRIPT_FILENAME in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> <br />
<b>Warning</b>: strpos() [<a href='function.strpos'>function.strpos</a>]: Empty needle in <b>/home/username/public_html/FOLDER/Gallery/application/config/config.php</b> on line <b>46</b><br /> cgi-fcgi

I assume this means that the PHP SAPI is cgi-fcgi?

 
Urias

Joined: 2014-01-06
Posts: 2
Posted: Mon, 2014-01-06 21:00

Hi!
I'm attempting to import a folder structure to a large existing Gallery. When there are albums with the same name, the Folder Sync module seems to always make a new folder with a duplicate name. Is there some way or trick I can use to get the folder contents merged?

 
siburny

Joined: 2012-03-27
Posts: 55
Posted: Mon, 2014-01-06 22:21
Urias wrote:
Hi!
I'm attempting to import a folder structure to a large existing Gallery. When there are albums with the same name, the Folder Sync module seems to always make a new folder with a duplicate name. Is there some way or trick I can use to get the folder contents merged?

At this point it's pretty hard to trick - you have to deal on folder-by-folder basis. But I can add a block that can check if folder exists before creating it.

 
Urias

Joined: 2014-01-06
Posts: 2
Posted: Tue, 2014-01-07 18:43

Yes please, that would be great!