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

Smarty 3 migratin woes
Goto page Previous  1, 2
 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
andig
Smarty Regular


Joined: 22 Apr 2004
Posts: 48

PostPosted: Fri Feb 26, 2010 12:39 pm    Post subject: Reply with quote

Hi Uwe, Monty,

as our other attempts were not successful, I'd like to digg deeper into the compile error. Is there a place I should look to see which functions the compiler should recognize (e.g. an array of function names or similar) that I could var_dump to see if it's more a compiler-thing or happens previously when gathering the plugins from disk?

Best regards,
Andreas
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Feb 26, 2010 12:47 pm    Post subject: Reply with quote

Andrea

I just saw by FTP that you still have an old Smarty version in the /lib/smarty folder
Back to top
View user's profile Send private message
andig
Smarty Regular


Joined: 22 Apr 2004
Posts: 48

PostPosted: Fri Feb 26, 2010 12:53 pm    Post subject: Reply with quote

Digging into the template compiler I'm seeing that the getPlugin function is called with different arguments depending on the machine (Win/local, Linux/hosted) it's being called:

local working: getPlugin(html_image, function)
hosted broken: getPlugin(html_, block)
Back to top
View user's profile Send private message
andig
Smarty Regular


Joined: 22 Apr 2004
Posts: 48

PostPosted: Fri Feb 26, 2010 1:00 pm    Post subject: Reply with quote

Wondering what this error/ line in the compiler base is doing on the server:

Warning: substr_compare() [function.substr-compare]: The start position cannot exceed initial string length in /hp/aa/ad/gq/www/cpuidle-de/videodb/lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 145

// not an internal compiler tag
if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) {

Why should the comparison index be -5? The php docs do not mention this case. Is strlen-5 the desired position? maybe we're seeing a php bug here?

Best regards,
Andreas
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Feb 26, 2010 1:07 pm    Post subject: Reply with quote

PHP documentation says :
The start position for the comparison. If negative, it starts counting from the end of the string.

What PHP version do you work with?
Back to top
View user's profile Send private message
andig
Smarty Regular


Joined: 22 Apr 2004
Posts: 48

PostPosted: Fri Feb 26, 2010 1:08 pm    Post subject: Reply with quote

Even this does still print the warning, so the -5 index is not the problem:

if (strlen($tag) < 6 || substr_compare($tag, 'close', strlen($tag)-5, 5) != 0) {

Still, I think the problem is substr_compare. PHP doc says:

Returns < 0 if main_str from position offset is less than str, > 0 if it is greater than str, and 0 if they are equal. If length is equal or greater than length of main_str and length is set, substr_compare() prints warning and returns FALSE.

What I believe happens is that html_image (10 chars) is compared from pos. 5 for 5 chars (which should be valid), yet PHP shows the warning and returns FALSE -> hence plugin is not found. PHP does actually not comply with docs in this case.

Will fup with php.net
Back to top
View user's profile Send private message
andig
Smarty Regular


Joined: 22 Apr 2004
Posts: 48

PostPosted: Fri Feb 26, 2010 2:18 pm    Post subject: Reply with quote

My last suspicion seems to be confirmed: http://bugs.php.net/bug.php?id=37394

The docs however are still wrong as they do not take the case of offset+length = strlen into account:

"If offset is equal to or greater than the length of main_str or length is set and is less than 1, substr_compare() prints a warning and returns FALSE."

Best regards,
Andreas
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Feb 26, 2010 2:32 pm    Post subject: Reply with quote

So you should update the PHP version...
Back to top
View user's profile Send private message
andig
Smarty Regular


Joined: 22 Apr 2004
Posts: 48

PostPosted: Fri Feb 26, 2010 2:35 pm    Post subject: Reply with quote

Sure. Now explain that to my provider...

For now this works fine:

if (strlen($tag) < 6 || strncmp(substr($tag, -5), 'close', 5) != 0) {

again- thank you for the great support!

Best regards,
Andreas
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 -> Smarty 3 All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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