Add prefix on tables break my site

I have an old site on an old shared server which used an old shared PHP 5 we can not update. I create a copy of this website which will run on a different (and dedicated) server with PHP 5.6 and present the contents in a API with the module RESTFUL (which need PHP 5.5.9 minimally to work). This copy will be used only to expose the content in the API. The old website will still be used to add contents. So we want share the same database.

Like Restful, Plug and Registry Autoload don’t work before PHP 5.5.9, I faked them on the old website. There is these 3 modules but they are composed of an empty .module and a .info very simple. So no issue with the fact they are not existant or than some classes are not find (because charge with the plugin system which doesn’t work on the old version of PHP 5).

I try with the two version on my local which share the same database. Technically, it works well until I empty the cache on the old website. At this moment, I loose all my endpoint on the new website. They come back when I empty the cache on the new website.

To bypass this issue, I thought to separate cache tables in the database. So each website will have their dedicated cache tables. So I cloned all cache tables and used a different prefix depending the website. But, after adding a prefix, my websites no more work and I have bugs with views and features.

My list of prefix for the website with API is:

$db_prefix = array(   "default" => "main_",   "cache" => "api_",   "cache_bootstrap" => "api_",   "cache_page" => "api_"   ... ); 

I tried to separate all the 21 cache tables. That doesn’t work.

I try to only used prefix for the cache tables and let the default prefix empty. That doesn’t work.

To see if tables prefix works, I tried to simply add the same and unique prefix to all tables of my database on the new website which run without connection with the old website. That doesn’t work and I have the same issue for all my tests when I empty the cache or try to access to one of the website:

PHP Fatal error:  Call to undefined method stdClass::init_display() in /var/www/html/web/sites/default/modules/contrib/views/views.module on line 704  Fatal error: Call to undefined method stdClass::init_display() in /var/www/html/web/sites/default/modules/contrib/views/views.module on line 704 Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                 [error] Error: Call to undefined method stdClass::init_display() in /var/www/html/web/sites/default/modules/contrib/views/views.module, line 704 

There is this ticket https://www.drupal.org/project/views/issues/371049 so I’m exploring views but I don’t know if I don’t forget something when I add my prefixes which create this issue or do something wrong.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Add prefix on tables break my site

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.