Magento Use of undefined constant tmp in core file - magento

My magento store is returning that error:
Notice: Use of undefined constant tmp - assumed 'tmp' in /lib/Zend/Cache.php on line 153
But my line is:
return new $backendClass($backendOptions);
I cannot see what file is exactly the error. How can I proceed?

It looks like somewhere in your code you put tmp instead of $tmp. Run a search over all of your code for tmp.

Related

how to get current running code line and directory name in go [duplicate]

In C/C++ you can use __FILE__ and __LINE__ to get access to the current file and line number.
Does Go provide something similar?
Indeed it does:
http://golang.org/pkg/runtime/#Caller
runtime.Caller can also be used to get the file name/line number of calling functions, too.

Can't use io.open in home directory - Lua

I'm writing a Mac OS program, and I have the following lines:
os.execute("cd ~/testdir")
configfile = io.open("configfile.cfg", "w")
configfile:write("hello")
configfile:close()
The problem is, it only creates the configfile in the scripts current directory instead of the folder I have just cd' into. I realised this is because I'm using a console command to change directory, then direct Lua code to write the file. To combat this I changed the code to this:
configfile = io.open("~/testdir/configfile.cfg", "w")
However I get the following result:
lua: ifontinst.lua:22: attempt to index global 'configfile' (a nil value)
stack traceback:
ifontinst.lua:22: in main chunk
My question is, what's the correct way to use IO.Open to create a file in a folder I have just created in the users home directory?
I appreciate I'm making a rookie mistake here, so I apologise if you waste your time on me.
You have problems with ~ symbol. In your os.execute("cd ~/testdir") is the shell who interprets the symbol and replaces it by your home path. However, in io.open("~/testdir/configfile.cfg", "w") is Lua who receives the string and Lua doesn't interprets this symbol, so your program tries to open a file in the incorrect folder. One simple solution is to call os.getenv("HOME") and concatenate the path string with your file path:
configfile = io.open(os.getenv("HOME").."/testdir/configfile.cfg", "w")
In order to improve error messages I suggests you to wrap io.open() using assert() function:
configfile = assert( io.open(os.getenv("HOME").."/testdir/configfile.cfg", "w") )

Magento font_color phtml error no idea where to even start

I keep getting the following error filling up my system log constantly.
2014-03-04T11:52:56+00:00 ERR (3): Notice: Undefined index: font_color in /var/www/html/waxmanenergy.co.uk/magento/app/design/frontend/default/mt_gero/template/page/html/header.phtml on line 31
Im not sure whats wrong with it or how to go about fixing it.
This is whats in line 31 on the error path within the header.phtml file
$text_color = isset($_COOKIE['textColor']) ? $_COOKIE['textColor'] : $config['font_color'];
Anyone got any heads up to what could be the issue
$config of yours do not have any index like 'font_color'. Either $config is not an array of array without 'font_color' as its key.

how to read file using path in ruby by function IO.readlines("path")[0]

i want to read first line of file by using following function in ruby
IO.readlines("path")[0]
But file is not in current directory, so i use path there
puts IO.readlines("Home/Documents/vikas/SHIF.doc")
but it is giving error as
a1.rb:1:in `readlines': No such file or directory # rb_sysopen - Home/Documents/vikas/SHIF.doc (Errno::ENOENT)
from a1.rb:1:in `<main>'
You can also open a file and read only the first line instead of the entire file
File.open("Home/Documents/vikas/SHIF.doc").readline
You can use File.expand_path:
puts IO.readlines(File.expand_path("Home/Documents/vikas/SHIF.doc", __FILE__))
Note however that it will create path relatively to a file directory, not to a root directory.
If you are using rails, you could use:
puts IO.readlines(Rails.root.join 'Home', 'Documents', 'vikas', 'SHIF.doc')

Ruby require_relative not loading file, not throwing error

I am having trouble getting constant definitions loaded via an external file. I have narrowed the problem down to the following.
require_relative '../../common/config.rb'
A_CONSTANT = 'something'
puts "A_CONSTANT: #{A_CONSTANT}"
When I run this as written, it prints the message correctly. The same constant is declared in the file common/config.rb. The relative path is correct for the location of this file. Just for completeness, the above code is in /watir/dashboard/spec/ex.rb. The constant is declared in /watir/common/config.rb.
As I see it, the above code should error out for a duplicate constant declaration. It does not. If I comment out the constant declaration above and rerun, the puts statement shows an error for 'uninitialized constant.' Any ideas what's wrong?
Edit - The contents of the file common/config.rb are below.
A_CONSTANT = 'something'
On a lark, I changed the filename to common/conf.rb. When I modify the require_relative statement to load the renamed file, I get the results I originally expected. The file is loaded and the second constant declaration throws a warning saying 'already initialized constant.' If I comment out the second declaration, the script runs perfectly.
It appears that the filename 'config.rb' is somehow special when loaded by a relative path. I have use that filename in other scripts where it was in the same folder as the loading script or a sub-folder. This is the first time I have had to move up the tree to load it.
Ruby allows redefining constants, and will only print a warning. Some setting in your Ruby is just hiding that warning from you.

Resources