0

Hi I am adding this into my settings.php file as I want the memory to increase when the URL visited contain one these string in the page

if ( (strpos($_GET['q'], 'admin') === 1) ||  ( strpos($_GET['q'], '/media/add/image') === 1) || 
   ( (strpos($_GET['q'], 'node/') === 1 && preg_match('/^node\/[\d]+\/edit/', $_GET['q']) === 1) ) 
   ) {
  ini_set('memory_limit', '256M');
}   }

is this correct? Thanks

mamesaye
  • 2,033
  • 2
  • 32
  • 49
  • I'm not going to validate your actual logic, but according [Acquia](https://support.acquia.com/hc/en-us/articles/360004542293-Conditionally-increasing-memory-limits), yes that is correct. – Chris Haas Oct 22 '20 at 18:17
  • I saw that they used `===0` instead of `===1` why did they do that? my understanding is `===0` means not in the path – mamesaye Oct 22 '20 at 18:25
  • 1
    In PHP (and many other languages), the "first" character is at index `0`, the second is at index `1`, and so on. Now looking at your code, `strpos($_GET['q'], 'admin') === 1` will **not** be true if `$_GET['q']` is `admin`, but will be true if it is `badmin` or `wadmin` or similar. So you probably want zeros. The best way to test this is to put a `die` in there and manually test all the URLs that you expect to behave this way. – Chris Haas Oct 22 '20 at 18:29
  • thanks @ChrisHaas that's help full I will have `===0` everywhere to make sure path have increased memory – mamesaye Oct 22 '20 at 19:07

0 Answers0