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

Problem with variable template and cache

 
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 -> General
View previous topic :: View next topic  
Author Message
Tweester
Smarty n00b


Joined: 19 Feb 2018
Posts: 2

PostPosted: Mon Feb 19, 2018 8:30 pm    Post subject: Problem with variable template and cache Reply with quote

Hey guys,

In start, I want apologize for my simple English, but I don't use this language everyday, so I've hope that you want by angry Wink

Ok, I have problem with Smarty - excatly with path to templates. I created page on serwer where I have PHP 7.0.27, but at last webpage must be on server where I have PHP 5.2. To define path I use:

Code:
        $smarty->setTemplateDir('DIR_VIEWS');
        $smarty->setCacheDir(DIR_WEBSITE . "templates/Cache/");
        $smarty->setCompileDir(DIR_WEBSITE . "templates/Compile/");


and I works. But when I upload files to second server I have a problem with path. My code:


Code:

/*
            $this->smarty->setTemplateDir ('/sss');
            $this->smarty->setCacheDir ('/ttt');
            $this->smarty->setCompileDir ('/ccc');

*/
            $this->smarty->setTemplateDir = '/sss';
            $this->smarty->setCacheDir = '/ttt';
            $this->smarty->setCompileDir = '/ccc';
           
            $temp = $this->smarty->getCacheDir();
            var_dump($temp);
           
            $this->smarty->testInstall();


and result is:

Code:
string(38) "/home/students/OS/samorzad/WWW/ss2018/"
Smarty Installation test...
Testing template directory...
/home/students/OS/samorzad/WWW/ss2018 is OK.
Testing compile directory...
/home/students/OS/samorzad/WWW/ss2018 is OK.
Testing plugins directory...
/home/students/OS/samorzad/WWW/ss2018 is OK.
WARNING: Smarty's own libs/plugins is not available.
Testing cache directory...
/home/students/OS/samorzad/WWW/ss2018 is OK.
Testing configs directory...
/home/students/OS/samorzad/WWW/ss2018/ is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.


Why I don't have 'sss' for TemplateDir, 'ttt' for CacheDir etc? Maybe you know where I can have a bug?

http://www.samorzad.umk.pl/ss2018/phpinfo.php
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Tue Feb 20, 2018 8:32 am    Post subject: Reply with quote

This works:
Code:
$this->smarty->setTemplateDir ('/sss');

because '/sss' is an argument for a function.

This does not work:
Code:
$this->smarty->setTemplateDir = '/sss';

because '/sss' is a value for a variable.

setTemplate() is a function.

Next, '/sss' is at the root of your server. You may be wanting a folder within your website:
Code:
$this->smarty->setTemplateDir (DIR_WEBSITE.'/sss');
Back to top
View user's profile Send private message
Tweester
Smarty n00b


Joined: 19 Feb 2018
Posts: 2

PostPosted: Tue Feb 20, 2018 11:28 am    Post subject: Reply with quote

I know that is an argument for a function, and I tried this soultion, and still I have this same resault. I forget to say (because I have error_reporting(E_ERROR | E_PARSE)), that I have this error:

Code:
Warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 4 in /home/students/OS/samorzad/WWW/ss2018/libraries/Smarty-3.1.30/libs/Smarty.class.php on line 1207


I also try in PHP 5.5 and all works fine.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Feb 20, 2018 2:20 pm    Post subject: Reply with quote

http://php.net/eol.php

Using a long abandoned, unsupported version of software is prone to mysterious errors like that.
Nobody know what's going on in the mammoth's dump.

Also, Smarty is at 3.1.31 now.

Said all that,
Tweester wrote:
I know that is an argument for a function

If you know that, then provide your actual code.
Nobody can debug code based on elaborate narratives alone.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Tue Feb 20, 2018 5:15 pm    Post subject: Reply with quote

The error is referring to this statement:
Code:
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%',

Researching this error suggests that your new server environment may be running:
* CentOS, and/or
* PHP 5.3 or earlier, and/or
* PHP using a PCRE library version less than 8.0

Have PHP show you the results of phpinfo() and look for the pcre table. If the version is less than 8.0, you may need to have your server administrators upgrade the version of PHP.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Tue Feb 20, 2018 5:53 pm    Post subject: Reply with quote

More research strongly hints that the PHP on that server has been compiled with PCRE of a version older than 8.0.

You can either insist your server administrators install a version of PHP compiled with the latest version PCRE library, or make the following edit to that statement mentioned earlier:
Code:
/Smarty-3.1.30/libs/Smarty.class.php on line 1207
From:
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%',

To:
preg_match('%^(?P<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?P<path>(?:[[:print:]]*))$%',

Modifying Smarty library code means you will need to keep a log about this edit so that when the application gets upgraded, to re-apply this edit. And there may be other instances of this function's syntax elsewhere - to be exposed at some later time.
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 -> General 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