问:
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted
Started having this issue on a development server running a WordPress website on Ubuntu 16.04 running Apache 2.4 and PHP 7.0.22. I tried installing fresh WP site and creating a phpinfo() document, the memory_limit shows 4096M. When I try to load the fresh website, I get 500 error with this in the logs:

```<code>[Tue Dec 05 11:31:21.361553 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP Fatal error:  Allowed memory size of 2097152 bytes exhausted (tried to allocate 110592 bytes) in /backup/storage/sites/wp.webtent.org/wp-settings.php on line 116
[Tue Dec 05 11:31:21.361597 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP Stack trace:
[Tue Dec 05 11:31:21.361610 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP   1. {main}() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:0
[Tue Dec 05 11:31:21.361621 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP   2. require() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:33
</code>```

Here is a snapshot of top, doesn't look like a memory issue...

```<code>top - 11:48:45 up 55 min,  2 users,  load average: 0.11, 0.10, 0.18
Tasks: 301 total,   1 running, 300 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.7 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8219672 total,  5059996 free,   802632 used,  2357044 buff/cache
KiB Swap:  4095996 total,  4059280 free,    36716 used.  7306804 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1523 mysql     20   0  551784 159588  15356 S   0.0  1.9   0:01.71 mysqld
 3215 robert    20   0  315180 118948  59092 S   0.0  1.4   0:17.95 compiz
 1716 root      20   0  170716  82768  43328 S   0.0  1.0   0:13.80 Xorg
 3608 robert    20   0  238364  61804  34528 S   0.0  0.8   0:00.25 evolution-alarm
 3073 robert    20   0  175796  61280  36024 S   0.0  0.7   0:00.29 hud-service
 3503 robert    20   0  227640  55264  48908 S   0.0  0.7   0:01.28 nautilus
 3246 robert    20   0  228908  54696  24776 S   0.0  0.7   0:00.13 goa-daemon
 3282 robert    20   0  165504  43108  19348 S   0.0  0.5   0:00.17 evolution-calen
 3345 robert    20   0  159160  37432  10820 S   0.0  0.5   0:00.12 evolution-calen
 3362 robert    20   0  149348  37104  10580 S   0.0  0.5   0:00.12 evolution-calen
 3599 robert    20   0  123568  34508  27464 S   0.0  0.4   0:02.82 gnome-terminal-
  310 root      20   0  139564  31700  25328 S   0.0  0.4   0:00.05 apache2
 3600 robert    20   0  111416  30300  26900 S   0.0  0.4   0:00.17 nm-applet
<snip>
</code>```

Here is what PHP Xdebug trace looks like:

```TRACE START [2017-12-05 16:31:21]
    0.0022     351672  +351672   -> {main}() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:0
    0.0023     351672       +0     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:15
    0.0023     351704      +32     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:20
    0.0023     351736      +32     -> error_reporting() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:27
    0.0023     352064     +328     -> dirname() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0023     352144      +80     -> dirname() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0024     352120      -24     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0044     352712     +592     -> require(/backup/storage/sites/wp.webtent.org/wp-settings.php) /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:33
    0.0044     352712       +0       -> define() /backup/storage/sites/wp.webtent.org/wp-settings.php:16
    0.0079     352992     +280       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/load.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:19
    0.0087     353088      +96       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:20
    0.0099     353184      +96       -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/plugin.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:21
    0.0099     353184       +0         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/plugin.php:25
    0.0108     354648    +1464         -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-hook.php) /backup/storage/sites/wp.webtent.org/wp-includes/plugin.php:25
    0.0109     354776     +128       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/version.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:29
    0.0109     354632     -144       -> wp_initial_constants() /backup/storage/sites/wp.webtent.org/wp-settings.php:41
    0.0109     354632       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:26
    0.0109     354664      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:27
    0.0109     354696      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:28
    0.0109     354728      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:29
    0.0109     354760      +32         -> ini_get() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:32
    0.0109     354784      +24         -> wp_convert_hr_to_bytes() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:33
    0.0110     354784       +0           -> trim() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0110     354784       +0           -> strtolower() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0110     354808      +24           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1000
    0.0110     354808       +0           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1002
    0.0110     354808       +0           -> min() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1009
    0.0110     354784      -24         -> wp_is_ini_value_changeable() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:37
    0.0110     355080     +296           -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1030
    0.0111     355080       +0           -> ini_get_all() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1031
    0.0114     486352  +131272         -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:39
    0.0114     486352       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:42
    0.0114     486384      +32         -> wp_is_ini_value_changeable() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:47
    0.0114     486384       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:50
    0.0114     486440      +56         -> wp_convert_hr_to_bytes() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:57
    0.0114     486440       +0           -> trim() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0114     486440       +0           -> strtolower() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0115     486464      +24           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1000
    0.0115     486464       +0           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1002
    0.0115     486464       +0           -> min() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1009
    0.0115     486504      +40         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:66
    0.0115     486536      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:70
    0.0115     486568      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:75
    0.0115     486600      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:79
    0.0115     486632      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:82
    0.0115     486640       +8         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:88
    0.0115     486640       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:93
    0.0116     486672      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:100
    0.0116     486704      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:103
    0.0116     486736      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:106
    0.0116     486768      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:121
    0.0116     486800      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:122
    0.0116     486832      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:123
    0.0116     486864      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:124
    0.0116     486896      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:125
    0.0116     486928      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:126
    0.0116     486936       +8       -> wp_check_php_mysql_versions() /backup/storage/sites/wp.webtent.org/wp-settings.php:44
    0.0117     486936       +0         -> phpversion() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:123
    0.0117     486976      +40         -> version_compare() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:125
    0.0117     486976       +0         -> extension_loaded() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:135
    0.0117     486976       +0         -> extension_loaded() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:135
    0.0117     486936      -40       -> ini_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:47
    0.0117     486936       +0       -> ini_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:48
    0.0117     486936       +0       -> date_default_timezone_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:51
    0.0117     486944       +8       -> wp_unregister_GLOBALS() /backup/storage/sites/wp.webtent.org/wp-settings.php:54
    0.0118     486944       +0         -> ini_get() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:30
    0.0118     486944       +0       -> wp_fix_server_vars() /backup/storage/sites/wp.webtent.org/wp-settings.php:57
    0.0118     486968      +24         -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:63
    0.0118     487912     +944         -> preg_match() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:66
    0.0119     487912       +0         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:96
    0.0119     487912       +0         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:100
    0.0119     487912       +0       -> wp_favicon_request() /backup/storage/sites/wp.webtent.org/wp-settings.php:60
    0.0119     487912       +0       -> wp_maintenance() /backup/storage/sites/wp.webtent.org/wp-settings.php:63
    0.0119     487992      +80         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:176
    0.0119     487912      -80       -> timer_start() /backup/storage/sites/wp.webtent.org/wp-settings.php:66
    0.0119     487936      +24         -> microtime() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:243
    0.0119     487936       +0       -> wp_debug_mode() /backup/storage/sites/wp.webtent.org/wp-settings.php:69
    0.0120     487936       +0         -> apply_filters() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:316
    0.0120     487936       +0         -> error_reporting() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:333
    0.0120     487960      +24         -> ini_set() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:337
    0.0120     487984      +24       -> wp_set_lang_dir() /backup/storage/sites/wp.webtent.org/wp-settings.php:93
    0.0120     488064      +80         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:356
    0.0120     488064       +0         -> is_dir() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:356
    0.0120     488064       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:364
    0.0120     488096      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:367
    0.0130     488616     +520       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/compat.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:96
    0.0130     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:10
    0.0130     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:44
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:134
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:219
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:278
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:291
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:323
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:361
    0.0131     488616       +0         -> interface_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:417
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:434
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:438
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:497
    0.0136     489640    +1024       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-list-util.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:97
    0.0240     555256   +65616       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/functions.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:98
    0.0275     555504     +248         -> require(/backup/storage/sites/wp.webtent.org/wp-includes/option.php) /backup/storage/sites/wp.webtent.org/wp-includes/functions.php:8
    0.0277     555944     +440       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-matchesmapregex.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:99
    0.0294     557080    +1136       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:100
    0.0297     557880     +800       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-error.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:101
    0.0306     624208   +66328       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:102
    0.0306     624208       +0         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:10
    0.0314     626112    +1904         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:10
    0.0314     626112       +0           -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:10
    0.0321     627992    +1880           -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/plural-forms.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:10
    0.0321     627824     -168           -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:11
    0.0324     628904    +1080           -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/entry.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:11
    0.0324     628904       +0             -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/entry.php:10
    0.0324     628736     -168           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:13
    0.0324     629664     +928           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:278
    0.0325     629488     -176         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:11
    0.0331     631600    +2112         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:11
    0.0331     631600       +0           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:11
    0.0331     631600       +0           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:137
    0.0331     632528     +928           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:207
    0.0332     633232     +704           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:270
    0.0332     634176     +944           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:295
    0.0332     634944     +768         -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:13
    0.0332     635272     +328       -> require_wp_db() /backup/storage/sites/wp.webtent.org/wp-settings.php:106
    0.0390     642704    +7432         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php) /backup/storage/sites/wp.webtent.org/wp-includes/load.php:396
    0.0390     642704       +0           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:15
    0.0390     642736      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:20
    0.0390     642768      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:21
    0.0390     642800      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:26
    0.0390     642832      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:31
    0.0391     642864      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:36
    0.0391     642808      -56         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:397
    0.0391     643752     +944         -> wpdb->__construct() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:404
    0.0391     644024     +272           -> register_shutdown_function() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:568
    0.0391     644320     +296           -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:579
    0.0392     644320       +0           -> phpversion() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:582
    0.0392     644360      +40           -> version_compare() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:582
    0.0392     644320      -40       -> wp_set_wpdb_vars() /backup/storage/sites/wp.webtent.org/wp-settings.php:110
    0.0392     644648     +328         -> wpdb->__isset() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:421
    0.0392     644624      -24         -> wpdb->set_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:432
    0.0392     644624       +0           -> preg_match() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:862
    0.0393     644624       +0           -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:865
    0.0393     644624       +0           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:873
    0.0393     644624       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:978
    0.0393     644624       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0393     644624       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0393     644624       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0393     645120     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0394     645416     +296             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0394     644680     -736           -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:876
    0.0394     644680       +0           -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:879
    0.0394     644680       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0394     644680       +0           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:881
    0.0394     644680       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0394     644680       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0394     644680       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0394     645176     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645696     +520             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645728      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645752      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645776      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645808      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645832      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645864      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645904      +40             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0472     645936      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0472     644976     -960           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:884
    0.0472     644976       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0472     644976       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0472     644976       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0472     645472     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645776     +304             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645808      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645376     -432           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     645376       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0473     647224    +1848           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     647224       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0473     647232       +8           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     647232       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0474     646936     -296         -> is_wp_error() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:434
    0.0474     646936       +0       -> wp_start_object_cache() /backup/storage/sites/wp.webtent.org/wp-settings.php:113
    0.0474     646936       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:480
    0.0474     647032      +96         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:481
    0.0474     646936      -96         -> wp_using_ext_object_cache() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:504
    0.0485     648424    +1488         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/cache.php) /backup/storage/sites/wp.webtent.org/wp-includes/load.php:505
    0.0485     648256     -168         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:515
    0.0485     648256       +0         -> wp_cache_init() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:516
    0.0485     648416     +160           -> WP_Object_Cache->__construct() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:153
    0.0485     648416       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:709
    0.0486     648688     +272             -> register_shutdown_function() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:717
    0.0486     648712      +24         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:519
    0.0486     648712       +0         -> wp_cache_add_global_groups() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:520
    0.0486     648736      +24           -> WP_Object_Cache->add_global_groups() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:233
    0.0486     648736       +0             -> array_fill_keys() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:428
    0.0486     649232     +496             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:429
    0.0486     649232       +0         -> wp_cache_add_non_persistent_groups() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:521
    0.0498    1023056  +373824       -> wpdb->__destruct() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:0
    0.0498    1023056       +0       -> WP_Object_Cache->__destruct() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:0
    0.0500     374368
TRACE END   [2017-12-05 16:31:21]
```

I don't have any experience with Xdebug, what does this tell me?

答:
You can see here  http://prntscr.com/agxrtt

So change ini_set('Memory_limit','-1') to ini_set('memory_limit',256) or ini_set('memory_limit','-1')

Body:
Started having this issue on a development server running a WordPress website on Ubuntu 16.04 running Apache 2.4 and PHP 7.0.22. I tried installing fresh WP site and creating a phpinfo() document, the memory_limit shows 4096M. When I try to load the fresh website, I get 500 error with this in the logs:

[Tue Dec 05 11:31:21.361553 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP Fatal error:  Allowed memory size of 2097152 bytes exhausted (tried to allocate 110592 bytes) in /backup/storage/sites/wp.webtent.org/wp-settings.php on line 116
[Tue Dec 05 11:31:21.361597 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP Stack trace:
[Tue Dec 05 11:31:21.361610 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP   1. {main}() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:0
[Tue Dec 05 11:31:21.361621 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP   2. require() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:33

Here is a snapshot of top, doesn't look like a memory issue...

top - 11:48:45 up 55 min,  2 users,  load average: 0.11, 0.10, 0.18
Tasks: 301 total,   1 running, 300 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.7 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8219672 total,  5059996 free,   802632 used,  2357044 buff/cache
KiB Swap:  4095996 total,  4059280 free,    36716 used.  7306804 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1523 mysql     20   0  551784 159588  15356 S   0.0  1.9   0:01.71 mysqld
 3215 robert    20   0  315180 118948  59092 S   0.0  1.4   0:17.95 compiz
 1716 root      20   0  170716  82768  43328 S   0.0  1.0   0:13.80 Xorg
 3608 robert    20   0  238364  61804  34528 S   0.0  0.8   0:00.25 evolution-alarm
 3073 robert    20   0  175796  61280  36024 S   0.0  0.7   0:00.29 hud-service
 3503 robert    20   0  227640  55264  48908 S   0.0  0.7   0:01.28 nautilus
 3246 robert    20   0  228908  54696  24776 S   0.0  0.7   0:00.13 goa-daemon
 3282 robert    20   0  165504  43108  19348 S   0.0  0.5   0:00.17 evolution-calen
 3345 robert    20   0  159160  37432  10820 S   0.0  0.5   0:00.12 evolution-calen
 3362 robert    20   0  149348  37104  10580 S   0.0  0.5   0:00.12 evolution-calen
 3599 robert    20   0  123568  34508  27464 S   0.0  0.4   0:02.82 gnome-terminal-
  310 root      20   0  139564  31700  25328 S   0.0  0.4   0:00.05 apache2
 3600 robert    20   0  111416  30300  26900 S   0.0  0.4   0:00.17 nm-applet
<snip>

Here is what PHP Xdebug trace looks like:

TRACE START [2017-12-05 16:31:21]
    0.0022     351672  +351672   -> {main}() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:0
    0.0023     351672       +0     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:15
    0.0023     351704      +32     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:20
    0.0023     351736      +32     -> error_reporting() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:27
    0.0023     352064     +328     -> dirname() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0023     352144      +80     -> dirname() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0024     352120      -24     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0044     352712     +592     -> require(/backup/storage/sites/wp.webtent.org/wp-settings.php) /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:33
    0.0044     352712       +0       -> define() /backup/storage/sites/wp.webtent.org/wp-settings.php:16
    0.0079     352992     +280       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/load.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:19
    0.0087     353088      +96       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:20
    0.0099     353184      +96       -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/plugin.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:21
    0.0099     353184       +0         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/plugin.php:25
    0.0108     354648    +1464         -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-hook.php) /backup/storage/sites/wp.webtent.org/wp-includes/plugin.php:25
    0.0109     354776     +128       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/version.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:29
    0.0109     354632     -144       -> wp_initial_constants() /backup/storage/sites/wp.webtent.org/wp-settings.php:41
    0.0109     354632       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:26
    0.0109     354664      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:27
    0.0109     354696      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:28
    0.0109     354728      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:29
    0.0109     354760      +32         -> ini_get() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:32
    0.0109     354784      +24         -> wp_convert_hr_to_bytes() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:33
    0.0110     354784       +0           -> trim() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0110     354784       +0           -> strtolower() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0110     354808      +24           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1000
    0.0110     354808       +0           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1002
    0.0110     354808       +0           -> min() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1009
    0.0110     354784      -24         -> wp_is_ini_value_changeable() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:37
    0.0110     355080     +296           -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1030
    0.0111     355080       +0           -> ini_get_all() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1031
    0.0114     486352  +131272         -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:39
    0.0114     486352       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:42
    0.0114     486384      +32         -> wp_is_ini_value_changeable() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:47
    0.0114     486384       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:50
    0.0114     486440      +56         -> wp_convert_hr_to_bytes() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:57
    0.0114     486440       +0           -> trim() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0114     486440       +0           -> strtolower() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0115     486464      +24           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1000
    0.0115     486464       +0           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1002
    0.0115     486464       +0           -> min() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1009
    0.0115     486504      +40         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:66
    0.0115     486536      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:70
    0.0115     486568      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:75
    0.0115     486600      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:79
    0.0115     486632      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:82
    0.0115     486640       +8         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:88
    0.0115     486640       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:93
    0.0116     486672      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:100
    0.0116     486704      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:103
    0.0116     486736      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:106
    0.0116     486768      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:121
    0.0116     486800      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:122
    0.0116     486832      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:123
    0.0116     486864      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:124
    0.0116     486896      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:125
    0.0116     486928      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:126
    0.0116     486936       +8       -> wp_check_php_mysql_versions() /backup/storage/sites/wp.webtent.org/wp-settings.php:44
    0.0117     486936       +0         -> phpversion() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:123
    0.0117     486976      +40         -> version_compare() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:125
    0.0117     486976       +0         -> extension_loaded() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:135
    0.0117     486976       +0         -> extension_loaded() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:135
    0.0117     486936      -40       -> ini_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:47
    0.0117     486936       +0       -> ini_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:48
    0.0117     486936       +0       -> date_default_timezone_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:51
    0.0117     486944       +8       -> wp_unregister_GLOBALS() /backup/storage/sites/wp.webtent.org/wp-settings.php:54
    0.0118     486944       +0         -> ini_get() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:30
    0.0118     486944       +0       -> wp_fix_server_vars() /backup/storage/sites/wp.webtent.org/wp-settings.php:57
    0.0118     486968      +24         -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:63
    0.0118     487912     +944         -> preg_match() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:66
    0.0119     487912       +0         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:96
    0.0119     487912       +0         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:100
    0.0119     487912       +0       -> wp_favicon_request() /backup/storage/sites/wp.webtent.org/wp-settings.php:60
    0.0119     487912       +0       -> wp_maintenance() /backup/storage/sites/wp.webtent.org/wp-settings.php:63
    0.0119     487992      +80         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:176
    0.0119     487912      -80       -> timer_start() /backup/storage/sites/wp.webtent.org/wp-settings.php:66
    0.0119     487936      +24         -> microtime() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:243
    0.0119     487936       +0       -> wp_debug_mode() /backup/storage/sites/wp.webtent.org/wp-settings.php:69
    0.0120     487936       +0         -> apply_filters() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:316
    0.0120     487936       +0         -> error_reporting() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:333
    0.0120     487960      +24         -> ini_set() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:337
    0.0120     487984      +24       -> wp_set_lang_dir() /backup/storage/sites/wp.webtent.org/wp-settings.php:93
    0.0120     488064      +80         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:356
    0.0120     488064       +0         -> is_dir() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:356
    0.0120     488064       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:364
    0.0120     488096      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:367
    0.0130     488616     +520       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/compat.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:96
    0.0130     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:10
    0.0130     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:44
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:134
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:219
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:278
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:291
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:323
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:361
    0.0131     488616       +0         -> interface_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:417
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:434
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:438
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:497
    0.0136     489640    +1024       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-list-util.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:97
    0.0240     555256   +65616       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/functions.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:98
    0.0275     555504     +248         -> require(/backup/storage/sites/wp.webtent.org/wp-includes/option.php) /backup/storage/sites/wp.webtent.org/wp-includes/functions.php:8
    0.0277     555944     +440       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-matchesmapregex.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:99
    0.0294     557080    +1136       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:100
    0.0297     557880     +800       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-error.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:101
    0.0306     624208   +66328       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:102
    0.0306     624208       +0         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:10
    0.0314     626112    +1904         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:10
    0.0314     626112       +0           -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:10
    0.0321     627992    +1880           -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/plural-forms.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:10
    0.0321     627824     -168           -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:11
    0.0324     628904    +1080           -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/entry.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:11
    0.0324     628904       +0             -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/entry.php:10
    0.0324     628736     -168           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:13
    0.0324     629664     +928           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:278
    0.0325     629488     -176         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:11
    0.0331     631600    +2112         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:11
    0.0331     631600       +0           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:11
    0.0331     631600       +0           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:137
    0.0331     632528     +928           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:207
    0.0332     633232     +704           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:270
    0.0332     634176     +944           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:295
    0.0332     634944     +768         -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:13
    0.0332     635272     +328       -> require_wp_db() /backup/storage/sites/wp.webtent.org/wp-settings.php:106
    0.0390     642704    +7432         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php) /backup/storage/sites/wp.webtent.org/wp-includes/load.php:396
    0.0390     642704       +0           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:15
    0.0390     642736      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:20
    0.0390     642768      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:21
    0.0390     642800      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:26
    0.0390     642832      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:31
    0.0391     642864      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:36
    0.0391     642808      -56         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:397
    0.0391     643752     +944         -> wpdb->__construct() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:404
    0.0391     644024     +272           -> register_shutdown_function() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:568
    0.0391     644320     +296           -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:579
    0.0392     644320       +0           -> phpversion() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:582
    0.0392     644360      +40           -> version_compare() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:582
    0.0392     644320      -40       -> wp_set_wpdb_vars() /backup/storage/sites/wp.webtent.org/wp-settings.php:110
    0.0392     644648     +328         -> wpdb->__isset() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:421
    0.0392     644624      -24         -> wpdb->set_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:432
    0.0392     644624       +0           -> preg_match() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:862
    0.0393     644624       +0           -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:865
    0.0393     644624       +0           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:873
    0.0393     644624       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:978
    0.0393     644624       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0393     644624       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0393     644624       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0393     645120     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0394     645416     +296             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0394     644680     -736           -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:876
    0.0394     644680       +0           -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:879
    0.0394     644680       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0394     644680       +0           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:881
    0.0394     644680       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0394     644680       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0394     644680       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0394     645176     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645696     +520             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645728      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645752      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645776      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645808      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645832      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645864      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645904      +40             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0472     645936      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0472     644976     -960           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:884
    0.0472     644976       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0472     644976       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0472     644976       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0472     645472     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645776     +304             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645808      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645376     -432           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     645376       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0473     647224    +1848           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     647224       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0473     647232       +8           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     647232       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0474     646936     -296         -> is_wp_error() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:434
    0.0474     646936       +0       -> wp_start_object_cache() /backup/storage/sites/wp.webtent.org/wp-settings.php:113
    0.0474     646936       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:480
    0.0474     647032      +96         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:481
    0.0474     646936      -96         -> wp_using_ext_object_cache() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:504
    0.0485     648424    +1488         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/cache.php) /backup/storage/sites/wp.webtent.org/wp-includes/load.php:505
    0.0485     648256     -168         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:515
    0.0485     648256       +0         -> wp_cache_init() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:516
    0.0485     648416     +160           -> WP_Object_Cache->__construct() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:153
    0.0485     648416       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:709
    0.0486     648688     +272             -> register_shutdown_function() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:717
    0.0486     648712      +24         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:519
    0.0486     648712       +0         -> wp_cache_add_global_groups() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:520
    0.0486     648736      +24           -> WP_Object_Cache->add_global_groups() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:233
    0.0486     648736       +0             -> array_fill_keys() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:428
    0.0486     649232     +496             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:429
    0.0486     649232       +0         -> wp_cache_add_non_persistent_groups() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:521
    0.0498    1023056  +373824       -> wpdb->__destruct() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:0
    0.0498    1023056       +0       -> WP_Object_Cache->__destruct() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:0
    0.0500     374368
TRACE END   [2017-12-05 16:31:21]

I don't have any experience with Xdebug, what does this tell me?


来源: stackexchange

问:
Create a singleton class with react native
I found different topics explain how to create a singleton, but none of them worked for me. This is an example taken from this post

```<code>export default class Credentials {

    static myInstance = null;

    _userID = "";

    static getInstance() {
        if (myInstance == null) {
            myInstance = new Credentials();
        }

        return myInstance;
    }

    getUserID() {
        return this._userID;
    }

    setUserID(id) {
        this._userID = id;
    }
}
</code>```

when I call Credentials.getInstance() I get a warning

Can't find variable myInstance

答:
JS has no implicit field lookup like statically-compiled languages. You need to lookup variables on the class explicitly:

```<code>class Credentials {

    static myInstance = null;

    static getInstance() {
      if (Credentials.myInstance == null) {
        Credentials.myInstance = new Credentials();
      }

      return Credentials.myInstance;
    }
}
</code>```

Be careful with this approach since it's not truly a singleton because JS doesn't have proper class encapsulation.

You could change the instance directly easily:

```<code>Credentials.myInstance = 'something else';
</code>```

Proper singleton with encapsulation should be implemented via a closure:

```<code>const Credentials = (() => {
  let myInstance = null;
  return class Credentials {
    static getInstance() {
      if (myInstance == null) {
        myInstance = new Credentials();
      }
      return myInstance;
    }
  }
})()
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I found different topics explain how to create a singleton, but none of them worked for me. This is an example taken from this post

export default class Credentials {

    static myInstance = null;

    _userID = "";

    static getInstance() {
        if (myInstance == null) {
            myInstance = new Credentials();
        }

        return myInstance;
    }

    getUserID() {
        return this._userID;
    }

    setUserID(id) {
        this._userID = id;
    }
}

when I call Credentials.getInstance() I get a warning

Can't find variable myInstance

Body:
JS has no implicit field lookup like statically-compiled languages. You need to lookup variables on the class explicitly:

class Credentials {

    static myInstance = null;

    static getInstance() {
      if (Credentials.myInstance == null) {
        Credentials.myInstance = new Credentials();
      }

      return Credentials.myInstance;
    }
}

Be careful with this approach since it's not truly a singleton because JS doesn't have proper class encapsulation.

You could change the instance directly easily:

Credentials.myInstance = 'something else';

Proper singleton with encapsulation should be implemented via a closure:

const Credentials = (() => {
  let myInstance = null;
  return class Credentials {
    static getInstance() {
      if (myInstance == null) {
        myInstance = new Credentials();
      }
      return myInstance;
    }
  }
})()

ContentLicense: CC BY-SA 3.0


问:
C# add Scrollbars to Panel with big BackgroundImage
I'm very new in c# and visual studio and i try a little bit to learn.
my problem is i have created a winform and a panel in it. this panel have a background image with a bigger size as the panel, i want to see the picture in orginal size in the panel with scrollbars in the sites and i want create buttons on this panel but the panel dont create automatic scrollbars. how i can solve this ? i tried it to set the width and height but this dont work.

```<code>Image myimage = new Bitmap(imgPath);
maleTreePanel.BackgroundImage = myimage;
</code>```

i create the panel and set later the background image

答:
One method is to set maleTreePanel width and height dynamically like

```<code>maleTreePanel.Width = myimage.Width;
maleTreePanel.Height = myimage.Height;
</code>```

and put maleTreePanel inside another smaller panel that has AutoScroll = true. The smaller panel will effectively act as your viewing area for the larger one.

Body:
I'm very new in c# and visual studio and i try a little bit to learn.
my problem is i have created a winform and a panel in it. this panel have a background image with a bigger size as the panel, i want to see the picture in orginal size in the panel with scrollbars in the sites and i want create buttons on this panel but the panel dont create automatic scrollbars. how i can solve this ? i tried it to set the width and height but this dont work.

Image myimage = new Bitmap(imgPath);
maleTreePanel.BackgroundImage = myimage;

i create the panel and set later the background image

Body:
One method is to set maleTreePanel width and height dynamically like

maleTreePanel.Width = myimage.Width;
maleTreePanel.Height = myimage.Height;

and put maleTreePanel inside another smaller panel that has AutoScroll = true. The smaller panel will effectively act as your viewing area for the larger one.


问:
How to NSLog pixel RGB from a UIImage?
I just want to:

1) Copy the pixel data.

2) Iterate and Modify each pixel (just show me how to NSLog the ARGB values as 255)

3) Create a UIImage from the new pixel data

I can figure out the the gory details if someone can just tell me how to NSLog the RGBA values of a pixel as 255. How do I modify the following code to do this? Be Specific Please!

```<code>-(UIImage*)modifyPixels:(UIImage*)originalImage
{

NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(originalImage.CGImage));
uint myLength = [pixelData length];

    for(int i = 0; i < myLength; i += 4) {

        //CHANGE PIXELS HERE
        /*
        Sidenote: Just show me how to NSLog them
        */
        //Example:
        //NSLog(@"Alpha 255-Value is: %u", data[i]);
        //NSLog(@"Red 255-Value is: %u", data[i+1]);
        //NSLog(@"Green 255-Value is: %u", data[i+2]);
        //NSLog(@"Blue 255-Value is: %u", data[i+3]);
    }

    //CREATE NEW UIIMAGE (newImage) HERE

    return newImage;
}
</code>```

答:
If you'd like to actually see the image, you can use Florent Pillet's NSLogger:
https://github.com/fpillet/NSLogger

The idea is you start the NSLogger client on your desktop, and then in your app you put this up towards the top:

```<code>#import "LoggerClient.h"
</code>```

And in your modifyPixels method you can do something like this:

```<code>LogImageData(@"RexOnRoids",        // Any identifier to go along with the log
             0,                    // Log level
             newImage.size.width,  // Image width
             newImage.size.height, // Image height
             UIImagePNGRepresentation(newImage)); // Image as PNG
</code>```

Start the client on your desktop, and then run the app on your iphone, and you'll see real images appear in the client.  VERY handy for debugging image problems such as flipping, rotating, colors, alpha, etc.

ContentLicense: CC BY-SA 2.5

Title: How to NSLog pixel RGB from a UIImage?

Body:
I just want to:

1) Copy the pixel data.

2) Iterate and Modify each pixel (just show me how to NSLog the ARGB values as 255)

3) Create a UIImage from the new pixel data

I can figure out the the gory details if someone can just tell me how to NSLog the RGBA values of a pixel as 255. How do I modify the following code to do this? Be Specific Please!

-(UIImage*)modifyPixels:(UIImage*)originalImage
{

NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(originalImage.CGImage));
uint myLength = [pixelData length];

    for(int i = 0; i < myLength; i += 4) {

        //CHANGE PIXELS HERE
        /*
        Sidenote: Just show me how to NSLog them
        */
        //Example:
        //NSLog(@"Alpha 255-Value is: %u", data[i]);
        //NSLog(@"Red 255-Value is: %u", data[i+1]);
        //NSLog(@"Green 255-Value is: %u", data[i+2]);
        //NSLog(@"Blue 255-Value is: %u", data[i+3]);
    }

    //CREATE NEW UIIMAGE (newImage) HERE

    return newImage;
}

Body:
If you'd like to actually see the image, you can use Florent Pillet's NSLogger:
https://github.com/fpillet/NSLogger

The idea is you start the NSLogger client on your desktop, and then in your app you put this up towards the top:

#import "LoggerClient.h"

And in your modifyPixels method you can do something like this:

LogImageData(@"RexOnRoids",        // Any identifier to go along with the log
             0,                    // Log level
             newImage.size.width,  // Image width
             newImage.size.height, // Image height
             UIImagePNGRepresentation(newImage)); // Image as PNG

Start the client on your desktop, and then run the app on your iphone, and you'll see real images appear in the client.  VERY handy for debugging image problems such as flipping, rotating, colors, alpha, etc.


问:
Why is Toast notification using OnLaunched instead of OnActivated in windows 10 app?
When clicking on my Toast notification the OnLaunched method is being called instead of the OnActivated.  And nothing is in the e.Arguments - any ideas?

My Toast template is the default Visual Studio Server Explorer template:

```<code><?xml version="1.0" encoding="utf-8"?>
<toast>
  <visual>
    <binding template="ToastText01">
      <text id="1">Test message</text>
    </binding>
  </visual>
</toast>
</code>```

答:
It was so silly, so the default test toast created in Visual Studio has the template set as "ToastText01" but it should be "ToastGeneric"</p>

```<code><?xml version="1.0" encoding="utf-8"?>
<toast>
  <visual>
    <binding template="ToastGeneric">
      <text id="1">Test message</text>
    </binding>
  </visual>
</toast>
</code>```

Body:
When clicking on my Toast notification the OnLaunched method is being called instead of the OnActivated.  And nothing is in the e.Arguments - any ideas?

My Toast template is the default Visual Studio Server Explorer template:

<?xml version="1.0" encoding="utf-8"?>
<toast>
  <visual>
    <binding template="ToastText01">
      <text id="1">Test message</text>
    </binding>
  </visual>
</toast>

Body:
It was so silly, so the default test toast created in Visual Studio has the template set as "ToastText01" but it should be "ToastGeneric"

<?xml version="1.0" encoding="utf-8"?>
<toast>
  <visual>
    <binding template="ToastGeneric">
      <text id="1">Test message</text>
    </binding>
  </visual>
</toast>


问:
Add a Right-Click Event to dynamic created Buttons in c#
```<code>List<Button> buttonlist = new List<Button>();
for(int i = 0; i< 5;i++){
Button but = new Button();
but.Name = Convert.ToString(i);
but.Location = new Point(50 + i * 20, 50);
but.Size = new Size(20,20);
buttonlist.Add(but);
but.Click += delegate {
//It's a Leftclick
//Code do stuff
 }
this.Controls.Add(but);
}
</code>```

At the moment I'm making a little Puzzle-Game with C# in Visual Studio 2017.
I create some Buttons dynamicly and when I make a Left-Click on it, it do some stuff. At the moment, nothing happen, when I right-click it.
I don't know how to add a "Right-Click" Event for each Button. The should all do the same if I right-click it.

Have someone a solution for this?

Thanks

答:
It's because you're using the wrong click event handler. Don't use MouseClick, it doesn't allow right-clicks.

```<code>using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace Anything
{
    public class Program
    {
        public static void Main(string[] _)
        {
            var form = new Form();
            List<Button> buttonlist = new List<Button>();
            for (int i = 0; i < 5; i++)
            {
                Button but = new Button();
                but.Name = Convert.ToString(i);
                but.Location = new Point(50 + i * 20, 50);
                but.Size = new Size(20, 20);
                buttonlist.Add(but);
                but.MouseUp += (s, args) =>
                {
                    if (args.Button == MouseButtons.Right)
                    {
                        // do your thing
                    }
                };
                form.Controls.Add(but);
            }

            form.ShowDialog();

            Console.ReadKey();
        }
    }
}
</code>```

Body:
List<Button> buttonlist = new List<Button>();
for(int i = 0; i< 5;i++){
Button but = new Button();
but.Name = Convert.ToString(i);
but.Location = new Point(50 + i * 20, 50);
but.Size = new Size(20,20);
buttonlist.Add(but);
but.Click += delegate {
//It's a Leftclick
//Code do stuff
 }
this.Controls.Add(but);
}

At the moment I'm making a little Puzzle-Game with C# in Visual Studio 2017.
I create some Buttons dynamicly and when I make a Left-Click on it, it do some stuff. At the moment, nothing happen, when I right-click it.
I don't know how to add a "Right-Click" Event for each Button. The should all do the same if I right-click it.

Have someone a solution for this?

Thanks

Body:
It's because you're using the wrong click event handler. Don't use MouseClick, it doesn't allow right-clicks.

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace Anything
{
    public class Program
    {
        public static void Main(string[] _)
        {
            var form = new Form();
            List<Button> buttonlist = new List<Button>();
            for (int i = 0; i < 5; i++)
            {
                Button but = new Button();
                but.Name = Convert.ToString(i);
                but.Location = new Point(50 + i * 20, 50);
                but.Size = new Size(20, 20);
                buttonlist.Add(but);
                but.MouseUp += (s, args) =>
                {
                    if (args.Button == MouseButtons.Right)
                    {
                        // do your thing
                    }
                };
                form.Controls.Add(but);
            }

            form.ShowDialog();

            Console.ReadKey();
        }
    }
}


问:
React Grid System equivalent to Bootstrap's Grid system?
I'm looking to start styling my React app. I have previously used Bootstrap's Grid system and am now looking for the React grid system. What do React developers commonly use for their App's Grid system / Layout? </p>

Body:
Take a look at fluid-react I built. It doesn't need extra CSS.

<Container>
    <Row>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">1</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">2</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">3</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">4</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">5</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">6</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">7</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">8</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">9</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">10</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">11</Col>
        <Col xs="12" sm="6" md="4" lg="3" xl="2">12</Col>
    </Row>
</Container>


问:
How to configure SQLAlchemy session.flush() periodically
Is there a way that when creating a session object, I could configure it to execute flush() periodically?

The reason I need this feature is because under the scope of a session, it is running a non-short background job in memory. I want the program to update the progress of the job with DB periodically using flush(), so that my client can query the progress from DB.

Currently, my solution is using another thread that periodically executes session.flush().

Thanks!

答:
You do not need to call session.flush() again and again in your code. By default in SqlAlchmey autoflush is set to True. Which means any update, delete, insert operations are already added to transeaction for commit. So any query to DB always get the latest data as i't unit of work pattern that even if a select query is fired the uncommiteed changes should be commited first.

```<code>In [8]: session.autoflush
Out[8]: True

In [9]: session.autocommit
Out[9]: False
</code>```

Body:
You do not need to call session.flush() again and again in your code. By default in SqlAlchmey autoflush is set to True. Which means any update, delete, insert operations are already added to transeaction for commit. So any query to DB always get the latest data as i't unit of work pattern that even if a select query is fired the uncommiteed changes should be commited first.

In [8]: session.autoflush
Out[8]: True

In [9]: session.autocommit
Out[9]: False


问:
Bottom Menu bar with submenu
Im using the BottomNavigationViewEx library to display a Bottom Menu Bar in my android app, the library works well and fixes many of the shortcomings of the standard BottomNavigationView.

The problem comes when as per requirements I need to show 7 options in the menu, with 4 options being the direct access to their respective functionality and a "More" option, that should show a submenu with 3 more options (similar to a toolbar with items with property showAsAction="never")

Since the library does not admit more than 5 items and does not support submenus either I've been trying to implement a solution to no avail. Is there a way to implement this or any other bottom menu library that I could use that implements submenus (or lets me extend it to create a submenu)?

答: Even though Adil's answer could have worked, I didn't go for it since it could create other problems. So I ended up making a Popup Menu anchored to the last menu item in the BottomNavigationView</p>

Title: Bottom Menu bar with submenu


问:
Is there a Python equivalent of the Haskell 'let'
Is there a Python equivalent of the Haskell 'let' expression that would allow me to write something like:

```<code>list2 = [let (name,size)=lookup(productId) in (barcode(productId),metric(size))
            for productId in list]
</code>```

If not, what would be the most readable alternative?

Added for clarification of the let syntax:

```<code>x = let (name,size)=lookup(productId) in (barcode(productId),metric(size))
</code>```

is equivalent to

```<code>(name,size) = lookup(productId)
x = (barcode(productId),metric(size))
</code>```

The second version doesn't work that well with list comprehensions, though.

答:
Since you asked for best readability you could consider the lambda-option but with a small twist: initialise the arguments. Here are various options I use myself, starting with the first I tried and ending with the one I use most now.

Suppose we have a function (not shown) which gets data_structure as argument, and you need to get x from it repeatedly.

First try (as per 2012 answer from huon):

```<code>(lambda x:
    x * x + 42 * x)
  (data_structure['a']['b'])
</code>```

With multiple symbols this becomes less readable, so next I tried:

```<code>(lambda x, y:
    x * x + 42 * x + y)
  (x = data_structure['a']['b'],
   y = 16)
</code>```

That is still not very readable as it repeats the symbolic names. So then I tried:

```<code>(lambda x = data_structure['a']['b'],
        y = 16:
  x * x + 42 * x + y)()
</code>```

This almost reads as an 'let' expression. The positioning and formatting of the assignments is yours of course.

This idiom is easily recognised by the starting '(' and the ending '()'.

In functional expressions (also in Python), many parenthesis tend to pile up at the end. The odd one out '(' is easily spotted.

Body:
Is there a Python equivalent of the Haskell 'let' expression that would allow me to write something like:

list2 = [let (name,size)=lookup(productId) in (barcode(productId),metric(size))
            for productId in list]

If not, what would be the most readable alternative?

Added for clarification of the let syntax:

x = let (name,size)=lookup(productId) in (barcode(productId),metric(size))

is equivalent to

(name,size) = lookup(productId)
x = (barcode(productId),metric(size))

The second version doesn't work that well with list comprehensions, though.

Body:
Since you asked for best readability you could consider the lambda-option but with a small twist: initialise the arguments. Here are various options I use myself, starting with the first I tried and ending with the one I use most now.

Suppose we have a function (not shown) which gets data_structure as argument, and you need to get x from it repeatedly.

First try (as per 2012 answer from huon):

(lambda x:
    x * x + 42 * x)
  (data_structure['a']['b'])

With multiple symbols this becomes less readable, so next I tried:

(lambda x, y:
    x * x + 42 * x + y)
  (x = data_structure['a']['b'],
   y = 16)

That is still not very readable as it repeats the symbolic names. So then I tried:

(lambda x = data_structure['a']['b'],
        y = 16:
  x * x + 42 * x + y)()

This almost reads as an 'let' expression. The positioning and formatting of the assignments is yours of course.

This idiom is easily recognised by the starting '(' and the ending '()'.

In functional expressions (also in Python), many parenthesis tend to pile up at the end. The odd one out '(' is easily spotted.


问:
Using Cocoa delegate in a Carbon Objective c++ app
I hope someone will be able to help me since this issue is killing my productivity..
One week on this even if I am quite new to Mac development.

I have a Carbon application in which I want to add a feature:
Get the path of a file I double clicked in the finder.

I have

modified the project to allow Objective C calls.

setup a delegate object and assigned it to NSApp

implemented - (BOOL)application:(NSApplication *)app openFile:(NSString *)filename
in the delegate.

the problem: the delegate method is NOT hit when double click a file in the finder.

I am sure I am missing something (memory/scope issue ? Event loop issue (using RunApplicationEventLoop for now)

If somebody has an hint I would be pleased to hear it.

Thank you all.

答: In a Carbon application, NSApp will be nil. NSApp is defined during the NSApplicationMain function, which is called to start a Cocoa application. In a Carbon application, you need to use Carbon methods to determine when an application is being opened. Install an event handler and listen for the 'odoc' apple event.</p>


问:
php doesn't get data from ajax
What I'm doing is I want to detect which reply button I click and send its index to php.

jQuery:

```<code>$(".reply").each(function (index5) {

$(".reply_button").each(function (index_b) {

            if(index_b==index5){
                $(this).on("click",function (e) {
                    e.preventDefault();
                    var $this = $(this)
                    $.ajax({
                        type:"POST",
                        url:"/yyqGS/public/form/reply.php",
                        data:{index:index_b},
                        dataType: "json",
                        success:function (d) {
                            console.log(d);
                        }
                    });
                })
            }
        });
});
</code>```

PHP:

```<code> <?php
    $n = $_POST['index'];
    echo $n+1;
</code>```

I want to pass the variable index_b to php the file, so that $_POST['index'] can get the value.

But the result on php page is 1, which means it doesn't get the value of index_b from ajax.

On the other hand, what is showed on console is, HOWEVER, correct number! Like, if I click the first reply button, it shows 1, if I click second, it shows 2, and so on...

```<code>result on php: always 1.

result on console: correct number.
</code>```

I couldn't figure out how it happened!

UPDATE:
so i changed console.log() to submit(), i want ajax would send the index to php first, and then another a form will send like 'text' i type to php. But, what's on php page is still 1.

$this.parent() is a form.

So what i really want to do is i want to send the variable index_b to php, and also, at the same time, send those input data to php. So i can use them both.

```<code>$(".reply_button").each(function (index_b) {

            if(index_b==index5){
                $(this).on("click",function (e) {
                    e.preventDefault();
                    var $this = $(this)
                    $.ajax({
                        type:"POST",
                        url:"/yyqGS/public/form/reply.php",
                        data:{index:index_b},
                        success:function (d) {
                            $this.parent().submit();
                        }
                    });
                })
            }
        });
</code>```

答:
Your PHP page doesn't store the $_POST value in any way - it receives the data through the ajax request (or other requests that send $_POST['index'] data).

When you go to form.php directly, it doesn't know what value $_POST['index'] has (because it's not set) so it uses zero (0) in the math formula. Thus, always outputs one (1).

If you wanted to be able to quickly test the form.php page directly, you could change $_POST['index'] to $_REQUEST['index'], which allows for POST and GET parameters. Meaning, you could test at form.php?index=17 and get output 18 (same output from your existing ajax).
Granted, that has it's own potential issues, so I'd recommend just continue as is with the knowledge that your code does work.

Title: php doesn't get data from ajax

Body:
What I'm doing is I want to detect which reply button I click and send its index to php.

jQuery:

$(".reply").each(function (index5) {

$(".reply_button").each(function (index_b) {

            if(index_b==index5){
                $(this).on("click",function (e) {
                    e.preventDefault();
                    var $this = $(this)
                    $.ajax({
                        type:"POST",
                        url:"/yyqGS/public/form/reply.php",
                        data:{index:index_b},
                        dataType: "json",
                        success:function (d) {
                            console.log(d);
                        }
                    });
                })
            }
        });
});

PHP:

 <?php
    $n = $_POST['index'];
    echo $n+1;

I want to pass the variable index_b to php the file, so that $_POST['index'] can get the value.

But the result on php page is 1, which means it doesn't get the value of index_b from ajax.

On the other hand, what is showed on console is, HOWEVER, correct number! Like, if I click the first reply button, it shows 1, if I click second, it shows 2, and so on...

result on php: always 1.

result on console: correct number.

I couldn't figure out how it happened!

UPDATE:
so i changed console.log() to submit(), i want ajax would send the index to php first, and then another a form will send like 'text' i type to php. But, what's on php page is still 1.

$this.parent() is a form.

So what i really want to do is i want to send the variable index_b to php, and also, at the same time, send those input data to php. So i can use them both.

$(".reply_button").each(function (index_b) {

            if(index_b==index5){
                $(this).on("click",function (e) {
                    e.preventDefault();
                    var $this = $(this)
                    $.ajax({
                        type:"POST",
                        url:"/yyqGS/public/form/reply.php",
                        data:{index:index_b},
                        success:function (d) {
                            $this.parent().submit();
                        }
                    });
                })
            }
        });


问:
How to align button to right in bootstrap 4
I tried looking this up here but I can't find anything related to this specific problem.

I'm trying to make a header which has a button on the left and right of the screen with a logo in the middle, but whenever I make the window smaller or larger the button on the right doesnt stay aligned.

Small window

Large window

Here is the code:

```<code><header>
        <div id="container-fluid">
            <div class="row">
                <div class=" col-2">
                    Menu
                </div>
                <div class="col-8 text-center ">
                    Logo
                </div>
                <div class="col-2 float-right">
                    Contact
                </div>
            </div>
        </div>
     </header>
</code>```

What am I missing here?

Thanks in advance.

Fixed it, code now looks like this:

```<code>    <body>
    <header>
        <div id="container-fluid">
            <div class="row">
                <div class="col">
                    <span class="float-left">Menu</span>
                </div>
                <div class="col text-center">
                    Logo
                </div>
                <div class="col">
                    <span class="float-right">Contact</span>
                </div>
            </div>
        </div>
     </header>
</body>
</code>```

答:
wrap your content so it can be aligned according to the parent container.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

        Menu

        Logo

        Contact

```

Body:
I tried looking this up here but I can't find anything related to this specific problem.

I'm trying to make a header which has a button on the left and right of the screen with a logo in the middle, but whenever I make the window smaller or larger the button on the right doesnt stay aligned.

Small window

Large window

Here is the code:

                    Menu

                    Logo

                    Contact

What am I missing here?

Thanks in advance.

Fixed it, code now looks like this:

                    Menu

                    Logo

                    Contact

Body:
wrap your content so it can be aligned according to the parent container.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

<header>
  <div id="container-fluid">
    <div class="row">
      <div class="col-2">
        <span class="float-left">Menu</span>
      </div>
      <div class="col-8 text-center">
        Logo
      </div>
      <div class="col-2">
        <span class="float-right">Contact</span>
      </div>
    </div>
  </div>
</header>


问:
Visual Studio keeps running the old build
I have a simple Silverlight program that displays a bunch of images. I modified it do display more images, but it when I hit "run without debugging" is keeps running the old build with fewer images. When I copy the code into a new project and run it, it works fine for the first time, but then each subsequent change is not displayed. What could be the problem? I'm using Visual Web Developer 2008 Express.</p>

答:
I had this issue in a web site.

The site referenced 1 of the projects in the solution, and changes to it would not reflect in the debug.

Issue was a third project was referencing an outdated dll of the same same referenced project.

I removed the project and all references in other projects and readded and re-referenced everything and it worked fine.


问:
AngularJS 1.6 - On a config phase $http defaults requestError, broadcast event to main scope?
I need to broadcast an event after receiving a $http.defaults request error (400 status code, mainly) but I cannot access $rootScope within config phase.

Code:

```<code>var app = angular.module('app', []);
app.config(['$httpProvider','$injector', function($httpProvider, $injector) {
    $httpProvider.interceptors.push(['$q', function($q) {
        return {
            'responseError': function (rejection) {
                /*
                Doesn't work:
                $rootScope = $injector.get("$rootScope");
                $rootScope.$emit("RESPONSE_ERROR");
                */
                return $q.reject(rejection);
            }
        };
    }]);
}]);
app.controller("Controller",function($scope){
    $scope.$on("RESPONSE_ERROR",function(event,params){
        alert("WORKING!");
    });
});
</code>```

Any suggestions? Thanks.

答:
You can try the following code injecting $rootScope into custom interceptor function.

```<code>var app = angular.module('app', []);
app.config(['$httpProvider','$injector', function($httpProvider, $injector) {
    $httpProvider.interceptors.push(['$rootScope', '$q', function($rootScope, $q) {
        return {
            'responseError': function (rejection) {
                $rootScope.$broadcast('RESPONSE_ERROR', {
                    // Custom properties
                });
                return $q.reject(rejection);
            }
        };
    }]);
}]);
</code>```

Body:
I need to broadcast an event after receiving a $http.defaults request error (400 status code, mainly) but I cannot access $rootScope within config phase.

Code:

var app = angular.module('app', []);
app.config(['$httpProvider','$injector', function($httpProvider, $injector) {
    $httpProvider.interceptors.push(['$q', function($q) {
        return {
            'responseError': function (rejection) {
                /*
                Doesn't work:
                $rootScope = $injector.get("$rootScope");
                $rootScope.$emit("RESPONSE_ERROR");
                */
                return $q.reject(rejection);
            }
        };
    }]);
}]);
app.controller("Controller",function($scope){
    $scope.$on("RESPONSE_ERROR",function(event,params){
        alert("WORKING!");
    });
});

Any suggestions? Thanks.

Body:
You can try the following code injecting $rootScope into custom interceptor function.

var app = angular.module('app', []);
app.config(['$httpProvider','$injector', function($httpProvider, $injector) {
    $httpProvider.interceptors.push(['$rootScope', '$q', function($rootScope, $q) {
        return {
            'responseError': function (rejection) {
                $rootScope.$broadcast('RESPONSE_ERROR', {
                    // Custom properties
                });
                return $q.reject(rejection);
            }
        };
    }]);
}]);


问:
How to get string between a character and first occurrence of double quotes?
I am trying to get tvg-logo string(http://awebsite/logos/TestChannel.png) but my current code only works on case one.For case 2 and 3 inputs the code outputs not only the tvg-logo value but also the rest of string after it!could you guys show me how to get ONLY tvg-logo url in all these case ?Thanks

```<code>public class HelloWorld {
  public static void main(String[] args) {

    //case 1:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\"";
    //case 2:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\" group-title=\"Movies\"";
    //case 3:
    String s="-1 tvg-logo=\"http://awebsite/logos/TestChannel.png\" tvg-name=\"Test Channel\" group-title=\"Movies\"";

    String icon = s.substring(s.indexOf("tvg-logo") + "tvg-logo".length()).replace("=", "").replace("\"", "").replace("\n", "");

    System.out.println("Logo:"+icon);
  }
}
</code>```

output for case 3 input:

```<code>Logo:http://awebsite/logos/TestChannel.png tvg-nameTest Channel group-titleMovies
</code>```

Expected output for all types of input cases:

```<code>Logo:http://awebsite/logos/TestChannel.png
</code>```

答:
You could insert the line
icon=icon.substring(0,icon.indexOf(" "));
to extract it.

public static void main(String[] args) {

```<code>    //case 1:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\"";
    //case 2:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\" group-title=\"Movies\"";
    //case 3:
    String s="-1 tvg-logo=\"http://awebsite/logos/TestChannel.png\" tvg-name=\"Test Channel\" group-title=\"Movies\"";
    String icon = s.substring(s.indexOf("tvg-logo") + "tvg-logo".length()).replace("=", "").replace("\"", "").replace("\n", "");
    icon=icon.substring(0,icon.indexOf(".png")+4);
    System.out.println("Logo:"+icon);
  }
</code>```

Body:
I am trying to get tvg-logo string(http://awebsite/logos/TestChannel.png) but my current code only works on case one.For case 2 and 3 inputs the code outputs not only the tvg-logo value but also the rest of string after it!could you guys show me how to get ONLY tvg-logo url in all these case ?Thanks

public class HelloWorld {
  public static void main(String[] args) {

    //case 1:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\"";
    //case 2:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\" group-title=\"Movies\"";
    //case 3:
    String s="-1 tvg-logo=\"http://awebsite/logos/TestChannel.png\" tvg-name=\"Test Channel\" group-title=\"Movies\"";

    String icon = s.substring(s.indexOf("tvg-logo") + "tvg-logo".length()).replace("=", "").replace("\"", "").replace("\n", "");

    System.out.println("Logo:"+icon);
  }
}

output for case 3 input:

Logo:http://awebsite/logos/TestChannel.png tvg-nameTest Channel group-titleMovies

Expected output for all types of input cases:

Logo:http://awebsite/logos/TestChannel.png

Body:
You could insert the line
icon=icon.substring(0,icon.indexOf(" "));
to extract it.

public static void main(String[] args) {

    //case 1:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\"";
    //case 2:
    //String s="-1 tvg-name=\"Test Channel\" tvg-logo=\"http://awebsite/logos/TestChannel.png\" group-title=\"Movies\"";
    //case 3:
    String s="-1 tvg-logo=\"http://awebsite/logos/TestChannel.png\" tvg-name=\"Test Channel\" group-title=\"Movies\"";
    String icon = s.substring(s.indexOf("tvg-logo") + "tvg-logo".length()).replace("=", "").replace("\"", "").replace("\n", "");
    icon=icon.substring(0,icon.indexOf(".png")+4);
    System.out.println("Logo:"+icon);
  }


问:
C - Caesar Cipher [Moving Code to Function]
I am totally new to C programming language, so don't be too critical about my code. I found some tutorials to make Caesar Cipher encryption and decryption program, I just would like to run it from the CLI.

I have code, but it uses global variables and doesn't use functions, i need both of them, i need to somehow move my code to function called "encryption" and another function called "decryption", this all goes to problem number 2

I created encryption code, but i can't make decryption, i understand the main idea, but because i don't have function (Which i need) i can't make the decryption part of the code.

Please help me. Here is my code:

```<code>#include<stdio.h>

int main()
{
    char message[100], symbol;
    int i, key;

    printf("Message to encrypt: ");
    gets(message); //fgets is better
    printf("Enter key: ");
    scanf("%d", &key);

    for(i = 0; message[i] != '\0'; ++i){
        symbol = message[i];

        if(symbol >= 'a' && symbol <= 'z'){
            symbol = symbol + key;

            if(symbol > 'z'){
                symbol = symbol - 'z' + 'a' - 1;
            }

            message[i] = symbol;
        }
        else if(symbol >= 'A' && symbol <= 'Z'){
            symbol = symbol + key;

            if(symbol > 'Z'){
                symbol = symbol - 'Z' + 'A' - 1;
            }

            message[i] = symbol;
        }
        else if(symbol >= '0' && symbol <= '9'){
            symbol = symbol + key;

            if(symbol > '9'){
                symbol = symbol - '9' + '1' - 1;
            }

            message[i] = symbol;
        }
    }

    printf("Encrypted message: %s", message);

    return 0;
}
</code>```

As i said, i need to make 2 function, one for encryption and another one for decryption, can i get some help ?

Thank you.

答:
Encryption function

```<code>char * encryption(char * message,  int key)
{
  char * encrypted_message= (char *)malloc( (strlen(message)+1)*sizeof(char)); //create a new message that has the length of the original message + 1 space for the null character ('\0')

 //do the encryption

 return encrypted_message;
  //or make it void and print it the enc. msg. or both
}
</code>```

You can also include string.h lib and use the strlen() function to get the length of the string.

Body:
I am totally new to C programming language, so don't be too critical about my code. I found some tutorials to make Caesar Cipher encryption and decryption program, I just would like to run it from the CLI.

I have code, but it uses global variables and doesn't use functions, i need both of them, i need to somehow move my code to function called "encryption" and another function called "decryption", this all goes to problem number 2

I created encryption code, but i can't make decryption, i understand the main idea, but because i don't have function (Which i need) i can't make the decryption part of the code.

Please help me. Here is my code:

#include<stdio.h>

int main()
{
    char message[100], symbol;
    int i, key;

    printf("Message to encrypt: ");
    gets(message); //fgets is better
    printf("Enter key: ");
    scanf("%d", &key);

    for(i = 0; message[i] != '\0'; ++i){
        symbol = message[i];

        if(symbol >= 'a' && symbol <= 'z'){
            symbol = symbol + key;

            if(symbol > 'z'){
                symbol = symbol - 'z' + 'a' - 1;
            }

            message[i] = symbol;
        }
        else if(symbol >= 'A' && symbol <= 'Z'){
            symbol = symbol + key;

            if(symbol > 'Z'){
                symbol = symbol - 'Z' + 'A' - 1;
            }

            message[i] = symbol;
        }
        else if(symbol >= '0' && symbol <= '9'){
            symbol = symbol + key;

            if(symbol > '9'){
                symbol = symbol - '9' + '1' - 1;
            }

            message[i] = symbol;
        }
    }

    printf("Encrypted message: %s", message);

    return 0;
}

As i said, i need to make 2 function, one for encryption and another one for decryption, can i get some help ?

Thank you.

Body:
Encryption function

char * encryption(char * message,  int key)
{
  char * encrypted_message= (char *)malloc( (strlen(message)+1)*sizeof(char)); //create a new message that has the length of the original message + 1 space for the null character ('\0')

 //do the encryption

 return encrypted_message;
  //or make it void and print it the enc. msg. or both
}

You can also include string.h lib and use the strlen() function to get the length of the string.