Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
sprocket
Experienced
Topic Author
Posts: 98
Joined: 18 Dec 2008, 19:40

php Touch ()

13 Sep 2016, 12:59

Posting this just in case it helps.
At home I have a Synology NAS that I mirror my website on. This gives me a backup and also allows me to experiment without disturbing the live public site. The NAS runs an Apache Web Server. Anyway, the site browses fine, but when I logged into the panel I could not change/save any settings, nor could I run "refresh menu". Both resulted in "can't write to \content" error. Checking the error logs I notice that both errors were triggered in lines of code that used the touch() command. Doing a little research I found THIS discussion on the touch command. Following user166560 advice (3rd answer listed), in the two php files that were giving me problems, filemanager_core.php [line 48] and menu_create.php [line 37], I changed the touch function to is_writable and all seems to work well now. I haven't played extensively with the panel on this home server, so not sure if the touch function is used elsewhere, that will give me further issues.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: php Touch ()

13 Sep 2016, 22:58

I am not sure you are aware what the touch() feature in X3 is for, but you can't generally change it to is_writeable(). The touch() command will change the timestamp of the content folder, while is_writeable() does absolutely nothing (just returns a status to the program).

The touch method was implemented in X3 Release [0.18].
X3 0.18 wrote: "Touch" Cache Invalidation
When an X3 page starts loading, it needs to check if any changes were made in your content, to decide if it should output a cached page or build a new one. Now, instead of having to loop through all your content folder (directories and images) to see if any changes were made, it only checks the timestamp of the /content folder. This is obviously MUCH faster, and will affect page speed both before and after cache. Now, when you make any changes from the panel, it will "touch" the /content folder, update the timestamp, and X3 pages will by this know if any changes were made.
By disabling this feature, "content" will not get an updated timestamp when you change anything in the panel, and X3 will not know when to serve "fresh" pages, instead of pages from the cache. In X3, the touch() feature never creates new files, but will simply update the timestamp of existing folder /content/.
sprocket wrote:Doing a little research I found THIS discussion on the touch command. Following user166560 advice (3rd answer listed), in the two php files that were giving me problems, filemanager_core.php [line 48] and menu_create.php [line 37], I changed the touch function to is_writable and all seems to work well now. I haven't played extensively with the panel on this home server, so not sure if the touch function is used elsewhere, that will give me further issues.
I don't see this as a solution, as it does not do anything, except disables the touch feature in X3. Your content folder needs to be writeable and have correct permissions, which sometimes also depend on the "owner" of the folder, which may be different from the www-user trying to modify it. I am not quite sure why it doesn't work ... Do you have a www link to this NAS version?