PHP parse error on string concat over 2 lines
-
Running FOG on CentOS 6. I’ve just done two things at once:
- Upgraded PHP 5.5.34 to 5.5.38
$ rpm -q php php-5.5.38-1.el6.remi.i686
- Upgraded FOG to trunk (1.3.0-RC-9, SVN Revision: 5952)
The upgrade failed with
Backing up database .... Failed!
/var/log/httpd/error_log:
PHP Parse error: syntax error, unexpected '.', expecting ',' or ';' in /var/www/html/fog/lib/fog/fogcontroller.class.php on line 106
After the following change I’ve managed to upgrade FOG successfully.
diff --git a/packages/web/lib/fog/fogcontroller.class.php b/packages/web/lib/fog/fogcontroller.class.php index bab94b2..ed59e42 100644 --- a/packages/web/lib/fog/fogcontroller.class.php +++ b/packages/web/lib/fog/fogcontroller.class.php @@ -102,8 +102,7 @@ abstract class FOGController extends FOGBase * * @var string */ - protected $insertQueryTemplate = "INSERT INTO `%s` (%s) " - . "VALUES (%s) ON DUPLICATE KEY UPDATE %s"; + protected $insertQueryTemplate = "INSERT INTO `%s` (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s"; /** * The delete query template to use. *
Best regards,
Sergey Romanov -
The concat is now fixed in RC 10.
-
Moved to bug reports as this seems to be one from my point of view. Just a simple one. Thanks for reporting!
-
I’m aware but unsure why this is an issue. Concat lines should work fine then again maybe a simple comma to separate might help?
These were separated because of psr-2 standards of which I’m trying to follow for more easily readable and follow able code.
-
I guess what you could try instead is (untested):
protected $insertQueryTemplate = "INSERT INTO `%s` (%s) "; protected $insertQueryTemplate .= "VALUES (%s) ON DUPLICATE KEY UPDATE %s";
Not very nice.
-
@Sebastian-Roth I don’t know if variable instantiation can be defined that way but I can try it.
-
It cannot be done that way. I suppose it’ll be simpler to have the one line over 85 characters (Sigh…).
-
The concat is now fixed in RC 10.
-
Well, I guess the ‘over two lines’ part is misleading and should be ‘when declaring a class property’ instead. It seems the ability to use scalar expressions in property declarations was only added in PHP 5.6.0. The only other possibility that would work in PHP 5.5.x in this context is heredoc/nowdoc:
protected $insertQueryTemplate = <<<EOT INSERT INTO `%s` (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s EOT;