Bug 5240

Summary: Need to rename Locale class to avoid PHP 5.3 namespace collisions
Product: OJS Reporter: Matthew Crider <mattcrider>
Component: LocalizationAssignee: PKP Support <pkp-support>
Status: RESOLVED FIXED    
Severity: normal CC: alec, dcebrian, fozturk, michal.rydlo, misho, mysql.jorge, peter.marquardt
Priority: P5    
Version: 2.3.7   
Hardware: PC   
OS: Mac OS X 10.3   
Version Reported In: Also Affects:

Description Matthew Crider 2010-03-19 15:25:02 PDT
PHP 5.3 now includes a core internationalization extension (see <http://devzone.zend.com/article/4799>), central to which belongs a 'Locale' class.  We'll have to rename our Locale class for the two to coexist.

Brought up thanks to <http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=5729&p=22438#p22438>.
Comment 1 Alec Smecher 2010-07-20 12:45:06 PDT
Deferring. This may indeed only apply to PHP installs including the optional i18n extension.
Comment 2 Alec Smecher 2011-04-05 09:00:15 PDT
*** Bug 6567 has been marked as a duplicate of this bug. ***
Comment 3 Peter Marquardt 2011-08-02 15:14:31 PDT
i18n isn't optional in PHP 5.3, it's bundled and enabled in the default installation.
Comment 4 Alec Smecher 2011-08-02 16:35:18 PDT
Peter, looking at php.ini-production and php.ini-development in the PHP 5.3.6 source distribution, the intl extension is disabled by default in both; likewise for the Windows binary package. I suspect you're using something like XAMPP with a non-stock default php.ini.
Comment 5 Peter Marquardt 2011-08-02 18:26:59 PDT
Alec, you're right, it's not enabled in php.net's source. I'm not using XAMPP. My dev server runs arch linux and the production server is CentOS (managed by the hosting company), on both it is enabled. I'm not sure if I enabled it myself on my dev server, but I definitely didn't on the production server. I had a look at a different server I manage, a shared hosting environment running debian and it's enabled there, too. As it is bundled from PHP 5.3 onwards and not a PECL lib anymore, I suggest you look into changing the class name again. I think this will be a problem for more and more people. I don't think you'll find many people running the stock php.ini on production servers so I'd say it's a good idea to rename it. I did a brute search and replace on all files which got rid of the problem in short time, there were just a handful of instances which required manual changes. If you're unwilling to make the change, I can provide you a patch against 2.3.6.
Comment 6 Alec Smecher 2011-08-02 19:14:21 PDT
Thanks for the details, Peter. It is a priority for us -- among many, unfortunately. It would be game-changer if PHP started shipping intl enabled by default. In any case, I'll reschedule this against the next release -- a few regular expressions would do the trick.
Comment 7 Peter Marquardt 2011-08-02 21:06:00 PDT
Thank you very much, Alec. I really appreciate the kind and fast response.
Comment 8 Michal Rydlo 2011-10-11 02:04:28 PDT
We have run into the same problem with our webhosting provider. It seems that this helped us in "solving" the problem so others may find it useful too:

1. Rename the class in classes/i18n/Locale.inc.php to XLocale
2. Run this unix shell one-liner in the root directory of OJS:
   find . -name '*.php' | xargs -n1 sed -i 's/Locale::/XLocale::/g'
Comment 9 Fatih 2011-10-14 16:55:03 PDT
Thank you Michal,
This line and another post in forums (http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=6444#p24796) helped me to move our OCS site to a newer server.
I also needed to change the Locale array in file lib/pkp/classes/template/PKPTemplateManager.inc.php (4 instances) as described in the forum.
Comment 10 Alec Smecher 2011-10-17 11:27:35 PDT
Fatih, there are similar cases in classes/install/form/InstallForm.inc.php, classes/manager/form/LanguageSettingsForm.inc.php, and lib/pkp/classes/i18n/PKPLocale.inc.php -- look for 'Locale' (including apostrophes). These are standard PHP callbacks (see the php documentation for e.g. call_user_func) and the class name will need to be changed here too.
Comment 11 Jorge Bastos 2011-10-17 13:27:20 PDT
Thanks all for providing the information on this bug, it helped me also to install OJS on a PHP 5.3x system with php-intl.
On my case I can't uninstall php-intl 'cause of other software that needs it.

Can this changed be commited to the next 2.3.7 OJS version?

Thanks in advanced,
Jorge Bastos,
Comment 12 Alec Smecher 2011-10-17 13:37:18 PDT
Hi Jorge -- it's already scheduled against 2.3.7. Unless our plans change drastically, it'll be included in that release.
Comment 13 Jorge Bastos 2011-10-17 15:17:51 PDT
Thanks for your reply Alec!

Jorge,
Comment 14 Fatih 2011-10-24 13:38:28 PDT
Thank you very much Alec,
After some time working on other issues, I recently applied the fix and it works great. 
Fatih
Comment 15 Alec Smecher 2011-10-27 10:20:02 PDT
Rename Locale class to AppLocale
https://github.com/pkp/omp/commit/7bad86db165f6c48cce5ed5af2edffd7a5355b3a
Comment 16 Alec Smecher 2011-10-27 10:20:02 PDT
Rename Locale class to AppLocale
https://github.com/pkp/pkp-lib/commit/7edc875792f25feac59706380ad190d3bd3a6373
Comment 17 Alec Smecher 2011-10-27 10:30:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/ojs/commit/e10e6018c320e1c528502d5f4efbebede46896c1
Comment 18 Alec Smecher 2011-10-27 11:20:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/pkp-lib/commit/66571b1bf309c2a2606f026c2778957ae140690d
Comment 19 Alec Smecher 2011-10-27 11:20:03 PDT
Rename Locale to AppLocale
https://github.com/pkp/ocs/commit/cdbb7aa1b792bc1da8c4f80ac736f140713e83f3
Comment 20 Alec Smecher 2011-10-27 11:25:54 PDT
Committed to the master branches only of all apps; still needs porting to stable.
Comment 21 Alec Smecher 2011-10-27 11:30:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/harvester/commit/2ea6ebdb5387a85c32b6c2e2bc6e05f777fa1d0d
Comment 22 Alec Smecher 2011-10-28 14:15:02 PDT
Added backwards compatibility Locale alias where possible
https://github.com/pkp/ocs/commit/a5f277fd63416d6a85c54df309805dde9f8af451
Comment 23 Alec Smecher 2011-10-28 14:15:02 PDT
Added backwards compatibility Locale alias where possible
https://github.com/pkp/harvester/commit/2ad43e624db21ba97da318b6b5d8576a44934228
Comment 24 Alec Smecher 2011-10-28 14:40:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/ocs/commit/04d3f774fa7c5a375d272652299385e0573966c9
Comment 25 Alec Smecher 2011-10-28 14:40:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/omp/commit/0582dba5aebaf46c82d0e2dd75732f0171a05059
Comment 26 Alec Smecher 2011-10-28 14:45:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/ojs/commit/7cc9b6cea151248b811289cdd402e2b1f1cad792
Comment 27 Alec Smecher 2011-10-28 14:45:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/ojs/commit/cf37c58cc0c48f90ec9ded5e97abf4e9ad1e53e8
Comment 28 Alec Smecher 2011-10-28 15:15:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/pkp-lib/commit/45bd1791fe98b5900a82bdfd1f2ee21471f7aae5
Comment 29 Alec Smecher 2011-10-28 15:20:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/ocs/commit/70c2867b72ad500310d4be60495fcf75cd38bb95
Comment 30 Alec Smecher 2011-10-28 15:20:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/pkp-lib/commit/7cab69e061c6b5ae54b82d9b98378f3a71c31962
Comment 31 Alec Smecher 2011-10-28 15:25:02 PDT
Rename Locale to AppLocale
https://github.com/pkp/pkp-lib/commit/5ffba461d9cb69c21c2e7ce4f434ede1d81eea68
Comment 33 Alec Smecher 2011-10-28 15:30:01 PDT
Rename Locale to AppLocale
https://github.com/pkp/harvester/commit/b7d04bbf638f91972988e9a0247d5094149670e2
Comment 36 Alec Smecher 2011-11-02 08:25:02 PDT
Fixed remaining old classname imports
https://github.com/pkp/ojs/commit/1a6d0e6f7f1a8ee4a8ca0905bcc6b7a3a8873cfb
Comment 37 Alec Smecher 2011-11-02 08:25:02 PDT
Fixed remaining old classname imports
https://github.com/pkp/ojs/commit/351c167b6f53d414ac9b2b819ab6c010777d1826
Comment 38 Alec Smecher 2011-11-02 08:25:03 PDT
Fixed remaining old classname imports
https://github.com/pkp/ojs/commit/351c167b6f53d414ac9b2b819ab6c010777d1826
Comment 39 Alec Smecher 2011-11-02 08:25:03 PDT
Fixed remaining old classname imports
https://github.com/pkp/ojs/commit/1a6d0e6f7f1a8ee4a8ca0905bcc6b7a3a8873cfb
Comment 40 Alec Smecher 2011-11-02 15:35:01 PDT
Leftover rename
https://github.com/pkp/omp/commit/a8ca1df535e6f4cb6eab372a812266e3ff394f2d
Comment 41 Alec Smecher 2011-11-15 08:34:26 PST
*** Bug 6950 has been marked as a duplicate of this bug. ***