Mage registry key "_singleton/core/resource" already exists
Trace:
#0 /.../app/Mage.php(222): Mage::throwException('Mage registry k...')
#1 /.../app/Mage.php(476): Mage::register('_singleton/core...', Object(Mage_Core_Model_Resource))
#2 /.../app/code/core/Mage/Core/Model/Resource/Setup.php(141): Mage::getSingleton('core/resource')
#3 /.../app/code/core/Mage/Core/Model/Resource/Setup.php(234): Mage_Core_Model_Resource_Setup->__construct('core_setup')
#4 /.../app/code/core/Mage/Core/Model/App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 /.../app/code/core/Mage/Core/Model/App.php(343): Mage_Core_Model_App->_initModules()
#6 /.../app/Mage.php(683): Mage_Core_Model_App->run(Array)
#7 /.../index.php(104): Mage::run('', 'store')
#8 {main}
Hi i'm getting above error, From few blogs and community forums i came to know the problem is with cache. so i added this in index.php
$app = Mage::app();
if ($app != null)
{
$cache = $app->getCache();
if ($cache != null)
{
$cache->clean();
}
}
Original source: http://vipinsahu.com/magento-mage-registry-key-_singletoncoreresource-already-exists#ixzz24XXCt6m2
But still i'm getting the same. Please give me your idea to solve this issue.
Thanks.
Try to refresh your magento cache on
admin > system > cache management
click button refresh magento cache and delete all folder on your ../var/cache/
Related
My problem isn't easy to describe, i guess I forgot something obvious but I just can't figure out what..
Here is the error: GET http://127.0.0.1/ideayear/850/js/app.js net::ERR_ABORTED 500 (Internal Server Error)
And here is the problem:
Until now I had
in web.php
Route::get('idea/{n}', 'IdeaController#idea')->name('idea');
And I want to add the year
Route::get('ideayear/{n}/{m}', 'IdeaController#idea')->name('idea');
public function idea($idea, $year){
$idea = substr($idea, 0, strpos($idea, "-"));
$sql = " SELECT BLABLA where year like ..."
$array = DB::connection('ideas')->select( DB::connection('ideas')->raw($sql));
return view('ideas/idea', ['idea' => json_encode($array), 'defyear' => $year] );
}
when I had public function idea($idea){} it worked well, but since I added $year, I get this strange issue when visiting http://127.0.0.1/ideayear/850/2018
Give me the error:
GET http://127.0.0.1/ideayear/850/js/app.js net::ERR_ABORTED 500 (Internal Server Error)
And I have absolutely no idea why it's for some reason trying to visit js/app.js
Here is idea.blade.php (in case if it helps)
#extends('template')
#section('contenu')
<div>
<div id="app">
<ideapage ideas="{{ $idea }}" defyear="{{ $defyear }}"></ideapage>
</div>
</div>
#endsection
[EDIT] Content of
(I removed almost everything from IdeaPage.vue, same problem)
<template>
<div> {{ideas}}
{{defyear}}
</div>
</template>
<script>
export default {
props: {
ideas: String,
defyear: String
}
}
</script>
Here is the error in laravel.log
#0 C:\\laragon\\www\\projet\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback(Object(Illuminate\\Database\\Query\\Expression), Array, Object(Closure))
#1 C:\\laragon\\www\\projet\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php(333): Illuminate\\Database\\Connection->run(Object(Illuminate\\Database\\Query\\Expression), Array, Object(Closure))
#2 C:\\laragon\\www\\projet\\app\\Http\\Controllers\\IdeaController.php(121): Illuminate\\Database\\Connection->select(Object(Illuminate\\Database\\Query\\Expression))
#3 [internal function]: App\\Http\\Controllers\\IdeaController->idea('850', '', 'app.js')
#4 C:\\laragon\\www\\projet\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array)
#5 C:\\laragon\\www\\projet\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('idea', Array)
Why is it trying to visit idea('850', '', 'app.js')** ? i really don't get this...
im new in the forum and im spanish... sorry for my low level of english...
Im using Codeigniter with twig engine in my project but I having some problems...
When I use:
<link rel="stylesheet" href="{{ asset('assets/css/bootstrap.min.css') }}">
Codeigniter throws an exception. It says:
The function "asset" does not exist. Did you mean "assert" in "index.html.twig" at line 12 --- #0 /volume1/web/ci/application/libraries/Twig/ExpressionParser.php(351): Twig_ExpressionParser->getFunctionNodeClass('asset', 12) #1 /volume1/web/ci/application/libraries/Twig/ExpressionParser.php(144): Twig_ExpressionParser->getFunctionNode('asset', 12) #2 /volume1/web/ci/application/libraries/Twig/ExpressionParser.php(84): Twig_ExpressionParser->parsePrimaryExpression() #3 /volume1/web/ci/application/libraries/Twig/ExpressionParser.php(41): Twig_ExpressionParser->getPrimary() #4 /volume1/web/ci/application/libraries/Twig/Parser.php(141): Twig_ExpressionParser->parseExpression() #5 /volume1/web/ci/application/libraries/Twig/TokenParser/Block.php(45): Twig_Parser->subparse(Array, true) #6 /volume1/web/ci/application/libraries/Twig/Parser.php(187): Twig_TokenParser_Block->parse(Object(Twig_Token)) #7 /volume1/web/ci/application/libraries/Twig/Parser.php(95): Twig_Parser->subparse(NULL, false) #8 /volume1/web/ci/application/libraries/Twig/Environment.php(543): Twig_Parser->parse(Object(Twig_TokenStream)) #9 /volume1/web/ci/application/libraries/Twig/Environment.php(595): Twig_Environment->parse(Object(Twig_TokenStream)) #10 /volume1/web/ci/application/libraries/Twig/Environment.php(335): Twig_Environment->compileSource('...', 'index.html.twig') #11 /volume1/web/ci/application/libraries/Twig.php(90): Twig_Environment->loadTemplate('index.html.twig') #12 /volume1/web/ci/application/controllers/welcome.php(15): Twig->display('index.html.twig', Array) #13 [internal function]: Welcome->index() #14 /volume1/web/ci/system/core/CodeIgniter.php(360): call_user_func_array(Array, Array) #15 /volume1/web/ci/index.php(202): require_once('/volume1/web/ci...') #16 {main}
Also throws an exception for any function twig
What is the problem?
Thank you!
Edit
Ok guys, I haven't been unable to resolve my problem, the function doesn't exists but I have got to include my css and js files and also using twig together. The problem was on my .htaccess file (the file is on root directory in my server). The file had written:
RewriteEngine on
RewriteCond $1 !^(index.php|css|js|images|robots.txt)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
So I created another .htaccess file on "/ci/assets/.htaccess" with this code:
RewriteEngine off
RewriteCond $1 !^(index.php|css|js|images|robots.txt)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
I don't know if this is the best way but this is valid for me and I can work fine.
Any sugestion?
You need helper file that contents asset() function.
But maybe you have a typo:
<link rel="stylesheet" href="{{ assert('assets/css/bootstrap.min.css') }}">
asset() takes part of the Symfony2 project, not the Twig one.
You should create this function in codeigniter by yourself first.
1) In your custom Twig library, add the following line:
$this->_twig_env->addFunction(
new Twig_SimpleFunction('asset', 'asset',
array('is_safe' => array('html')))
);
2) In your helpers, add the following function (replace assets/ by the path to your assets, here I assume your images, js, ... are available in assets/images, assets/js, assets/...).
if (!function_exists('asset'))
{
function asset()
{
return base_url() . 'assets/';
}
}
You Might want to add a filter like eg usage is as below
Link rel="stylesheet" href="{{ 'assets/css/bootstrap.min.css' | asset }}">
to achieve above you might want to extend twig filters class and add your filter.
requrie_once("path of Twig_Extension class); // update this
use Twig_Extension;
use Twig_Filter_Method;
class customExtension extends Twig_Extension
{
/**
* Returns the name of the extension.
*
* #return string The extension name
*/
function getName()
{
return "customExtension";
}
public function getFilters()
{
return array(
'asset' => new Twig_Filter_Method($this,'twig_asset_filter'),
);
}
/**
* #param $path
*
* #return string
*/
function twig_asset_filter($path)
{
return 'assets/'.$path;
}
after which you can use it in same way - this extension is already written and is accessible via composer..
check this link https://github.com/iddigitalagency/Codeigniter-twig-twigextensions
I get this error while trying to implement a block for a specific module. I put it with the stack trace :
Fatal error: Class 'Zend_Log_Formatter_Simple' not found in /users/christophe/dev/------/public/www/app/code/community/Bms/Recrutement/Block/Annonce.php on line 20
Call Stack:
0.0012 692544 1. {main}() /users/christophe/dev/------/public/www/index.php:0
5.0145 1334240 2. Mage::run() /users/christophe/dev/------/public/www/index.php:96
5.0351 3083736 3. Mage_Core_Model_App->run() /users/christophe/dev/------/public/www/app/Mage.php:683
26.9640 17422296 4. Mage_Core_Controller_Varien_Front->dispatch() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/App.php:354
26.9974 19462280 5. Mage_Core_Controller_Varien_Router_Standard->match() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Controller/Varien/Front.php:176
27.0049 20055160 6. Mage_Core_Controller_Varien_Action->dispatch() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250
27.4144 28301984 7. Bms_Recrutement_IndexController->annonceAction() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Controller/Varien/Action.php:419
27.4144 28301984 8. Mage_Core_Controller_Varien_Action->loadLayout() /users/christophe/dev/------/public/www/app/code/community/Bms/Recrutement/controllers/IndexController.php:30
27.7507 28773096 9. Mage_Core_Controller_Varien_Action->generateLayoutBlocks() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Controller/Varien/Action.php:269
27.7509 28777880 10. Mage_Core_Model_Layout->generateBlocks() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Controller/Varien/Action.php:344
27.9351 37337024 11. Mage_Core_Model_Layout->generateBlocks() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:210
27.9351 37338856 12. Mage_Core_Model_Layout->_generateBlock() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:205
27.9352 37341256 13. Mage_Core_Model_Layout->addBlock() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:239
27.9352 37341256 14. Mage_Core_Model_Layout->createBlock() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:472
27.9352 37341568 15. Mage_Core_Model_Layout->_getBlockInstance() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:437
27.9356 37342840 16. Varien_Autoload->autoload() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:0
27.9369 37401728 17. mageCoreErrorHandler() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/Model/Layout.php:98
27.9369 37402272 18. Mage::log() /users/christophe/dev/------/public/www/app/code/core/Mage/Core/functions.php:247
Here is the class I use :
class Bms_Recrutement_Block_Annonce extends Mage_Core_Block_Template {
public function getUrl() {
$data = $this->getRequest()->getParams();
var_dump($data);
return 'http://some_url';
}
}
And finally the .phtml
<iframe src="<?php echo $this->getUrl() ?>" style="width:100%; height : 490px;"></iframe>
I do not have an idea where it can come from. If you have an answer or any hint, I will be glad to get it.
Thanks in advance.
I found my mistake !
getUrl() is already a function that is set in parent class and used elsewhere. I renamed it to getIframeUrl() and everything is ok.
I am trying to get to grips with working with layouts and came across Alan Storm's book Nofrills Magento Layouts (Good Book).
I have gone through the examples right up to page 19 adding in a new class under the Advanced Block Functionality section.
I have created all the files and templates as per the examples but I am now getting an error and cannot seem to progress until it is fixed.
The block class looks like this:
<?php
class Nofrills_Booklayout_Block_Helloworld extends Mage_Core_Block_Template
{
public function _construct()
{
$this->setTemplate('helloworld.phtml');
return parent::_construct();
}
}
?>
The IndexController class looks like this:
<?php
class Nofrills_Booklayout_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$block_1 = new Mage_Core_Block_Text();
$block_1->setText('Original Text');
$block_2 = new Mage_Core_Block_Text();
$block_2->setText('The second sentence');
$main_block = new Nofrills_Booklayout_Block_Helloworld();
//$main_block->setTemplate('../helloworld.phtml');
$main_block->setChild('the-first',$block_1);
$main_block->setChild('the-second', $block_2);
//$block_1->setText('Wait, I want this text instead!');
echo $main_block->toHtml();
}
public function helloblockAction()
{
$block_1 = new Mage_Core_Block_Text();
$block_1->setText('Original Text');
$block_2 = new Mage_Core_Block_Text();
$block_2->setText('The second sentence');
$main_block = new Nofrills_Booklayout_Block_Helloworld();
//$main_block->setTemplate('helloworld.phtml');
$main_block->setChild('the-first',$block_1);
$main_block->setChild('the-second', $block_2);
echo $main_block->toHtml();
}
}
and the template looks like this:
<h1>hello world</h1>
<p>
<?php echo $this->getChildHtml('the-first'); ?>
</p><p>
<?php echo $this->getChildHtml('the-second'); ?>
</p>
However when i goto my url to call the page:
http://www.phmagento.com/nofrills_booklayout/index/index
http://www.phmagento.com/nofrills_booklayout/index/helloblock
I get this error which is totally confusing me:
Warning: include(C:\xampp\htdocs\phmagento\includes\src\Nofrills_Booklayout_Block_Helloworld.php): failed to open stream: No such file or directory in C:\xampp\htdocs\phmagento\includes\src\Varien_Autoload.php on line 93
#0 C:\xampp\htdocs\phmagento\includes\src\Varien_Autoload.php(93): mageCoreErrorHandler(2, 'include(C:\xamp...', 'C:\xampp\htdocs...', 93, Array)
#1 C:\xampp\htdocs\phmagento\includes\src\Varien_Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload('Nofrills_Bookla...')
#3 C:\xampp\htdocs\phmagento\app\code\local\Nofrills\Booklayout\controllers\IndexController.php(12): spl_autoload_call('Nofrills_Bookla...')
#4 C:\xampp\htdocs\phmagento\includes\src\__default.php(13969): Nofrills_Booklayout_IndexController->indexAction()
#5 C:\xampp\htdocs\phmagento\includes\src\__default.php(18331): Mage_Core_Controller_Varien_Action->dispatch('index')
#6 C:\xampp\htdocs\phmagento\includes\src\__default.php(17865): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#7 C:\xampp\htdocs\phmagento\includes\src\__default.php(20465): Mage_Core_Controller_Varien_Front->dispatch()
#8 C:\xampp\htdocs\phmagento\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#9 C:\xampp\htdocs\phmagento\index.php(87): Mage::run('', 'store')
#10 {main}
If anybody has any clues as to why I am getting this error or what I am doing wrong it would be greatly appreciated.
Many thanks
Graham
The autoloader is trying to load the Nofrills_Booklayout_Block_Helloworld class from C:\xampp\htdocs\phmagento\includes\src\Nofrills_Booklayout_Block_Helloworld.php. Are you sure that file exists? It should contain the block from your first code snippet.
I want to embed an HTML input form (search bar) in /View/Layouts/default.ctp (which is Homepage presentation layout of the site). I've created /View/Elements/lookup.ctp with the following code (I wrote Element because I wanted to include that search bar on every page of the site):
<?php
echo $this->Form->create('Search', array('action' => 'lookup', 'accept-charset' => 'utf-8'));
echo $this->Form->input(array('type' => 'search', 'name' => 'search', 'placeholder' => 'enter search term'));
echo $this->Form->button('Search', array('type' => 'button', 'value' => 'submit'));
echo $this->Form->end();
?>
The search bar itself should look like this:
___________________________ ______________
| enter search term | | Search | <--- button
|_________________________| |______________|
↑
search bar
The generated code in /View/Layouts/default.ctp must be like this:
<form id="searchForm" method="post" action="/searches/lookup" accept-charset="utf-8">
<input type="search" name="search" placeholder="enter search term" />
<button type="button" name="submit" value="submit">Search</button>
</form>
I included line:
<?php echo $this->element('lookup'); ?>
in /View/Layouts/default.ctp (which embeds the Element), but when I go to Homepage, it won't render this element and the error appears:
( #Wylie: Yes, you're right. It wasn't the whole error. Here's the complete error )
#0 C:\wamp\www\lib\Cake\Model\Datasource\DboSource.php(436): PDOStatement->execute(Array)
#1 C:\wamp\www\lib\Cake\Model\Datasource\Database\Mysql.php(307): DboSource->_execute('SHOW FULL COLUM...')
#2 C:\wamp\www\lib\Cake\Model\Model.php(1226): Mysql->describe(Object(Search))
#3 C:\wamp\www\lib\Cake\View\Helper\FormHelper.php(197): Model->schema()
#4 C:\wamp\www\lib\Cake\View\Helper\FormHelper.php(450): FormHelper->_introspectModel('Search', 'fields')
#5 C:\wamp\www\azil\View\Elements\lookup.ctp(2): FormHelper->create('Search', Array)
#6 C:\wamp\www\lib\Cake\View\View.php(595): include('C:\wamp\www\azi...')
#7 C:\wamp\www\lib\Cake\View\View.php(317): View->_render('C:\wamp\www\azi...', Array)
#8 C:\wamp\www\azil\View\Layouts\default.ctp(91): View->element('lookup')
#9 C:\wamp\www\lib\Cake\View\View.php(595): include('C:\wamp\www\azi...')
#10 C:\wamp\www\lib\Cake\View\View.php(411): View->_render('C:\wamp\www\azi...')
#11 C:\wamp\www\lib\Cake\View\View.php(373): View->renderLayout('<h2>Database ta...', 'default')
#12 C:\wamp\www\lib\Cake\Controller\Controller.php(900): View->render('error500', NULL)
#13 C:\wamp\www\lib\Cake\Error\ExceptionRenderer.php(282): Controller->render('error500')
#14 C:\wamp\www\lib\Cake\Error\ExceptionRenderer.php(191): ExceptionRenderer->_outputMessageSafe('error500')
#15 [internal function]: ExceptionRenderer->_cakeError(Object(MissingTableException))
#16 C:\wamp\www\lib\Cake\Error\ExceptionRenderer.php(165): call_user_func_array(Array, Array)
#17 C:\wamp\www\lib\Cake\Error\ErrorHandler.php(127): ExceptionRenderer->render()
#18 [internal function]: ErrorHandler::handleException(Object(MissingTableException))
#19 {main} [<b>CORE\Cake\Error\ErrorHandler.php
Missing table?! What missing table, it just need to add a couple of HTML lines inside a /View/Layouts/default.ctp. I don't understand what's going on. Please help. Thank you.
Cake expects a Model to have a corresponding database table. Based on the incomplete error output Cake looks for a searches table in the database, but can't find it. Because you include an element which contains a form belonging to the Search Model Cake queries the database for a description of the columns to correctly display the form.
Are you certain you want to have a separate Controller and Model for searching? search could also be an action of the relevant Controller (the PostsController, for example).
Of course, if you need a global Search model which can query several models (Posts, Pages, Users, for example) modelising might make sense. You can tell Cake that a Model doesn't have a database table:
public $useTable = false;