-2

I am having a very strange issue, when ever I download any php script, and try to install it locally, I run into trouble. I mentioning download any php script, because, if I create a php script locally, no matters how many include statement it has, or how long include statement it contains, they just work fine.

Last time, I faced some issue with my WP installation See my other question

I did 4 git clone, for cake, croogo, fuel, fuel-cms and having same issue with all of them:

  • Strange annoying BOM charachter in include making PHP throw Fatal error :

    A PHP Error was encountered

    Severity: Warning

    Message: require_once(base_module_model.php): failed to open stream: No such file or directory

    Filename: models/users_model.php

    Line Number: 3 Fatal error: require_once(): Failed opening required 'base_module_model.php' (include_path='.:/usr/share/php:/usr/share/pear:/usr/share/ZF/library:/usr/share/ZF/extras/library') in ª.!ª(!“(! on line 3

    Call Stack: 0.0002 327540 1. {main}() PATH_TO_FUEL/index.php:0
    0.0006 329032 2. require_once('ãå,/PATH_TO_FUEL/fuel/codeigniter/core/CodeIgniter.php') PATH_TO_FUEL/index.php:236
    0.0109 544260 3. Login->__construct() PATH_TO_FUEL/fuel/application/../modules/user_guide/:267
    0.0269 1002572 4. Fuel_Loader->module_model() PATH_TO_FUEL/fuel/modules/fuel/controllers/login.php:28
    0.0269 1002660 5. Fuel_Loader->model() PATH_TO_FUEL/fuel/application/third_party/fuel/Loader.php:107
    0.0337 1469404 6. Modules::load_file() PATH_TO_FUEL/fuel/application/third_party/fuel/Loader.php:237
    0.0338 1482504 7. include_once('_ö,/PATH_TO_FUEL/fuel/modules/fuel/models/users_model.php') PATH_TO_FUEL/fuel/application/third_party/MX/Modules.php:142

Since it's happening with almost all the files, I am now now sure, the problem is not in the content of the files, it something else, maybe a mismatch in encoding.

my questing is :

  • is the problem above suggest that there might be some problem with my system encoding? (I am mostly using vi or Netbeans as IDE.)

  • if there is some problem with the encoding (with my machine or with the file), is there a permanent fix for the problem ?

List of Extension installed (got them using php -m):

[PHP Modules]
apc
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
SQLite
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]
Xdebug
Community
  • 1
  • 1
Ravish
  • 2,383
  • 4
  • 37
  • 55
  • 1
    Are you moving and editing files from windows to linux? – Alfabravo Aug 03 '12 at 20:17
  • I fail to see how a BOM could cause php to not find a file, unless the bom was embedded in the filename somewhere... – Marc B Aug 03 '12 at 20:17
  • You can see clearly whats wrong, the encoding within the files has been changed as such these BOM characters are showing up. – Sammaye Aug 03 '12 at 20:20
  • I would check your editor, maybe it is setup for an ISO character encoding while most files are for UTF-8 encoding – Sammaye Aug 03 '12 at 20:22
  • @MarcB This line makes me think it is: `include_once('_ö,/PATH_TO_FUEL/fuel/modules/fuel/models/users_model.php')` and this one `include_path='.:/usr/share/php:/usr/share/pear:/usr/share/ZF/library:/usr/share/ZF/extras/library') in ª.!ª` – Sammaye Aug 03 '12 at 20:24
  • I just did a git clone from fuel repo, and it's happening with almost everything. I just did a git clone of **croogo** cms, and it isn't working as well... file -i index.php = : text/x-php; charset=us-ascii – Ravish Aug 03 '12 at 21:41
  • *"when ever I download any php script, and try to install it locally, I run into trouble"* - sorry but this is not the Esoteric FAQ. Stop guessing, start validating and debugging. Start with uninstalling PHP and let it yourself re-installed by a third party. Just for safeness reasons and you get a second opinion. – hakre Aug 03 '12 at 21:54
  • If it was a BOM, one would expect the character sequence to be the same each time (http://en.wikipedia.org/wiki/Byte_order_mark#Representations_of_byte_order_marks_by_encoding), and it would appear at the start of each file instead of e.g., inside an `include_once()` statement, no? –  Aug 03 '12 at 21:57
  • @Phoenix true his PHP is prolly encoding funny somewhere...fail thinking on my part. – Sammaye Aug 03 '12 at 21:59
  • @Phoenix you are right, but, still can't find the root cause of the problem. There are projects in my www directory working fine, I checked mime info of those files, it's same **us-ascii** – Ravish Aug 03 '12 at 22:06
  • @RavishTiwari have you checked inside the files? Searched for some of the strings you are getting back, grepped all files in the folder for them? – Sammaye Aug 03 '12 at 22:10
  • yes, I checked the content of the file where it is reporting problem. those characters are not present in any of the file... and if I do a echo of the same path(that is being used inside the include statement) it prints the correct path (with those strange characters) – Ravish Aug 03 '12 at 22:18
  • @hakre I've already tried installing php5 once, will do it again. I haven't touched any of the file and just performed a chmod on so that I can access them using apache... – Ravish Aug 03 '12 at 22:33
  • On which OS are you running PHP? – hakre Aug 04 '12 at 09:20
  • @hakre I am running on Ubuntu 10.04 – Ravish Aug 04 '12 at 09:55
  • 1
    I'd say one of your PHP extensions is not working. Do you use any byte-caching or something? What about disabling everything first and only enable what is actually needed? Also list all needed extensions. – hakre Aug 04 '12 at 10:10
  • @hakre I've added a list of modules. I've mbstring installed and enabled, could it be a problem? I need the extension for some other scripts... – Ravish Aug 04 '12 at 10:41
  • 1
    First reduce all potential side-effects, so for this error you describe here, disable everything you do not really need. You find that out by first disabling every module, php extensions and zend extensions. Then try to reproduce. The special characters that appear for the includes and within the error messages make be assume that you have got some problem here that is not easily to cope with via a website like this one (you open a club of guessing room here) but only with direct access to the system where the problem appears. – hakre Aug 04 '12 at 10:45
  • possible duplicate of [Strange characters in require_once() paths in stack trace](http://stackoverflow.com/questions/9642260/strange-characters-in-require-once-paths-in-stack-trace) –  Aug 04 '12 at 23:58
  • @Phoenix not exactly an duplicate, last time my problem was solved by removing the corrupt plugin... – Ravish Aug 06 '12 at 15:19
  • Thanks every1 for helping me out, it seems there is some problem with my system, one of my friend who is a ubuntu expert was not able to fix it, and to me, fresh install is more viable then trying to fix the problem, because everything was working fine couple of months ago... – Ravish Aug 12 '12 at 11:24

1 Answers1

0

In order to confirm that the problem really is that your version control operations are adding a BOM character, you could:

  1. Check out a small set of files for testing, and verify that you see the problem.
  2. Use vi or vim to "clean" each file manually, e.g. via :set nobomb
  3. Verify that the problem goes away.

If this does not work, then you know you're barking up the wrong tree. If it does work, then you know that there is indeed something wrong - perhaps with your git setup.

Peter
  • 2,526
  • 1
  • 23
  • 32
  • it's not git, If I download a zip archive of say WP, I will still face the problem. If I zip something on windows and extract it on my machine, I face issue. How ever, I'll the things suggested by you... – Ravish Aug 04 '12 at 10:39
  • In your question you mention "git clone", which I assumed was one of the methods by which you had caused the source code to appear in your webserver filesystem. If you're seeing the same problem with zipped archives, then you're most likely moving files between Windows and Linux filesystems - in which case you can easily Google some utilities to help you make the transition "clean" and thereby get rid of the problem. – Peter Aug 04 '12 at 13:00