Ticket #845: php53_patch.txt

File php53_patch.txt, 10.4 KB (added by craigmj, 3 years ago)

Patch to get Piwik running under PHP 5.3

Line 
1Index: plugins/Dashboard/Dashboard.php
2===================================================================
3--- plugins/Dashboard/Dashboard.php     (revision 1269)
4+++ plugins/Dashboard/Dashboard.php     (working copy)
5@@ -58,7 +58,7 @@
6                } catch(Zend_Db_Statement_Exception $e){
7                        // mysql code error 1050:table already exists
8                        // see bug #153 http://dev.piwik.org/trac/ticket/153
9-                       if(ereg('1050',$e->getMessage()))
10+                       if(preg_match('/1050/',$e->getMessage()))
11                        {
12                                return;
13                        }
14Index: plugins/ExampleFeedburner/ExampleFeedburner.php
15===================================================================
16--- plugins/ExampleFeedburner/ExampleFeedburner.php     (revision 1269)
17+++ plugins/ExampleFeedburner/ExampleFeedburner.php     (working copy)
18@@ -29,7 +29,7 @@
19                } catch(Zend_Db_Statement_Exception $e){
20                        // mysql code error 1060: column already exists
21                        // if there is another error we throw the exception, otherwise it is OK as we are simply reinstalling the plugin
22-                       if(!ereg('1060',$e->getMessage()))
23+                       if(!preg_match('/1060/',$e->getMessage()))
24                        {
25                                throw $e;
26                        }
27Index: plugins/Installation/Controller.php
28===================================================================
29--- plugins/Installation/Controller.php (revision 1269)
30+++ plugins/Installation/Controller.php (working copy)
31@@ -136,7 +136,7 @@
32                                        Piwik::createDatabaseObject($dbInfos);
33                                } catch (Zend_Db_Adapter_Exception $e) {
34                                        // database not found, we try to create  it
35-                                       if(ereg('[1049]',$e->getMessage() ))
36+                                       if(preg_match('/[1049]/',$e->getMessage() ))
37                                        {
38                                                $dbInfosConnectOnly = $dbInfos;
39                                                $dbInfosConnectOnly['dbname'] = null;
40@@ -489,7 +489,7 @@
41                {
42                    $gdInfo = gd_info();
43                        $infos['gd_version'] = $gdInfo['GD Version'];
44-                   ereg ("([0-9]{1})", $gdInfo['GD Version'], $gdVersion);
45+                   preg_match ("/([0-9]{1})/", $gdInfo['GD Version'], $gdVersion);
46                    if($gdVersion[0] >= 2)
47                    {
48                                $infos['gd_ok'] = true;
49Index: plugins/CoreHome/templates/piwik_tag.tpl
50===================================================================
51--- plugins/CoreHome/templates/piwik_tag.tpl    (revision 1269)
52+++ plugins/CoreHome/templates/piwik_tag.tpl    (working copy)
53@@ -1,4 +1,4 @@
54-{if ereg('http://127.0.0.1|http://localhost|http://piwik.org', $url)}
55+{if preg_match('/http:\/\/127.0.0.1|http:\/\/localhost|http:\/\/piwik.org/', $url)}
56 <div style="clear:both"></div>
57 {literal}
58 <!-- Piwik -->
59Index: plugins/LanguagesManager/LanguagesManager.php
60===================================================================
61--- plugins/LanguagesManager/LanguagesManager.php       (revision 1269)
62+++ plugins/LanguagesManager/LanguagesManager.php       (working copy)
63@@ -68,7 +68,7 @@
64                } catch(Zend_Db_Statement_Exception $e){
65                        // mysql code error 1050:table already exists
66                        // see bug #153 http://dev.piwik.org/trac/ticket/153
67-                       if(ereg('1050',$e->getMessage()))
68+                       if(preg_match('/1050/',$e->getMessage()))
69                        {
70                                return;
71                        }
72Index: core/Period/Range.php
73===================================================================
74--- core/Period/Range.php       (revision 1269)
75+++ core/Period/Range.php       (working copy)
76@@ -112,7 +112,7 @@
77                }
78                parent::generate();
79               
80-               if(ereg('(last|previous)([0-9]*)', $this->strDate, $regs))
81+               if(preg_match('/(last|previous)([0-9]*)/', $this->strDate, $regs))
82                {
83                        $lastN = $regs[2];
84                        $lastOrPrevious = $regs[1];
85@@ -141,7 +141,7 @@
86                       
87                        $startDate = $this->removePeriod($endDate, $lastN);
88                }
89-               elseif(ereg('([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}),([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})', $this->strDate, $regs))
90+               elseif(preg_match('/([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}),([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})/', $this->strDate, $regs))
91                {
92                        $strDateStart = $regs[1];
93                        $strDateEnd = $regs[2];
94
95Index: core/API/DocumentationGenerator.php
96===================================================================
97--- core/API/DocumentationGenerator.php (revision 1269)
98+++ core/API/DocumentationGenerator.php (working copy)
99@@ -67,7 +67,10 @@
100                                        if($exampleUrl !== false)
101                                        {
102                                                $lastNUrls = '';
103-                                               if( ereg('(&period)|(&date)',$exampleUrl))
104+                                               /**
105+                                                * @TODO TODO Somebody should check this regex with pregex
106+                                                */
107+                                               if( preg_match('/(&period)|(&date)/',$exampleUrl))
108                                                {
109                                                        $exampleUrlRss1 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last10') + $parametersToSet) ;
110                                                        $exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last5','period' => 'week',) + $parametersToSet );
111Index: core/PluginsFunctions/Menu.php
112===================================================================
113--- core/PluginsFunctions/Menu.php      (revision 1269)
114+++ core/PluginsFunctions/Menu.php      (working copy)
115@@ -165,8 +165,8 @@
116                                // we want to move some submenus in the first position
117                                foreach($element as $nameSubmenu => $submenu)
118                                {
119-                                       if(ereg('Evolution', $nameSubmenu) !== false
120-                                               || ereg('Overview', $nameSubmenu) !== false)
121+                                       if(preg_match('/Evolution/', $nameSubmenu) !== false
122+                                               || preg_match('/Overview/', $nameSubmenu) !== false)
123                                        {
124                                                $newElement = array($nameSubmenu => $submenu);
125                                                unset($element[$nameSubmenu]);
126Index: core/TablePartitioning.php
127===================================================================
128--- core/TablePartitioning.php  (revision 1269)
129+++ core/TablePartitioning.php  (working copy)
130@@ -86,7 +86,7 @@
131                }
132        }
133       
134-       protected function __toString()
135+       public function __toString()
136        {
137                return $this->getTableName();
138        }
139Index: core/Archive.php
140===================================================================
141--- core/Archive.php    (revision 1269)
142+++ core/Archive.php    (working copy)
143@@ -141,8 +141,8 @@
144                // if a period date string is detected: either 'last30', 'previous10' or 'YYYY-MM-DD,YYYY-MM-DD'
145                elseif(is_string($strDate)
146                        && (
147-                               ereg('^(last|previous){1}([0-9]*)$', $strDate, $regs)
148-                               || ereg('^([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}),([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})$', $strDate, $regs)
149+                               preg_match('/^(last|previous){1}([0-9]*)$/', $strDate, $regs)
150+                               || preg_match('/^([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}),([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})$/', $strDate, $regs)
151                                )
152                        )
153                {
154Index: core/Piwik.php
155===================================================================
156--- core/Piwik.php      (revision 1269)
157+++ core/Piwik.php      (working copy)
158@@ -85,7 +85,7 @@
159                $resultCheck = array();
160                foreach($directoriesToCheck as $directoryToCheck)
161                {
162-                       if( !ereg('^'.preg_quote(PIWIK_INCLUDE_PATH), $directoryToCheck) )
163+                       if( !preg_match('/^'.preg_quote(PIWIK_INCLUDE_PATH, '/').'/', $directoryToCheck) )
164                        {
165                                $directoryToCheck = PIWIK_INCLUDE_PATH . $directoryToCheck;
166                        }
167@@ -1299,14 +1299,14 @@
168                $tablesAlreadyInstalled = self::getTablesInstalled();
169                $db = Zend_Registry::get('db');
170               
171-               $doNotDeletePattern = "(".implode("|",$doNotDelete).")";
172+               $doNotDeletePattern = "/(".implode("|",$doNotDelete).")/";
173               
174                foreach($tablesAlreadyInstalled as $tableName)
175                {
176                       
177                        if( count($doNotDelete) == 0
178                                || (!in_array($tableName,$doNotDelete)
179-                                       && !ereg($doNotDeletePattern,$tableName)
180+                                       && !preg_match($doNotDeletePattern,$tableName)
181                                        )
182                                )
183                        {
184Index: libs/Event/Dispatcher.php
185===================================================================
186--- libs/Event/Dispatcher.php   (revision 1269)
187+++ libs/Event/Dispatcher.php   (working copy)
188@@ -268,8 +268,12 @@
189         if ($pending === true) {
190             $this->_pending[$nName][] =& $notification;
191         }
192-        $objClass = get_class($notification->getNotificationObject());
193-
194+        if ($notification!=null && $notification->getNotificationObject()!=null) {
195+               $objClass = get_class($notification->getNotificationObject());
196+               } else {
197+                       $objClass = null;
198+               }
199+               
200         // Find the registered observers
201         if (isset($this->_ro[$nName])) {
202             foreach (array_keys($this->_ro[$nName]) as $k) {
203Index: index.php
204===================================================================
205--- index.php   (revision 1269)
206+++ index.php   (working copy)
207@@ -33,7 +33,9 @@
208 require_once "core/testMinimumPhpVersion.php";
209 
210 // NOTE: the code above this comment must be PHP4 compatible
211+$oldErrorReporting = error_reporting(0);
212 date_default_timezone_set(date_default_timezone_get());
213+error_reporting($oldErrorReporting);
214 
215 if(!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER)
216 {
217Index: tests/core/Tracker/Action.test.php
218===================================================================
219--- tests/core/Tracker/Action.test.php  (revision 1269)
220+++ tests/core/Tracker/Action.test.php  (working copy)
221@@ -84,6 +84,13 @@
222                                                                                'url' => 'http://example.org/category/test///test  wOw',
223                                                                                'type' => Piwik_Tracker_Action::TYPE_ACTION),
224                        ),
225+                       // testing: inclusion of zero values in action name
226+                       array (
227+                               'request'=>array( 'url' => "http://example.org/category/1/0/t/test"),
228+                               'expected'=>array(      'name'  => 'category/1/0/t/test',
229+                                                                       'url'   => 'http://example.org/category/1/0/t/test',
230+                                                                       'type'  => Piwik_Tracker_Action::TYPE_ACTION),
231+                       ),
232                );
233                foreach($tests as $test) {
234                        $request = $test['request'];
235Index: config/global.ini.php
236===================================================================
237--- config/global.ini.php       (revision 1269)
238+++ config/global.ini.php       (working copy)
239@@ -69,7 +69,7 @@
240 action_category_delimiter = /
241 
242 ; currency used by default when reporting money in Piwik
243-default_currency = "$"
244+default_currency = '$'
245 
246 ; if you want all your users to use Piwik in only one language, disable the LanguagesManager
247 ; plugin, and set this default_language (users won't see the language drop down)
248@@ -103,7 +103,7 @@
249 
250 ; email address that appears as a Sender in the password recovery email
251 ; if specified, {DOMAIN} will be replaced by the current Piwik domain
252-login_password_recovery_email_address = "password-recovery@{DOMAIN}"
253+login_password_recovery_email_address = 'password-recovery@{DOMAIN}'
254 
255 ; name that appears as a Sender in the password recovery email
256 login_password_recovery_email_name = Piwik
257@@ -142,7 +142,7 @@
258 ; However when most users have the same IP, and the same configuration, it is advised to set it to 0
259 enable_detect_unique_visitor_using_settings = 1
260 
261-; if set to 1, Piwik attempts a "best guess" at the visitor's country of
262+; if set to 1, Piwik attempts a 'best guess' at the visitor's country of
263 ; origin when the preferred language tag omits region information.
264 ; The mapping is defined in core/DataFiles/LanguageToCountry.php,
265 enable_language_to_country_guess = 1