0

I using a plugin that crashes due to lack of memory. But I'm on a host (Pantheon) that uses git for file updates between a Dev server (where I have FTP access) and a Live server (where I have no FTP or SSH access). I can't change wp-config.php and commit the file because the database details are different between Dev and Live. php.ini files are not allowed, and PHP directives in .htaccess are not allowed.

How can I increase PHP memory for Live? Can I add a directive in a theme file? Like functions.php? Will that work for plugin memory?

  • you can try to use the PHP code ini_set("memory_limit", "50G"); because it's to correct a plugin problem, I recommand you to put this code in a another plugin (e.g. a plugin just for this correction) and not in the theme. – mmm Feb 22 '18 at 19:24
  • If you cannot change the content of any files on the live server, then no, it is not possible to the adjust the memory_limit. You can use an ini_set, but a) that doesn't always work on all types of hosting and b) you still need to put it in a file and the most reliable place would be the wp-config.php file. – Otto Feb 22 '18 at 20:00
  • Actually, using a simple plugin with only ini_set("memory_limit", "256M"); works for the most part. My search/replace using the Search Reg Ex plugin to search postmeta didn't crash, like it had been with memory errors. It ain't pretty, but it works for now. And it keeps me from having to go from Pantheon's $25/month plan to $100/month to get 512M. – BlueDogRanch Feb 22 '18 at 20:30
  • WordPress hits index.php before wp config is it possible to add it there? – Joel M Feb 22 '18 at 20:35
  • maybe conditional php ini set based on a url stored in $_SERVER? you can conditionally define functions in php so i imagine you can do this unless somehow php reads this at compile time but i assume it's run time – Joel M Feb 22 '18 at 20:37
0

Using ini_set("memory_limit", "256M"); in a simple plugin works for the most part. Ugly, yes; but it appears to work in my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.