Jump to content

[PS 1.6.1.7] Exception due to missing CREATE TEMPORARY TABLE privileges


c_reiter

Recommended Posts

Hi,

 

I'm trying to dig into some problems with an existing PrestaShop setup, I've been approached by the site owners after their original developer did a disappearing act.

 

They have some problems with recurring 500 errors that turn out, after activating _PS_MODE_DEV_, to be caused by database operations such as CREATE TEMPORARY TABLE ps_cat_restriction ENGINE=MEMORY.

 

The database user in the hosting environment doesn't have CREATE TEMPORARY TABLE privileges and the privilege can't be granted.

 

Is creating temporary tables a baseline requirement for running Prestashop? That is, the database has to be moved to a server where that priviliege is available?

 

The code doing that is in  classes/Product.php and modules/blocklayered/blocklayered.php so it's not a third party extension doing that.

 

Thanks for any help,

 

Christian

 

Link to comment
Share on other sites

This is how prestashop works. In Product.php it is the function

getRandomSpecial

which needs the CREATE privilege. However you could easily disclaim this function. It's not important at all. Dirty fix:

    public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null)
    { return false; }

Or you can rewrite the function with - as example - writing to a temporary file. Takes more time than a memory table but would work. Or you can create a non-temporary normal table with the characteristics according to the class. Then replace ....    

Db::getInstance()->execute('CREATE TEMPORARY TABLE `'._DB_PREFIX_.'product_reductions` (id_product INT UNSIGNED NOT NULL DEFAULT 0, id_product_attribute INT UNSIGNED NOT NULL DEFAULT 0) ENGINE=MEMORY', false);

with

 Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_reductions ;`);

Same for blocklayered. It won't get faster with a rewrite but there are many options.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

bellini13 

I have tried to rewrite the getRandomSpecial function, but my problem still there.

 I also checked app/config/parameters.php, all the information is correct with my host provider. 

It seems like when I create a new product, the new product can be displayed at my home page, but it is not displayed under its associated catalog page

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...