Fatal error: Out of memory - Page 2 Fatal error: Out of memory - Page 2
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Fatal error: Out of memory

Started by zi3mn1ak, February 16, 2008, 07:49:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

copperminepro

Get a better host which will allocate more memory to you..


the 4 posts above me were classic

Sukebe

Great! Buy more memory for shared host or switch to better host.  ;D

If you don't want to follow such a nice advice, try this hack:

1. Create file "advanced_get_lang_var.php":
<?php

/**
 * advanced_get_lang_var()
 *
 * A better way to return a variable from the language file
 *
 * @param string $file Path to lang file.
 * @param string $var_name Language variable name
 * @return
 **/
function advanced_get_lang_var($file$var_name)
{
    static 
$loaded_files// static var for loaded lang variables

    // Load lang file just once, not for every function call.
    
if (empty($loaded_files[$file])) {
        
// read file code
        
$file_contents file_get_contents($file);
        
// find names of all lang vars
        
if (preg_match_all('/\$(\w+)\s*=/is'$file_contents$matches)) {
            
// include lang file to load all the lang vars
            
include($file);
            
$loaded_files[$file] = array();

            
// and store them in static variable
            
foreach($matches[1] as $match) {
                
$loaded_files[$file][$match] = $$match;
            }
        }
    }

    return 
$loaded_files[$file][$var_name];
}


?>


2. Put this file into "include" directory.
3. Edit functions.inc.php: find cpg_get_default_lang_var() function and rewrite it a bit. Change
        include('lang/'.$language.'.php');
        return $$language_var_name;


for
        include_once('advanced_get_lang_var.php');
        return advanced_get_lang_var('lang/'.$language.'.php', $language_var_name);


That's all.

Don't forget to restore this hack next time when you upgrade you CPG.