Setting Timezone in KiwiTCMS - kiwi-tcms

We are currently trying to implement KiwiTCMS into our workflow with docker. We've seen that it should be possible to change the timezone in KiwiTCMS by either changing the environment variable KIWI_TIME_ZONE or TIME_ZONE in the settings.
We therefore tried either setting the environment variable inside the docker-compose.yml as KIWI_TIME_ZONE: Europe/Berlin or adding a settings file as a volume where TIME_ZONE = 'Europe/Berlin'.
We've added the settingsfile called default_config.py into the docker-compose.yml as follows:
volumes:
- ./my_settings_dir/default_config.py:/venv/lib64/python3.8/site-packages/tcms_settings_dir/default_config.py
The volume looks to be implemented correctly because other settings we change inside the same file work. But setting the timezone variable in either of those files only changes the name of the timezone next to the clock to Europe/Berlin but neither the time of the clock nor the time of the last userlogin change, they still show the UTC time.
The time of the server that is running the docker containers and the time of both docker containers (DB and Kiwi) is set to Europe/Berlin so that shouldn't be the issue.
We've seen that there was a GitHub issue around three years ago that mentioned the same problem and there were a few commits to fix that issue but somehow it still doesn't work for us.
So now we're not sure if our implementation is wrong or if it's something else that prevents us from changing the timezone.

But setting the timezone variable in either of those files only
changes the name of the timezone next to the clock to Europe/Berlin
but neither the time of the clock
nor the time of the last userlogin
change, they still show the UTC time.
Does the value of the web based clock match the value reported by date inside the container? You need to post the actual values so we can see what's happening.
If they don't match that likely means container isn't configured appropriately for the local timezone.

We resolved the problem, thanks to eddywu on GitHub.
The solution was to set KIWI_USE_TZ: "True" in the docker-compose.yml. You could probably also set USE_TZ = True in the settings file.

Related

Issue Clearing cache in Chrome

I have a Java/Spring MVC WebApp using Angular as the Front End. The ui application is deployed as part of the web app in the src>main>webapp folder. The problem is when I make any changes in the CSS or HTML files, the same are not reflected instantaneously. I have tried clearing cache and hard resetting also but to no avail.
I tried running the app in incognito mode too but it does not work.
Please help.
Specific resources can be reloaded individually if you change the date and time on your files on the server. "Clearing cache" is not as easy as it should be. Instead of clearing cache on my browsers, I realized that "touching" the server files cached will actually change the date and time of the source file cached on the server (Tested on Edge, Chrome and Firefox) and most browsers will automatically download the most current fresh copy of whats on your server (code, graphics any multimedia too). I suggest you just copy the most current scripts on the server and "do the touch thing" solution before your program runs, so it will change the date of all your problem files to a most current date and time, then it downloads a fresh copy to your browser:
<?php
touch('/www/sample/file1.css');
touch('/www/sample/file2.css');
touch('/www/sample/file2.css');
?>
then ... the rest of your program...
It took me some time to resolve this issue (as many browsers act differently to different commands, but they all check time of files and compare to your downloaded copy in your browser, if different date and time, will do the refresh), If you can't go the supposed right way, there is always another usable and better solution to it. Best Regards and happy camping. By the way touch(); or alternatives work in many programming languages inclusive in javascript bash sh php and you can include or call them in html.

How to set "cache dependency" to local storage

We are using local storage module from angularjs.
https://github.com/grevory/angular-local-storage
Now can anybody suggest how we can set a cache dependency at client side, so that when data changes in the server the local storage is invalidated(forcing to fetch data afresh from server).
Right now in test environment, we had to ask the testers to clear browser cache each time there is a release. Cant move with this approach in production.
Thanks for helping.
Setup a version number in your app, and store it in the local storage when the user visits.
When the app is initialised, compare the local storage version with the App.version.
If it's different, clear local storage and re-render, reload, re-initialise or whatever you need to do for your app.
To handle the situation where a user has used your app before you implemented this behaviour, simply ensure it also clears local storage if it cannot find a version key in local storage to begin with.
Just a couple of further notes, relating to the comments.
I've had issues in the past with local storage due to different things happening. Part 3 goes beyond the scope of the question but is worth mentioning for completeness.
A new release: the application source code has changed, and the data it's storing is structured differently. Perhaps it's now JSON.stringified, for example. Or perhaps we were expecting a string and now we get an integer, which might break something with strict type checking.
This is solved using the approach described above. The app has changed, so the app has a new version, and it knows it cannot trust the data retrieved from local storage for a different version.
The problem you describe: the data on the server has been updated and the app's locally stored copy is out of date.
How do we tell the app that things have changed? Periodically request some token from the server, perhaps a timestamp, that we can compare to see if there was a change since we last accessed the data. This question talks about a number of different ways to do this.
The JavaScript itself has changed: we have a minified production build and now there is a new one, but the user still has the old build cached. This is a problem when the server is expecting different requests to what it will now receive from the new build.
The simple solution here is to tack a version number of some kind onto the end of the resource URL, so that the browser requests application.min.js?v=2 instead of application.min.js?v=1.

Clearing the cakephp tmp/cache solves the issue for only one save call. What can be the reason?

I modified the schema of mysql database(added a new table etc.), I cleared the tmp/cache(except directories).
Now the save in the new table happens only once(I have multiple save calls in a for loop and save happens for all of them) and fails from next time I enter the flow.
I am using cakephp 1.3.
What else should I check ?
Got it.
The cache issue was one part of the problem, which got fixed by clearing the files in tmp/cache directory.
Learning is -
If you make mysql schema changes(add new table / column etc.) in mysql, either clear the tmp/cache directory or set the debug level as 3 and refresh the page and set the debug level again to 0(if on production).
I was also getting a save error - mysql server has gone away, because in configs the wait_timeout value was 600 seconds. But my script was taking longer than that.
So model->save() was not working.
In my.cnf I updated the timeout to 4800 and restarted mysql and it fixed the problem.

Cake PHP timezone wrong

I got a strange problem with Cake. I live in Germany. When I add posts the time in the "created" database-field is 6 hours back. E.g. a post created 6pm shows up in the database as created 12am.
I use a managed server and I contacted the company which set the php.ini to the correct timezone Europe/Berlin. When I request the servers php.ini, it shows the timezone "Europe/Berlin" correctly. But when I run the code
$timezone = date_default_timezone_get();
echo "The current server timezone is: " . $timezone;
in CakePHP it shows
The current server timezone is: America/New_York
I already tried to set in the core.php:
date_default_timezone_set('Europe/Berlin');
But that has no effect at all.
Hopefully someone knows what to do.
EDIT 1:
After asking the support to run "locale -a", following was spit out:
# locale -a
C
de_DE
de_DE#euro
de_DE.iso88591
de_DE.iso885915#euro
de_DE.utf8
deutsch
en_US.utf8
german
POSIX
I assume that serverside everything is fine and the error is cake-wise.
But I donĀ“t have a clue what to do next? Maybe someone can help. Thanks in advance.
** EDIT 2: **
After looking around what it could be I found the error in the bootstrap.php of the Usermanagement-plugin, which set the timezone there to UTC. So everything works fine now. Thanks for your help anyway.
Edit:
If doing the answer below has no effect (per OP), it could be this issue:
Is is quite likely that the German locale is not installed on the
server your running the script on - do you have shell access to the
server? Then try
locale -a
to see which locales are installed. Also have a look here Is
it feasible to rely on setlocale, and rely on locales being installed?
TLDR:
You had the right idea - just put it in your Config/bootstrap.php. instead of your Config/core.php.
More Detail:
This is likely the same as this question. It's answer:
Put this in your Config/bootstrap.php:
date_default_timezone_set('UTC'); //or whatever your timezone is
It's just based on the server time and really has nothing to do with
CakePHP - so just change the default timezone with PHP, and you should
be good to go. 'created' and 'modified' will be based on the specified
timezone.
To reiterate, the "created" and "modified" fields ARE based on the server and really don't have much to do with CakePHP (which it sounds like you already assumed correctly).
A related item (just fyi to read up on) is CakeTime::convert(), but in this case, is not what you'd want.
Set in app_controller not in code.php
Problem solved. The problem was in a plugin which also had a config.php. There the Cake-config was overwritten. Now everything is fine.

how to change timezone setting in Lucid Work Enterprises

I have installed Lucid Work Enterprises and notice that its displaying time of UTC zone. But my system timezone is UTC+05:30. so there is always a difference in my database last_modified field value for delta query for indexing (as there is 5:30 Hrs difference in Lucid admin timezone and my database timezone).
I tried to change a setting in start.bat file from
"set MISC_OPTS2=-Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8"
to
"set MISC_OPTS2=-Duser.language=en -Duser.country=US -Duser.timezone=UTC+05:30 -Dfile.encoding=UTF-8"
But it doesn't make any difference.
I am unable to find a way to change timezone setting in Lucid admin area. Even there was no option to select timezone in installation wizard.
Please help me that how i can change this timezone setting for Lucid.
Thanks in advance
I had a similar issue using lucen/solr (without LWE). At solr ther is (also) no way to configure the timezone. Asking an Partner from "Lucid imagination" how to handle time-zones with lucene/solr, i get the answer: change timezone-settings at your J2EE servlet container options.
But as you said:
But it doesn't make any difference.
My workaround is realized by the application, which handles the "time-zone-difference" between lucene- and database timestamp. Not sure, which programming language you are using. PHP for example provides nice build-in functionality for handling dateTime objects and different timezones.

Resources