The "var_mode" and "var_profile" are applied by adding either
?var_mode=... (e.g. -
spip.php?article3&var_mode=...) to the end of the URL for the called page.
Their application will only work if you are logged in to the site as one of the administrators.
Calling a page with "var_mode=calcul" regenerates the HTML code (calls the already compiled code) and refreshes the cache (creates the HTML files which will simply need to be read when the next call to that page is requested).
Calling a page with "var_mode=recalcul" regenerates the PHP code (performs a new compilation of the template), then also regenerates the HTML code (run an execution of the code which has just been compiled) and then again finally refreshes the cache (creates the HTML files which will be read the next time that page is called).
the recalculation does not apply to the images (vignettes/thumbnails, images-typo/textual images, ...)
Either of these two calls can be executed by clicking on one of the administration buttons visible on the public page whenever you are logged in as an administrator;
the first click calling "var_mode=calcul" (when the button’s title is accompanied with an asterisk, it is because the displayed page has been read from the cache);
a second click calls for a recalculation with "var_mode=recalcul".
Warning: You might be tempted to use
Calling a page with "var_mode=inclure" displays the name and path of each sub-component (inclure/include code or SPIP model) which is included within the page.
This makes it possible to check that the includes actually called by the page template are indeed those that have been specified, particularly important if you have overloaded any standard or plugin models by showing the full pathname to each included file.
Calling a page with "var_profile=1" displays the details of the SQL queries and the calculation times involved with each of them. The queries are sorted from the most time consuming to the least.
This function is particularly useful to find out what could be making a particular page display excessively slowly.
It allows you to view the SQL queries generated by each loop in the template (including those of any included templates or models) as well as any out of loop queries (noted as "Uncompiled") when generated by SPIP.
This will display:
- for each loop
- the number of times that the loop (and therefore the SQL query) has been executed,
- the time (in seconds) used by the loop (i.e. the time for the corresponding query multiplied by the number of executions of the loop),
- the list (sorted in chronological order of all the queries generated by the page) of each execution of the query (which provides a link to the details of each query).
- the uncompiled queries
- the total time taken by all of the queries for the page
- the details of each query run with
- a statistical table showing the execution plan of the query,
- the title of the query.
Warning: Remember to calculate the page with (
&var_profile=1&var_mode=calcul) in order to avoid the cache being read, which would thereby cause false results to be displayed.
Calling a page with "var_mode=preview" from the private space is used to view an article which has been "proposed for publication" without actually needing to publish it on the public site.
Calling a page with "var_mode=urls" forces an update of all of the URLs included within that page.
Calling a page with "var_mode=debug" details the generation of a page (the SPIP loops - SQL queries - PHP code - SQL query statistics).
This page displays info for the main template file as well as for any included template files:
- the list of values of the environment context variables (#ENV) passed by the calling template,
- the list of loops.
The various links can be used to access:
the textual code of the template (thereby avoids needing to have direct access to the .html file in order to read its contents),
the code specifically generated by the template (any possible includes) which, once evaluated, will return the HTML to the browser,
the PHP code generated by the compiler (an analysis moreover intended for core code developers) which, once executed, will generate the results (see above),
the detail of the SQL queries and, for each of them, their execution times (see above for
the textual code of the complete loop (from
the SQL query generated by the loop in question,
a list of the first results returned by that query ,
the PHP code (generated by the compiler) for the specific function associated with that loop (an analysis mostly reserved for expert core code developers),
the details and calculation time for the SQL query associated with that loop (see above for
Display the contents of a table
Calling a page with the URL modifier
name_of_the_table from the public space will display the contents of the named table as an array.
?page=table:articles for the
The first line of this array lists the fields of the table in alphabetical order (warning: do not confuse the database record "N°" with the "id_..."); clicking on one of these fields will sort the results accordingly (ascending/descending order).
The second line is used to run a search for a specific field value.
All of the data are displayed in paginated mode in groups of 10 results per page.
Note: This function makes it possible to display ALL of the data for ANY table in the database, but can only be used by a logged in site administrator.
Obtaining even more information for debugging
- Deactivate the SPIP cache by adding a line into config/mes_options.php:
- Activate PHP error reporting by adding this code into config/mes_options.php:
ini_set ("display_errors", "On");