Archivio

Posts Tagged ‘error’

[Risolto] – Joomla error – Strict Standards: Non-static method JApplication::getMenu()

marzo 7, 2011 4 commenti

Con alcune versioni di easyphp si verifica un errore nella visualizzazione del proprio sito joomla.

L’errore è del tipo:

Strict Standards: Non-static method JLoader::import() should not be called statically in I:\EasyPHP\www\Joomla_1.5.22_ita-Stable\libraries\joomla\import.php on line 29

Strict Standards: Non-static method JLoader::register() should not be called statically in I:\EasyPHP\www\Joomla_1.5.22_ita-Stable\libraries\loader.php on line 71

Strict Standards: Non-static method JLoader::load() should not be called statically in I:\EasyPHP\www\Joomla_1.5.22_ita-Stable\libraries\loader.php on line 161

Strict Standards: Non-static method JRequest::clean() should not be called statically in I:\EasyPHP\www\Joomla_1.5.22_ita-Stable\libraries\joomla\import.php on line 33

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in I:\EasyPHP\www\Joomla_1.5.22_ita-Stable\libraries\joomla\environment\request.php on line 463

Per risolvere il problema basta modificare il file php.ini e togliere la visualizzazione degli errori.

Fare click con il tasto destro sull’icona di easyphp nella trayicon e selezionare configurazione e quindi php. Si aprirà il file php.ini nel blocco note. Fate cerca “display_errors” e modificate il valore della variabile da on a off:

1° metodo: disattivare tutti gli errori

Prima:

; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On

Dopo :

; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = Off

Ho mostrato anche le altre righe per poter darvi un riferimento all’interno del blocco di testo.

2° metodo: disattivare solo gli errori strict

Questo altro metodo non elimina la visualizzazione di tutti gli errori, ma solo di quelli strict. Infatti per chi programma risulta molto utile visualizzare gli errori generati nel codice in modo da poterli prontamente correggere.

Dovete cercare nel file php.ini “error_reporting” e cancellare “|E_STRICT”:

prima:

error_reporting = E_ALL | E_STRICT

dopo:

error_reporting = E_ALL

Riepilogo

Ecco il listato completo con evidenziate in rosso le uniche 2 righe che dovete modificare.

la riga blu indica la riga da modificare con il 2° metodo, ovvero cancellare “|E_STRICT”

la riga in rosso indica la riga da modificare con il 1° metodo, ovvero cambiare on in off  (qui sotto è riportato ancora come on, visto che è stato applicato il 2°metodo)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; This directive informs PHP of which errors, warnings and notices you would like
; it to take action for. The recommended way of setting values for this
; directive is through the use of the error level constants and bitwise
; operators. The error level constants are below here for convenience as well as
; some common settings and their meanings.
; By default, PHP is set to take action on all errors, notices and warnings EXCEPT
; those related to E_NOTICE and E_STRICT, which together cover best practices and
; recommended coding standards in PHP. For performance reasons, this is the
; recommend error reporting setting. Your production server shouldn’t be wasting
; resources complaining about best practices and coding standards. That’s what
; development servers and development settings are for.
; Note: The php.ini-development file has this setting as E_ALL | E_STRICT. This
; means it pretty much reports everything which is exactly what you want during
; development and early testing.
;
; Error Level Constants:
; E_ALL             – All errors and warnings (includes E_STRICT as of PHP 6.0.0)
; E_ERROR           – fatal run-time errors
; E_RECOVERABLE_ERROR  – almost fatal run-time errors
; E_WARNING         – run-time warnings (non-fatal errors)
; E_PARSE           – compile-time parse errors
; E_NOTICE          – run-time notices (these are warnings which often result
;                     from a bug in your code, but it’s possible that it was
;                     intentional (e.g., using an uninitialized variable and
;                     relying on the fact it’s automatically initialized to an
;                     empty string)
; E_STRICT          – run-time notices, enable to have PHP suggest changes
;                     to your code which will ensure the best interoperability
;                     and forward compatibility of your code
; E_CORE_ERROR      – fatal errors that occur during PHP’s initial startup
; E_CORE_WARNING    – warnings (non-fatal errors) that occur during PHP’s
;                     initial startup
; E_COMPILE_ERROR   – fatal compile-time errors
; E_COMPILE_WARNING – compile-time warnings (non-fatal errors)
; E_USER_ERROR      – user-generated error message
; E_USER_WARNING    – user-generated warning message
; E_USER_NOTICE     – user-generated notice message
; E_DEPRECATED      – warn about code that will not work in future versions
;                     of PHP
; E_USER_DEPRECATED – user-generated deprecation warnings
;
; Common Values:
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards

warnings.)
;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding

standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
;error_reporting = E_ALL | E_STRICT
error_reporting = E_ALL

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It’s recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On

[Risolto] Easyphp fatal error include_path=’.;C:\php5\pear’

settembre 24, 2010 7 commenti

Mi è capitato di aver appena reinstallato Easyphp e mi sono accorto che se provavo ad eseguire un include/require in un file php mi veniva restituito un warning ed un fatal error :

Warning: require_once(mysite/_include/before_close_head.tpl) [function.require-once]: failed to open stream: No such file or directory in I:\EasyPHP\www\mysite\index.php on line 51Fatal error: require_once() [function.require]: Failed opening required ‘mysite/_include/before_close_head.tpl’ (include_path=’.;C:\php5\pear’) in I:\EasyPHP\www\mysite\index.php on line 51

In breve Easyphp non riusciva a trovare il file da includere perché sbaglia la directory base, andando a cercare erroneamente in “C:\php5\pear”.  Ora spiegherò come risolvere il problema.

Dobbiamo aprire il file di configurazione di php. Possiamo farlo o  cliccando col destro sull’icona del programma nella TrayIcon (quelle icone vicino all’orologio in basso a dx nella barra di avvio) e clicckiamo su configurazione e poi su php oppure andando nella cartella dove abbiamo installato easyphp, aprendo la cartella conf_files e quindi php.ini.

A questo punto cerchiamo nel file (modifica>trova/cerca)  la stringa include_path (di solito non è la prima occorrenza), finché non troviamo una porzione di codice simile a questa:

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: “/path1:/path2”
;include_path = “.:/php/includes”
;
; Windows: “\path1;\path2”
;include_path = “.;${path}\php\includes”

; PHP’s default setting for include_path is “.;/path/to/php/pear”
; http://php.net/include-path

Nella penultima riga compare proprio quello che stavamo cercando :

; PHP’s default setting for include_path is “.;/path/to/php/pear”

ovvero l’impostazione predefinita per la cartella dell’include è “.;/path/to/php/pear”

Per tornare a far funzionare il tutto basta aggiungere una riga di codice;  per comodità la inserisco  subito sopra:

; Windows: “\path1;\path2” ;include_path = “.;${path}\php\includes”

include_path = “.;${path}\php\includes;I:\EasyPHP\www\”

; PHP’s default setting for include_path is “.;/path/to/php/pear”
; http://php.net/include-path

La riga inserita è quella in rosso ed è molto simile alla riga subito sopra, la quale indica la corretta sintassi per il comando da inserire. Il punto e virgola che compare all’inizio di alcune righe sta ad indicare che tutta la riga sarà ignorata, infatti il ; indica un commento.

La riga che abbiamo inserito indica alcuni possibili indirizzi dove andare a cercare i files, ognuno dei quali separati da un punto e virgola.

Ho inserito alcuni indirizzi tipici di alcune versioni di easyphp ed infine, e più importante, la cartella dove ho attualmente installato easy php che nel mio caso è proprio I:\EasyPHP\www\

Quindi nel vostro caso basta inserire una riga del tipo:

include_path = “.;${path}\php\includes;${path}\php5\pear\;Unitàdisco:\Cartella di installazione di EasyPHP\www

oppure solo

include_path = “.;Unitàdisco:\Cartella di installazione di EasyPHP\www

dove Unitàdisco:\Cartella di installazione di EasyPHP\www va sostituito con il percorso della cartella www all’interno della cartella dove avete installato easyphp, ad esempio “c:\Easyphp 5.3.0\www” oppure “d:\Easyphp\www .

Un ultima cosa: fate attenzione ad inserire correttamente il backslash “\” per separare le cartelle e non lo slash normale “/”.