setCustomerid() Fatal error Magento 1.9.2.1 - magento

I keep having this problem:
Customers can not register, login and logout without an fatal error (enabled debugging).
Fatal error: Call to a member function setCustomerId() on a non-object in ../public_html/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php on line 169
Here is the code snippet from lines 161 - 180:
/**
* Calculate count of product index items cache
*
* #return Mage_Reports_Model_Product_Index_Abstract
*/
public function calculate()
{
$collection = $this->getCollection()
->setCustomerId($this->getCustomerId())
->addIndexFilter();
Mage::getSingleton('catalog/product_visibility')
->addVisibleInSiteFilterToCollection($collection);
$count = $collection->getSize();
$this->_getSession()->setData($this->_countCacheKey, $count);
return $this;
}
What i've done, thanks to answers on similar questions:
Cookie settings.
Disabled (all) modules, one by one. By xml, admin backend and deleting. Also checked if there were any updates (there were not).
Refreshed cache, deleted cache, disabled cache (same for sessions)
Set Var directory, media, downloader and eventually all folders and files to 777.
Set all the correct permissions back again, thanks to magento-cleanup.php.
Checked the database on wrong base url's, secured and unsecured.
Did a complete app directory rewrite, uploaded from a clean magento installation.
Checked the server settings with , no safe modus (do got a basedir open directory)
Also i'm being redirected tot a 404 page within the backend. With a NoRoute URL, after a correct login. I do see and can use everything in the backend, including the navigation menu.
I do use a template and some customisation with plugins / modules. No coding in core files. Not sure what information is needed, so do ask if i have to mention something.
I'm completely lost after 8 hours of struggling. Hope it is something you can help me with.

Judging by the debug of calling the collection, you have either:
a) the issue with factory and xml (most likely, it the config.xml of some extension). In this case, you should debug the method _getResourceModelFactoryClassName of the core/config model.
https://www.gyazo.com/e7c8ebb26326ce2f1a3c7c26b43812ea
OR
b) the following class is absent: Mage_Reports_Model_Resource_Product_Index_Compared_Collection
https://www.gyazo.com/9c59119fe4b97889cb81d2e8980b55fa
You may check that in the getModelInstance method of the model. Please take into account the fact that while debuging via echo/var_dump you won't be able to good results, since these methods are generally called everywhere by different models.
I'd rather recommend you to start from checking the presence of the following class:
Mage_Reports_Model_Resource_Product_Index_Compared_Collection (app/code/core/mage/reports/model/resource/product/index/compared/collection.php).
Next, I'd check the presence of model rewrites in the (Mage_Reports) extension + check all recently installed extensions/ implemented changes in config.xml files of these modules.
Hope it helps.

Just debug and check what is returned in this method:
1) get_class($this)
2) get_class($this->getCollection())
In your case the error means the following: there's no a set resource model for the current model. The code is trying to access the collection, but can't do that, as there's no the required resource model, or the name of the resource model, or the class that corresponds to this name.

Related

Redirection issue in Codeigniter4

I have done admin controller and put that in a sub folder named 'Admin'
Controller
Admin
-login.php
Now I want to fetch that by router file where I wrote this
$routes->get('admin', 'Admin/Login::index');
But it is showing me "Not found" error and redirects to "http://localhost/admin".
Could there be some .htaccess issue?
replace this
$routes->get('admin', 'Admin/Login::index');
with
$routes->get('admin', 'Admin\Login::index');
also make sure you add namespace in your login.php
namespace App\Controllers\Admin;
If you keep CI4's directory structure intact you could in fact use sub-folders for Controllers, Models, Views, etc.
For example app/Controllers/Admin/Login.php is a valid place to put a Controller class. Make sure to add the appropriate namespace in Login.php - namespace App\Controllers\Admin; Also in routes - $routes->get('admin', 'App\Controllers\Admin\Login::index'); It is quite possible to work without the prefix of App\Controllers, but I never extensively tested it and I think there was a problem in some versions of CI4 before.
Another issue could be your app/Config/App.php class. If you did not change anything in your .htaccess file (the one in public directory!), $baseURL should be set to your public directory address - http://localhost/myproject/public/ . Or if you wish to make it easier - set up virtual hosts.
Just a thing to add - get() method in $routes allow only GET requests, meaning if you are trying to POST something (or use any other HTTP request method) it will fail and redirect.

trying to rebuild a Reddit Rails App from two years ago (User Agent & BootStrap)

Two years I used the Reddit API to pull stories into a Rails app I built. I wanted to come back to it to refresh myself on RoR. It seems like I got all of the updates working and can sometimes run it, but here are my issues:
1) Reddit now requires Oauth2 for API requests. I'm using the Redd gem and am able to get authenticated, but I get the 429 error (too many requests) error.
I copied from the Redd instructions the following into my model (substituting my info from my registered Reddit app page):
# Authorization (Web)
w = Redd.it(:web, "_myClientId_", "_My_Secret", "_myRedirectURI", user_agent: 'ruby:edswartz.com.myredditapp:v1.0 (by /u/edswartz')
url = w.auth_url("random_state", ["identity", "read"], :permanent)
puts "Please go to #{url} and enter the code below:"
code = gets.chomp
w.authorize!(code)
# Authorization
re = Redd.it(:script, "_my_Client_ID_", "_my_secret_", "_my_user_name_", "_my_password_", user_agent: 'ruby:edswartz.com.myredditapp:v1.0 (by /u/edswartz')
re.authorize!
edAgent = 'User-Agent: ruby:com.edswartz.trueQuotes:v1.0 (by /u/edswartz)'
response = JSON.load(RestClient.get('http://reddit.com/.json'),{'User-Agent'=> edAgent})
After successfully authenticating (copying and pasting the code into the console) I usually get a 429 error. What am I doing wrong? I'm not trying to spoof the user agent, but have put it in manually. I just don't know how else to do it.
The times that I do get in and see the site appear it is obvious that Bootstrap has not loaded. In looking at the Rails-Bootstrap documentation I see where the Gem name has changed and the application css. My /app/assets/stylesheets/application css looks like this:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
#import "bootstrap";
*/
Again, not sure this is right either but have tried to comply with the read me from https://github.com/twbs/bootstrap-rubygem
Any help anyone can provide on either of these issues would be much appreciated.
I resolved the Bootstrap question. I was using Bootstrap 4. When I went back to Bootstrap 3, and moved the #import directives in the SASS file out of the comments section AND changed the "span4" class to "col-md-4" everything worked.
The user agent seems to be working more often so it might have been a caching issue?
In any event, onward.

The photos don't appear after an update to vTiger 6.2

After an update or a fresh install of vtiger 6.2, it's possible that contact photos don't appear. It looks like a dead link.
Problem
vTiger 6.2 puts all your uploads (incl. user & product pictures) into /storage and denys access to this folder from the web through a htaccess-File (/storage/.htaccess):
deny from all
These files will only be accessible by the webserver/php directly, which is perfect from a security point of view and it should be kept that way (deleting this htaccess-file is a very bad thing, cause then everybody outside will be able to read your files given he has the right path)!!!
The correct way to deal with these files inside the Web-Application would be to never reference the files directly in HTML (<img src="path/to/file">, cause you would not see them due to the htaccess-File) but to always route their data through a gateway-PHP-Script which checks if the requesting user is authenticated (<img src="file.php?filename=path/to/file">). The PHP-Script can (as I said above) bypass the Apache/htaccess-Security cause it directly accesses the filesystem. This is done in the Document-Section where you can see that downloading a file leads to "http://domain/index.php?module=Documents&action=DownloadFile&record=10&fileid=11"
However, unfortunatly vTiger has places in its Web-Application where it still references files in /storage directly in HTML as with User Pictures and Product Pictures therefor they are not shown.
UPDATE: Bugfix
I found that the Apps Contacts, Users and Products have this problem.
I bugfixed them in 2 steps:
Add Actions for each App as Gateway-Scripts
Create the files (vTiger is installed on /opt/vtiger)
/opt/vtiger/modules/Users/actions/DownloadPicture.php
<?php
class Users_DownloadPicture_Action extends Vtiger_Action_Controller {
public function checkPermission(Vtiger_Request $request) {
$moduleName = $request->getModule();
if(!Users_Privileges_Model::isPermitted($moduleName, 'DetailView', $request->get('record'))) {
throw new AppException(vtranslate('LBL_PERMISSION_DENIED', $moduleName));
}
}
public function process(Vtiger_Request $request) {
$userRecordModel = Vtiger_Record_Model::getInstanceById($request->get('record'), $request->getModule());
$userPictureDetails = $userRecordModel->getImageDetails();
$pictureData = file_get_contents($userPictureDetails[0]['path'] . '_' . $userPictureDetails[0]['orgname']);
header("Content-type: image/jpeg");
header("Pragma: public");
header("Cache-Control: private");
echo $pictureData;
}
}
?>
/opt/vtiger/modules/Products/actions/DownloadPicture.php
The same but: class Products_Download...
/opt/vtiger/modules/Contacts/actions/DownloadPicture.php
The same but: class Contacts_Download...
Adapt the Templates to serve Image-Tags with the Gateway-Script
Go in the files, find the <img ... >-Tag and change its src-Attribute:
/opt/vtiger/layouts/vlayout/modules/Users/ListViewContents.tpl
index.php?module={$MODULE}&action=DownloadPicture&record={$LISTVIEW_ENTRY->get('id')}
/opt/vtiger/layouts/vlayout/modules/Users/PreferenceDetailViewHeader.tpl
index.php?module={$MODULE}&action=DownloadPicture&record={$RECORD->get('id')}
/opt/vtiger/layouts/vlayout/modules/Users/UserViewHeader.tpl
index.php?module={$MODULE}&action=DownloadPicture&record={$RECORD->get('id')}
/opt/vtiger/layouts/vlayout/modules/Vtiger/DetailViewBlockView.tpl
index.php?module={$MODULE}&action=DownloadPicture&record={$RECORD->get('id')}
/opt/vtiger/layouts/vlayout/modules/Vtiger/uitypes/Image.tpl
index.php?module={$MODULE}&action=DownloadPicture&record={$RECORD_ID}
/opt/vtiger/layouts/vlayout/modules/Contacts/DetailViewHeaderTitle.tpl
index.php?module={$MODULE}&action=DownloadPicture&record={$RECORD->get('id')}
Now it is for sure you can see your pictures everywhere, but without beeing logged in you cannot access the files!
Possible open problem: I do not know so much about rights management in vTiger to tell you that now only users with access rights on the records have access to the files. It is possible that now every user can access them. If somebody knows how to control this. Please comment!
Hope everything works out, as by me.
Servus
Lukas
To solve that, simply yourself connect to your server through an FTP client. Empty or remove the ".htaccess" file in the "/storage" folder.
That's it!
Or in the .htaccess file change from:
deny from all
to:
Options -Indexes
I rewrote my .htaccess file from "deny from all" to…
# If the URI is an image then we allow accesses
SetEnvIfNoCase Request_URI "\\.(gif|jpe?g|png|bmp)$" let_me_in
Order Deny,Allow
Deny from All
# Allow accesses only if an images was requested
Allow from env=let_me_in
Now my images show up.

Disable caching of the config details in Symfony2

We have several sites, each site has its own database and url.
All sites are using an API written by Symfony2. The database configuration in Symfony is in parameter.php file, which set the database parameters according to the current site.
As a result, every request to Symfony can be from different database, which means, the configuration should be loaded every time.
The question is how to disable the caching of the config parameters.
Or, if there is other idea, how to keep caching and to find a way to create caching per site, I would be happy to hear.
Thanks.
I ended up creating a separate cache directory for each site. This way the configuration parameters are saved in the cache per site.
Here is how to override the cache directory:
http://symfony.com/doc/2.1/cookbook/configuration/override_dir_structure.html
I just added the following to the AppKernel.php file:
public function getCacheDir()
{
$request = Request::createFromGlobals();
return $this->rootDir . '/cache/'. $this->environment .'/' . $request->getHost();
}

Magento: Enterprise Full Page Cache - Disable Cookies / $_COOKIE

We have a customised process that relies on a cookie to render some pivotal display options. This is the only real solution as is required for all website guests.
Process works beautifully with FPC disabled, but with it enabled the PHP global $_COOKIE is cached for the entire browser session.
Essentially - we need to apply a patch to FPC to make it ignore cookies (either all or by name - either is fine for now).
Appreciate if anyone has had any success in achieving something similar, or a suitable place to start.
Note: running EE1.12 on AWS nginx build.
Cheers,
t8
In FPC with no Dynamic Block Magento application initialization is not done.
So as you want some part of your page to vary depending on Cookies you need to use Dynamic Block.
For this you will have to create a container class and set lifetime as Null as in snippet below
1.Try adding this to your container class: protected function _saveCache($data, $id, $tags = array(), $lifetime = null) { return false; } That should prevent it from getting cached.
Also this link on Stackoverflow :
How do I include a dynamic block in the product page with full page caching turned on?
details out on Dynamic Blocks and FPC.

Resources