A
A
Alexander2016-11-11 00:08:08
MODX
Alexander, 2016-11-11 00:08:08

Modx after moving to another server began to eat memory, why?

On request to some parts of the site, it throws 500 errors
in the PHP logs
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /home/~/public_html/core/model/modx/modresource.class.php on line 881
this is in the getAliasPath method of this class
on line 881

while ($currResource) {
$parentAlias= $currResource['alias'];
                    if (empty ($parentAlias)) {
                        $parentAlias= "{$pathParentId}";
                    }
                    $parentResources[]= "{$parentAlias}";
                    $pathParentId= $currResource['parent'];
881->                    $query->stmt->execute(array($pathParentId));
                    $currResource= $query->stmt->fetch(PDO::FETCH_ASSOC);
                }

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander, 2016-11-11
@kascor

The problem was as follows:
When transferring the database from another server, I did not pay attention to the fact that the import occurred with an error, because. the site is up and running, all the signs are in place.
Import occurs in the following sequence:
1. Creating tables
2. Assigning primary keys and indexes to fields
3. Assigning auto-increment to fields (primary)
4. Adding data
An error occurred at the stage of assigning primary keys, indexes and auto-increments. Because of this, I got tables with data, but without primary keys, indexes and auto-increments, in most of the tables.
In this regard, when adding a new resource, its id was assigned to 0, everything slowed down, etc.
Specifically, the code above hung in an infinite loop.

A
Alexander Aksentiev, 2017-02-03
@Sanasol

sandbox.onlinephpfunctions.com/code/fe7f6498aa7ca8...
works

<?php  
$arr = array(1) { 
  [0]=> array(5) {
    ["tab__button"]=> string(16) "Top Hits, 2000-e" 
    ["repertuar__readmore__text"]=> string(48) "/Смотреть другие концерты/" 
    ["repertuar__readmore__link"]=> string(33) "/cntnt/nas_vybira/nastoyashe.html" 
    ["repertuar__block"]=> array(1) { 
                  [0]=> array(2) { 
                      ["repertuar__video__url"]=> string(199) "url" 
                      ["repertuar__preview"]=> string(76) "http://www./hqdefault.jpg"
  } 
}
?>

what a perversion, why insert the code like that, I was cleaning it ....

A
Alexey, 2017-02-03
@masterfreelance

and like this:

$preview = [];
foreach ($arr as $arr_item) {
  if ( !is_empty($arr_item['repertuar__block']) ) {
    foreach ($arr_item['repertuar__block'] as $arr_i) {	
          $preview[] = $arr_i["repertuar__preview"];  
    }
  }
}
print_r($preview);

F
Fakhridin Jamolidinov, 2017-02-03
@Fahridin

foreach ($arr as $arr) {
    foreach ($arr['repertuar__block'] as $out) {
        echo $out['repertuar__video__url'] . " и " . $out['repertuar__preview'] . "<hr>";
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question