Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

fetch() auf Windows

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
m[e]ntor
Smarty Rookie


Joined: 02 Jan 2007
Posts: 9

PostPosted: Mon May 27, 2013 9:28 am    Post subject: fetch() auf Windows Reply with quote

Hi,

ich hab ein ganz komisches Problem:

Auf meiner lokalen Entwicklungsumgebung hier im office läuft ein Zendserver auf Windows. Wenn ich an Templates was ändere, dann sehe ich beim nächsten Aufruf um CompileDir auch das neu erzeugte File, Smarty liefert mir aber noch die vorherige Version des Templates aus. D.h. ich brauche zwei Aufrufe, bis ich den richtigen Inhalt bekomme.

Das ist insofern etwas nervig, da ich SCSS und teilweise JS Files mit Smarty vorparse, bevor ich sie durch meine SASS/Compression Routinen schicke. Gerade bei den SCSS files, die dann in ein komprimiertes CSS File gepresst werden hab ich das Problem, dass die Erkennung der Änderung via md5_file im filesystem passiert, und ich hier eine Änderung zurückbekomme, aber noch die "alte" Rückgabe von Smarty.

Auf allen Productionservern, die alle auf Linuxsystemen basieren, hab ich das Problem nicht.

Hat irgendwer eine Idee, warum das gerade auf dem Windowsserver passiert, und wie ich das evtl abstellen könnte?

// Oliver
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon May 27, 2013 3:31 pm    Post subject: Reply with quote

Hallo Oliver

Das Problem könnte ein PHP Opcode Cache sein. Bei den kompilierten Templates handelt es sich um PHP Dateien, deren Opcode gegebenfalls gecached wird. Das PHP Caching muss so konfiguriert werden, das immer auf neuere Source geprüft wird.
Zendserver haben da so ihr eigenes Caching und mir kommt das Problem bei Zendservern bekannt vor, konnte aber nichts mehr dazu finden.

Ich meine mich zu erinnern das es sich genau um das gleiche Problem handelte und das Problem am Zendserver Opcode Cache lag.
Back to top
View user's profile Send private message
m[e]ntor
Smarty Rookie


Joined: 02 Jan 2007
Posts: 9

PostPosted: Mon May 27, 2013 5:24 pm    Post subject: Reply with quote

Hi Uwe,

danke für den Hinweis, ich hab den zend optimizer einfach mal testweise abgeschaltet und schon gehts.

// Oliver
Back to top
View user's profile Send private message Visit poster's website
oschonrock
Smarty Rookie


Joined: 08 Aug 2003
Posts: 13

PostPosted: Mon Sep 16, 2013 9:04 am    Post subject: geliches Problem Reply with quote

Seitdem ich von APC auf OPCACHE (also das neue open source Zend Accelerator) umgestellt habe, habe ich das gleiche Problem.

Sehr nervig, weil man oft Refresh drückt und sich dann denkt, warum geht es nicht? Grund, 2. Refresh erforderlich.

Ich guck da mal in den Smarty code rein, ob ich was finden kann.
Back to top
View user's profile Send private message
oschonrock
Smarty Rookie


Joined: 08 Aug 2003
Posts: 13

PostPosted: Mon Sep 16, 2013 9:06 am    Post subject: gleiches Problem Reply with quote

übrigens ist das Alles auf FreeBSD mit php 5.4.14 &&
smarty 3.1.14
Back to top
View user's profile Send private message
oschonrock
Smarty Rookie


Joined: 08 Aug 2003
Posts: 13

PostPosted: Mon Sep 16, 2013 10:48 am    Post subject: Reply with quote

soweit ich sehe ist das Problem hier:

Code:

smarty_internal_templatebase.php

                    if (!$_template->compiled->loaded) {
                        include($_template->compiled->filepath);
                        if ($_template->mustCompile) {
                            $_template->compileTemplateSource();
                            include($_template->compiled->filepath);


Hier wird der compilierte code zweimal "included", einmail bevor und einmail nach dem compilieren. Der Zend Opcache scheint seine "opcache.revalidate_freq" (die bei mir auf 0 ist, zum testen) aber nur einmal "pro request" zu checken.

Mit anderen Worten wenn man zweimal "include" macht und sich der Quelltext und file_timestamp zwischen dem ersten und zweiten include ändert, so wie hier, dann ignoriert der opcache das komplett, weil er meint er hätte es in diesem request schon gecheckt.

So klingt es auch hier...

Code:

http://www.php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq

opcache.revalidate_freq integer
How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.

This configuration directive is ignored if opcache.validate_timestamps if disabled.


Allerdings hat sich die Beschreibung für diese Stellschraube by github geändert:

Code:

https://github.com/zendtech/ZendOptimizerPlus/blob/master/README

opcache.revalidate_freq (default "2")
   How often (in seconds) to check file timestamps for changes to the shared
   memory storage allocation. ("1" means validate once per second, but only
   once per request. "0" means always validate)



Ich habe bis jetzt noch nicht heraus gefunden wann und ob sich da beim bei der neuesten github opcode version etwas geändert hat.
Back to top
View user's profile Send private message
oschonrock
Smarty Rookie


Joined: 08 Aug 2003
Posts: 13

PostPosted: Mon Sep 16, 2013 11:56 am    Post subject: Reply with quote

vielleicht habe ich dem opcache ein Unrecht getan. Habe einen kleinen Test geschrieben, der meine obige Hypothese _nicht_ bestätigt:

Code:

<?php

$filename = '/tmp/code.php';

function precise_date_str()
{
 
  $utime = microtime();
  $utime_pieces = explode(' ', $utime);
  $timestamp = (int)$utime_pieces[1];
  $usec = substr($utime_pieces[0], 2);
  return date('Y-m-d h:i:s', $timestamp) . '.' . $usec;
}

function print_filemtime($filename)
{
  clearstatcache(true, $filename);
  echo "filemtime($filename) = " . date('Y-m-d h:i:s', filemtime($filename)) . '<br/>';
}

function write_code($filename)
{
  $prec_date_str = precise_date_str();
  file_put_contents($filename,
    '<?php                                                                                                                                                                           
echo "this code was written at: ' . $prec_date_str . '<br/>";                                                                                                                       
');
  print_filemtime($filename);
}

// if you set this to one we get the same string twice                                                                                                                               
ini_set('opcache.revalidate_freq', '0');
echo 'opcache.revalidate_freq = ' . ini_get('opcache.revalidate_freq') . '<br/>';

// just to get set up for first run                                                                                                                                                 
if (!file_exists($filename))
{
  write_code($filename);
  // ensure the file timestamp will be more than 1s different!                                                                                                                       
  sleep(2);
}

print_filemtime($filename);
include $filename;
write_code($filename);
include $filename;



dabei kommt heraus, vorausgesetzt dass man nicht zu schnell refresh drückt (nicht mehr als einmal pro sekunde), dass der opcache sehr wohl den quelltext in /tmp/code.php neu einliest.

Code:

opcache.revalidate_freq = 0
filemtime(/tmp/code.php) = 2013-09-16 12:53:16
this code was written at: 2013-09-16 12:53:16.13608100
filemtime(/tmp/code.php) = 2013-09-16 12:53:19
this code was written at: 2013-09-16 12:53:19.60681100


Also wo liegt das Problem? Ist da doch bei Smarty irgendwie der Wurm drin?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Sep 16, 2013 6:48 pm    Post subject: Reply with quote

The fix is now in the SVN trunk and will later be included in 3.1.15
Back to top
View user's profile Send private message
m[e]ntor
Smarty Rookie


Joined: 02 Jan 2007
Posts: 9

PostPosted: Mon Sep 16, 2013 8:10 pm    Post subject: Reply with quote

@Uwe: geht das dann auch wieder mit zend optimizer?

//Oliver
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Sep 16, 2013 8:37 pm    Post subject: Reply with quote

Sollte auch mit dem zend optimizer funktionieren.

Ich kann es hier leider damit nicht testen.

Falls Du es probierst gib mir bitte ne Rückmeldung.
Back to top
View user's profile Send private message
oschonrock
Smarty Rookie


Joined: 08 Aug 2003
Posts: 13

PostPosted: Tue Sep 17, 2013 8:07 am    Post subject: Reply with quote

I benutze den Fix mit dem, jetzt open source, Zend Opcache:

http://pecl.php.net/package/ZendOpcache

ab php5.5 ist der mit im php tarball drin.

Es ist das gleiche wie das "closed source" commerzielle ZendOptimiser Product.

Funktioniert bei mir sehr gut jetzt.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Sep 17, 2013 7:23 pm    Post subject: Reply with quote

Ich habe hier die Tests mit PHP 5.5.3 durch geführt.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP