summaryrefslogtreecommitdiff
path: root/www-apps/gallery/files/0001-Fixing-PHP-7-issues.patch
blob: 43f047c86db5c842cdf95e3bf9763e1c2347552a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
From b180528e518ecd35c8f47e301db8d816f3ed480d Mon Sep 17 00:00:00 2001
From: Greg Stoll <greg@gregstoll.com>
Date: Tue, 28 Mar 2017 15:17:53 -0500
Subject: [PATCH 1/2] Fixing PHP 7 issues

The real fixes are replacing uses of preg_replace with the 'e' mode with
preg_replace_callback and the change to
modules/core/clases/GalleryStorage/GalleryStorageExtras to add {}.  The
rest is just declaring functions static to avoid noisy warning messages,
but there are plenty more that could be added.
---
 .gitignore                                         |  3 ++
 lib/adodb/adodb-time.inc.php                       |  1 -
 lib/adodb/adodb.inc.php                            |  2 +-
 lib/bbcode/stringparser.class.php                  |  2 +-
 lib/smarty/Smarty_Compiler.class.php               | 12 ++++-
 lib/support/GallerySetupUtilities.class            | 26 +++++-----
 modules/core/classes/GalleryCoreApi.class          | 16 +++---
 modules/core/classes/GalleryDataCache.class        | 16 +++---
 .../GalleryStorage/GalleryStorageExtras.class      |  2 +-
 modules/core/classes/GalleryUtilities.class        | 59 ++++++++++++----------
 10 files changed, 77 insertions(+), 62 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3503017
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+config.php
+login.txt
+*.swp
diff --git a/lib/adodb/adodb-time.inc.php b/lib/adodb/adodb-time.inc.php
index 575578c..eb6c415 100644
--- a/lib/adodb/adodb-time.inc.php
+++ b/lib/adodb/adodb-time.inc.php
@@ -1006,7 +1006,6 @@ function adodb_tz_offset($gmt,$isphp5)
 		return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); 
 	else
 		return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); 
-	break;
 }
 
 
diff --git a/lib/adodb/adodb.inc.php b/lib/adodb/adodb.inc.php
index 092e46e..2ff4486 100644
--- a/lib/adodb/adodb.inc.php
+++ b/lib/adodb/adodb.inc.php
@@ -373,7 +373,7 @@
 	* All error messages go through this bottleneck function.
 	* You can define your own handler by defining the function name in ADODB_OUTP.
 	*/
-	function outp($msg,$newline=true)
+	static function outp($msg,$newline=true)
 	{
 	global $ADODB_FLUSH,$ADODB_OUTP;
 	
diff --git a/lib/bbcode/stringparser.class.php b/lib/bbcode/stringparser.class.php
index 46f78f3..b0a0619 100644
--- a/lib/bbcode/stringparser.class.php
+++ b/lib/bbcode/stringparser.class.php
@@ -1248,7 +1248,7 @@ class StringParser_Node {
 	 * @param object $node The node to destroy
 	 * @return bool True on success, else false.
 	 */
-	function destroyNode (&$node) {
+	static function destroyNode (&$node) {
 		if ($node === null) {
 			return false;
 		}
diff --git a/lib/smarty/Smarty_Compiler.class.php b/lib/smarty/Smarty_Compiler.class.php
index f09f8de..a62c624 100644
--- a/lib/smarty/Smarty_Compiler.class.php
+++ b/lib/smarty/Smarty_Compiler.class.php
@@ -262,12 +262,20 @@ class Smarty_Compiler extends Smarty {
         reset($this->_folded_blocks);
 
         /* replace special blocks by "{php}" */
-        $source_content = preg_replace($search.'e', "'"
+        $source_content = preg_replace_callback($search, 
+                                        function($matches) {
+                                            return $this->_quote_replace($this->left_delimiter) . 'php'
+                                           . str_repeat("\n", substr_count($matches[0], "\n"))
+                                           . $this->_quote_replace($this->right_delimiter);
+                                        }
+                                       , $source_content);
+
+        /*$source_content = preg_replace($search.'e', "'"
                                        . $this->_quote_replace($this->left_delimiter) . 'php'
                                        . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
                                        . $this->_quote_replace($this->right_delimiter)
                                        . "'"
-                                       , $source_content);
+                                       , $source_content);*/
 
         /* Gather all template tags. */
         preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
diff --git a/lib/support/GallerySetupUtilities.class b/lib/support/GallerySetupUtilities.class
index 6a6da7b..4f8cc7e 100644
--- a/lib/support/GallerySetupUtilities.class
+++ b/lib/support/GallerySetupUtilities.class
@@ -54,7 +54,7 @@ class GallerySetupUtilities {
      *
      * @static
      */
-    function regenerateSession() {
+    static function regenerateSession() {
 	/* 1. Generate a new session id */
 	$newSessionId = md5(uniqid(substr(rand() . serialize($_REQUEST), 0, 114)));
 	$sessionData = array();
@@ -84,7 +84,7 @@ class GallerySetupUtilities {
      *
      * @static
      */
-    function areCookiesSupported() {
+    static function areCookiesSupported() {
 	static $areCookiesSupported;
 
 	/* Remember the state since we might unset $_COOKIE */
@@ -101,7 +101,7 @@ class GallerySetupUtilities {
      * @return int the number of attempts or false if there was an error
      * @static
      */
-    function getLoginAttempts() {
+    static function getLoginAttempts() {
 	/* Init if needed (like from lib/support; upgrader already init'ed) */
 	global $gallery;
 	if (!isset($gallery)) {
@@ -139,7 +139,7 @@ class GallerySetupUtilities {
      * @return true on success, false on error
      * @static
      */
-    function setLoginAttempts($attempts) {
+    static function setLoginAttempts($attempts) {
 	/* Init if needed (like from lib/support; upgrader already init'ed) */
 	global $gallery;
 	if (!isset($gallery)) {
@@ -182,7 +182,7 @@ class GallerySetupUtilities {
      * @param bool $updateDatabase true if you want to also reset the login attempts (default: true)
      * @static
      */
-    function authenticateThisSession($resetLoginAttempts=true) {
+    static function authenticateThisSession($resetLoginAttempts=true) {
 	$_SESSION['authenticated'] = true;
 	if ($resetLoginAttempts) {
 	    GallerySetupUtilities::setLoginAttempts(0);
@@ -196,7 +196,7 @@ class GallerySetupUtilities {
      * @return true if this session is authenticated
      * @static
      */
-    function isSessionAuthenticated() {
+    static function isSessionAuthenticated() {
 	return !empty($_SESSION['authenticated']);
     }
 
@@ -205,7 +205,7 @@ class GallerySetupUtilities {
      *
      * @static
      */
-    function redirectBackToSelf() {
+    static function redirectBackToSelf() {
 	require_once(dirname(__FILE__) . '/../../modules/core/classes/GalleryUrlGenerator.class');
 	$urlGenerator = new GalleryUrlGenerator();
 	$url = $urlGenerator->getCurrentUrl();
@@ -224,7 +224,7 @@ class GallerySetupUtilities {
      * @return string the path to the config dir
      * @static
      */
-    function getConfigDir() {
+    static function getConfigDir() {
 	if (defined('GALLERY_CONFIG_DIR')) {
 	    return GALLERY_CONFIG_DIR;
 	}
@@ -237,7 +237,7 @@ class GallerySetupUtilities {
      * @return array the config values from config.php
      * @static
      */
-    function getGalleryConfig() {
+    static function getGalleryConfig() {
 	$gallery = new GallerySetupUtilitiesStub();
 
 	/* Load config.php */
@@ -256,7 +256,7 @@ class GallerySetupUtilities {
      * @return string the authentication key
      * @static
      */
-    function getAuthenticationKey() {
+    static function getAuthenticationKey() {
 	return isset($_SESSION['authKey']) ? $_SESSION['authKey'] : null;
     }
 
@@ -265,7 +265,7 @@ class GallerySetupUtilities {
      * @param string $key the authentication key
      * @static
      */
-    function setAuthenticationKey($key) {
+    static function setAuthenticationKey($key) {
 	$_SESSION['authKey'] = $key;
     }
 
@@ -274,7 +274,7 @@ class GallerySetupUtilities {
      * @param string a random value
      * @static
      */
-    function generateAuthenticationKey() {
+    static function generateAuthenticationKey() {
 	for ($len = 64, $rand='';
 	     strlen($rand) < $len;
 	     $rand .= chr(!mt_rand(0,2) ? mt_rand(48,57) :
@@ -308,7 +308,7 @@ class GallerySetupUtilities {
      *
      * @static
      */
-    function startSession() {
+    static function startSession() {
 	/* Set our own session name */
 	if (@ini_get('session.auto_start')) {
 	    session_unset();
diff --git a/modules/core/classes/GalleryCoreApi.class b/modules/core/classes/GalleryCoreApi.class
index 6edcdf4..27d5b20 100644
--- a/modules/core/classes/GalleryCoreApi.class
+++ b/modules/core/classes/GalleryCoreApi.class
@@ -295,7 +295,7 @@ class GalleryCoreApi {
      * @return array GalleryStatus a status code
      *               string a value
      */
-    function getPluginParameter($pluginType, $pluginId, $parameterName, $itemId=0) {
+    static function getPluginParameter($pluginType, $pluginId, $parameterName, $itemId=0) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryPluginHelper_simple.class');
 	return GalleryPluginHelper_simple::getParameter($pluginType, $pluginId,
@@ -363,7 +363,7 @@ class GalleryCoreApi {
      *						     'requiredModuleApi' => array,
      *						     'version' => string)
      */
-    function fetchPluginStatus($pluginType, $ignoreCache=false) {
+    static function fetchPluginStatus($pluginType, $ignoreCache=false) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryPluginHelper_simple.class');
 	return GalleryPluginHelper_simple::fetchPluginStatus($pluginType, $ignoreCache);
@@ -376,7 +376,7 @@ class GalleryCoreApi {
      * @return array GalleryStatus a status code
      *               array of (pluginId => ('active' => boolean))
      */
-    function fetchPluginList($pluginType) {
+    static function fetchPluginList($pluginType) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryPluginHelper_simple.class');
 	return GalleryPluginHelper_simple::fetchPluginList($pluginType);
@@ -2355,7 +2355,7 @@ class GalleryCoreApi {
      *               mixed one GalleryEntity or an array of GalleryEntities
      * @deprecated $requiredEntityType will no longer be optional after the next major API change
      */
-    function loadEntitiesById($ids, $requiredEntityType=null) {
+    static function loadEntitiesById($ids, $requiredEntityType=null) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryEntityHelper_simple.class');
 	return GalleryEntityHelper_simple::loadEntitiesById($ids, $requiredEntityType);
@@ -2708,7 +2708,7 @@ class GalleryCoreApi {
      * @param string $sourceEncoding source encoding (eg. 'ISO-8859-1'), defaults to system charset
      * @return string the result
      */
-    function convertToUtf8($inputString, $sourceEncoding=null) {
+    static function convertToUtf8($inputString, $sourceEncoding=null) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryCharsetHelper_simple.class');
 	return GalleryCharsetHelper_simple::convertToUtf8($inputString, $sourceEncoding);
@@ -2734,7 +2734,7 @@ class GalleryCoreApi {
      * @param int $length the length of the substring, not optional
      * @return string a multibyte safe substring of input value
      */
-    function utf8Substring($string, $start, $length) {
+    static function utf8Substring($string, $start, $length) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryCharsetHelper_simple.class');
 	return GalleryCharsetHelper_simple::utf8Substring($string, $start, $length);
@@ -2747,7 +2747,7 @@ class GalleryCoreApi {
      * @param int $length the length in bytes (not in characters), not optional
      * @return string a multibyte safe substring of input value
      */
-    function utf8Strcut($string, $start, $length) {
+    static function utf8Strcut($string, $start, $length) {
 	GalleryCoreApi::requireOnce(
 	    'modules/core/classes/helpers/GalleryCharsetHelper_simple.class');
 	return GalleryCharsetHelper_simple::utf8Strcut($string, $start, $length);
@@ -2817,7 +2817,7 @@ class GalleryCoreApi {
      * @param string $file
      * @param boolean $skipBaseDirectoryDetection deprecated
      */
-    function requireOnce($file, $skipBaseDirectoryDetection=false) {
+    static function requireOnce($file, $skipBaseDirectoryDetection=false) {
 	static $loaded;
 	if (!isset($loaded[$file])) {
 	    $loaded[$file] = 1;
diff --git a/modules/core/classes/GalleryDataCache.class b/modules/core/classes/GalleryDataCache.class
index 07f26f4..dd6d5ec 100644
--- a/modules/core/classes/GalleryDataCache.class
+++ b/modules/core/classes/GalleryDataCache.class
@@ -40,7 +40,7 @@ class GalleryDataCache {
      * @staticvar cache the singleton cache
      * @access private
      */
-    function &_getCache() {
+    static function &_getCache() {
 	static $cache;
 	if (!isset($cache)) {
 	    $cache['maxKeys'] = 800;
@@ -81,7 +81,7 @@ class GalleryDataCache {
      * @param mixed $data
      * @param boolean $protected should this key survive a reset call?
      */
-    function put($key, $data, $protected=false) {
+    static function put($key, $data, $protected=false) {
 	$cache =& GalleryDataCache::_getCache();
 	if (!$cache['memoryCacheEnabled']) {
 	    return;
@@ -182,7 +182,7 @@ class GalleryDataCache {
      * @param string $key
      * @return mixed the cached data
      */
-    function get($key) {
+    static function get($key) {
 	$cache =& GalleryDataCache::_getCache();
 	if (!$cache['memoryCacheEnabled']) {
 	    return null;
@@ -199,7 +199,7 @@ class GalleryDataCache {
      * @param string $key
      * @return boolean true if the cache contains the key given
      */
-    function containsKey($key) {
+    static function containsKey($key) {
 	$cache =& GalleryDataCache::_getCache();
 	if (!$cache['memoryCacheEnabled']) {
 	    return false;
@@ -268,7 +268,7 @@ class GalleryDataCache {
      * @param array $pathInfo the path info
      * @return mixed object data
      */
-    function &getFromDisk($pathInfo) {
+    static function &getFromDisk($pathInfo) {
 	$null = null;
 	$cache =& GalleryDataCache::_getCache();
 	if (!$cache['fileCacheEnabled']) {
@@ -341,7 +341,7 @@ class GalleryDataCache {
      * @param array $requiredClasses classes that must be loaded in order to retrieve this data
      * @see GalleryDataCache::getCachePath
      */
-    function putToDisk($pathInfo, &$data, $requiredClasses=array()) {
+    static function putToDisk($pathInfo, &$data, $requiredClasses=array()) {
 	$cache =& GalleryDataCache::_getCache();
 	if (!$cache['fileCacheEnabled']) {
 	    return;
@@ -373,7 +373,7 @@ class GalleryDataCache {
      * @param int $id
      * @return array the tuple
      */
-    function getCacheTuple($id) {
+    static function getCacheTuple($id) {
 	$id = "$id";
 	if ($id > 100) {
 	    return array($id[0], $id[1]);
@@ -395,7 +395,7 @@ class GalleryDataCache {
      *
      * @return string the path
      */
-    function getCachePath($pathInfo) {
+    static function getCachePath($pathInfo) {
 	global $gallery;
 
 	$base = $gallery->getConfig('data.gallery.cache');
diff --git a/modules/core/classes/GalleryStorage/GalleryStorageExtras.class b/modules/core/classes/GalleryStorage/GalleryStorageExtras.class
index 9a12ecd..9214b8c 100644
--- a/modules/core/classes/GalleryStorage/GalleryStorageExtras.class
+++ b/modules/core/classes/GalleryStorage/GalleryStorageExtras.class
@@ -190,7 +190,7 @@ class GalleryStorageExtras /* the other half of GalleryStorage */ {
 			$value = $this->_gs->_normalizeValue($row[$i], $memberData[$i], true);
 
 			/* Store the value in the object */
-			$entity->$callbacks[$i] = $value;
+			$entity->{$callbacks[$i]} = $value;
 			$entity->_persistentStatus['originalValue'][$callbacks[$i]] = $value;
 		    }
 
diff --git a/modules/core/classes/GalleryUtilities.class b/modules/core/classes/GalleryUtilities.class
index 0e394fa..eeae67d 100644
--- a/modules/core/classes/GalleryUtilities.class
+++ b/modules/core/classes/GalleryUtilities.class
@@ -43,7 +43,7 @@ class GalleryUtilities {
      * @param string $filename
      * @return array the file basename, the file extension
      */
-    function getFileNameComponents($filename) {
+    static function getFileNameComponents($filename) {
 
 	$pos = strrpos($filename, '.');
 
@@ -69,7 +69,7 @@ class GalleryUtilities {
      * @param string $filename
      * @return array the file extension
      */
-    function getFileExtension($filename) {
+    static function getFileExtension($filename) {
 	list ($base, $extension) = GalleryUtilities::getFileNameComponents($filename);
 	return $extension;
     }
@@ -81,7 +81,7 @@ class GalleryUtilities {
      * @param string $filename
      * @return array the file base
      */
-    function getFileBase($filename) {
+    static function getFileBase($filename) {
 	list ($base, $extension) = GalleryUtilities::getFileNameComponents($filename);
 	return $base;
     }
@@ -92,7 +92,7 @@ class GalleryUtilities {
      * @param boolean $prefix (optional) false to omit Gallery variable prefix (not recommended)
      * @return array file data
      */
-    function getFile($key, $prefix=true) {
+    static function getFile($key, $prefix=true) {
 	$file = array();
 	if ($prefix) {
 	    $key = GALLERY_FORM_VARIABLE_PREFIX . $key;
@@ -235,7 +235,7 @@ class GalleryUtilities {
      * @param one or more string parameters
      * @return mixed a single string value or many values
      */
-    function getRequestVariables() {
+    static function getRequestVariables() {
 	$values = array();
 	foreach (func_get_args() as $argName) {
 	    $values[] = GalleryUtilities::_getRequestVariable(
@@ -255,7 +255,7 @@ class GalleryUtilities {
      * Return all request variables with the Gallery variable prefix.
      * @return array request variable name => value
      */
-    function getAllRequestVariables() {
+    static function getAllRequestVariables() {
 	$values = array();
 	$prefixLength = strlen(GALLERY_FORM_VARIABLE_PREFIX);
 	foreach ($_POST as $key => $value) {
@@ -283,7 +283,7 @@ class GalleryUtilities {
      * @param one or more string parameters
      * @return mixed a single string value or many values
      */
-    function getRequestVariablesNoPrefix() {
+    static function getRequestVariablesNoPrefix() {
 	$values = array();
 	foreach (func_get_args() as $argName) {
 	    $values[] = GalleryUtilities::_getRequestVariable($argName);
@@ -304,7 +304,7 @@ class GalleryUtilities {
      * @param string $value
      * @param boolean $prefix (optional) false to omit Gallery variable prefix (not recommended)
      */
-    function putRequestVariable($key, $value, $prefix=true) {
+    static function putRequestVariable($key, $value, $prefix=true) {
 	if ($prefix) {
 	    $key = GALLERY_FORM_VARIABLE_PREFIX . $key;
 	}
@@ -373,7 +373,7 @@ class GalleryUtilities {
      * @param array $array the source
      * @access private
      */
-    function _internalRemoveRequestVariable($keyPath, &$array) {
+    static function _internalRemoveRequestVariable($keyPath, &$array) {
 	$key = array_shift($keyPath);
 	while (!empty($keyPath)) {
 	    if (empty($array[$key])) {
@@ -401,7 +401,7 @@ class GalleryUtilities {
      * @param int $count the number of markers to return
      * @return string
      */
-    function makeMarkers($count, $markerFragment='?') {
+    static function makeMarkers($count, $markerFragment='?') {
 	if (is_array($count)) {
 	    $count = count($count);
 	}
@@ -427,7 +427,7 @@ class GalleryUtilities {
      * @param array $options (optional) options to pass to UrlGenerator
      * @return string a URL
      */
-    function convertPathToUrl($path, $options=array()) {
+    static function convertPathToUrl($path, $options=array()) {
 	global $gallery;
 	$platform =& $gallery->getPlatform();
 	$dirbase = $platform->realpath(dirname(__FILE__) . '/../../..') . '/';
@@ -458,7 +458,7 @@ class GalleryUtilities {
      * @param int $targetHeight (optional) target height, defaults to same as width
      * @return array(width, height)
      */
-    function shrinkDimensionsToFit($width, $height, $targetWidth, $targetHeight=null) {
+    static function shrinkDimensionsToFit($width, $height, $targetWidth, $targetHeight=null) {
 	if (!isset($targetHeight)) {
 	    $targetHeight = $targetWidth;
 	}
@@ -499,7 +499,7 @@ class GalleryUtilities {
      * @param int $precision defaults to zero
      * @return string rounded value
      */
-    function roundToString($floatValue, $precision=0) {
+    static function roundToString($floatValue, $precision=0) {
 	return str_replace(',', '.', round($floatValue, $precision));
     }
 
@@ -701,7 +701,7 @@ class GalleryUtilities {
      * @param boolean $adaptForMagicQuotes (optional) false to skip undoing the damage caused
      *                by magic_quotes
      */
-    function sanitizeInputValues(&$value, $adaptForMagicQuotes=true) {
+    static function sanitizeInputValues(&$value, $adaptForMagicQuotes=true) {
 	if (is_array($value)) {
 	    foreach (array_keys($value) as $key) {
 		$newKey = $key;
@@ -739,7 +739,7 @@ class GalleryUtilities {
      * @param boolean $adaptForMagicQuotes (optional) false to skip redoing the damage caused
      *                by magic_quotes
      */
-    function unsanitizeInputValues(&$value, $adaptForMagicQuotes=true) {
+    static function unsanitizeInputValues(&$value, $adaptForMagicQuotes=true) {
 	if (is_array($value)) {
 	    foreach (array_keys($value) as $key) {
 		GalleryUtilities::unsanitizeInputValues($value[$key], $adaptForMagicQuotes);
@@ -763,9 +763,14 @@ class GalleryUtilities {
      * @param string $string the input string with UTF-8 entities
      * @return string the UTF-8 string
      */
-    function unicodeEntitiesToUtf8($string) {
-	$string = preg_replace('/&#([xa-f\d]+);/mei',
-	    "GalleryUtilities::unicodeValueToUtf8Value('\\1')", $string);
+    static function unicodeEntitiesToUtf8($string) {
+	$string = preg_replace_callback('/&#([xa-f\d]+);/mi',
+        function($matches) {
+            return GalleryUtilities::unicodeValueToUtf8Value($matches[1]);
+        }
+        , $string);
+	/*$string = preg_replace('/&#([xa-f\d]+);/mei',
+	    "GalleryUtilities::unicodeValueToUtf8Value('\\1')", $string);*/
 	return $string;
     }
 
@@ -777,7 +782,7 @@ class GalleryUtilities {
      * @return string a multibyte safe substring of input value
      * @deprecated Please use GalleryCoreApi::utf8Substring instead
      */
-    function utf8Substring($string, $start, $length) {
+    static function utf8Substring($string, $start, $length) {
 	return GalleryCoreApi::utf8Substring($string, $start, $length);
     }
 
@@ -788,7 +793,7 @@ class GalleryUtilities {
      * @param int $num the unicode value
      * @return string the UTF-8 string
      */
-    function unicodeValueToUtf8Value($num) {
+    static function unicodeValueToUtf8Value($num) {
 	if ($num[0] == 'x') {
 	    /* Convert hex to decimal */
 	    $num = hexdec(substr($num, 1));
@@ -870,7 +875,7 @@ class GalleryUtilities {
      * @return string a single value
      * @access private
      */
-    function _getRequestVariable($key) {
+    static function _getRequestVariable($key) {
 	$keyPath = preg_split('/[\[\]]/', $key, -1, PREG_SPLIT_NO_EMPTY);
 	$result = GalleryUtilities::_internalGetRequestVariable($keyPath, $_GET);
 	if (isset($result)) {
@@ -889,7 +894,7 @@ class GalleryUtilities {
      * @return the value or null if it does not exist
      * @access private
      */
-    function _internalGetRequestVariable($keyPath, $array) {
+    static function _internalGetRequestVariable($keyPath, $array) {
 	$key = array_shift($keyPath);
 	while (!empty($keyPath)) {
 	    if (!isset($array[$key])) {
@@ -1001,7 +1006,7 @@ class GalleryUtilities {
      * Return the address of the remote host.
      * @return string the remote host address (or null)
      */
-    function getRemoteHostAddress() {
+    static function getRemoteHostAddress() {
 	$addr = null;
 	if (isset($_SERVER['REMOTE_ADDR'])) {
 	    $addr = $_SERVER['REMOTE_ADDR'];
@@ -1399,7 +1404,7 @@ class GalleryUtilities {
      * @param string $key the key in the _SERVER superglobal
      * @return string the value
      */
-    function getServerVar($key) {
+    static function getServerVar($key) {
 	if (!isset($_SERVER[$key])) {
 	    return null;
 	}
@@ -1432,7 +1437,7 @@ class GalleryUtilities {
      * @see Gallery::isEmbedded
      * @deprecated
      */
-    function isEmbedded() {
+    static function isEmbedded() {
 	global $gallery;
 	return $gallery->isEmbedded();
     }
@@ -1617,7 +1622,7 @@ class GalleryUtilities {
      * @param string $string
      * @return string lowercase version of the string
      */
-    function strToLower($string) {
+    static function strToLower($string) {
 	return strtr($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
     }
 
@@ -1626,7 +1631,7 @@ class GalleryUtilities {
      * @param string $string
      * @return string uppercase version of the string
      */
-    function strToUpper($string) {
+    static function strToUpper($string) {
 	return strtr($string, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
     }
 
-- 
2.13.1