updateniceurls.php could update path_string.

Author Message

Erik Weinmaster

Thursday 13 January 2011 11:25:37 am

Hello,

I've run into a couple problems with the ezcontentobject_tree table. Mainly, the two fields of 'path_identification_string' and 'path_string' seem to be inaccurate from time to time. The 'path_identification_string' is the least of the worries since this can be easily rectified by running the mentioned script (updateniceurls.php).

However, I do see on occasion an incorrect 'path_string'. I think this mainly happens when an upgrade to the database is attempted. Nevertheless, if one is going to the trouble of running the script in general, It would be nice to see 'path_string' included in the process.

I've already created a function and added it to my own install. I listed the function here:
function updatePathString( $node )
{
$parentNode = $node->attribute( 'parent' );
$pathString = $parentNode->attribute( 'path_string' ).$node->attribute( 'node_id' ).'/';
if( $node->attribute( 'path_string' ) != $pathString )
{
$node->setAttribute( 'path_string', $pathString );
$node->sync();
}
}

The call would be as shown:

foreach ( array_keys( $nodeList ) as $key )
{
$node = $nodeList[ $key ];
updatePathString( $node );
$hasChanged = $node->updateSubTreePath();

As you can see, its fairly simple and does the job.

Thanks,

-erik

Christian Rößler

Friday 14 January 2011 8:57:42 am

Erik, this looks good.

Did you encounter errors in var/log/error.log as below or did you just dig into the database and fell over this issue?

 [ Jan 14 2011 17:25:33 ] [66.249.71.228] :eZContentObjectTreeNode::pathWithNames() failed to fetch path of node 17898, falling back to generated url entries. Run updateniceurls.php to fix the problem.

In other words, did your patch solve the url-alias problems above?
Those errors I got an a fresh installed ezPublish 4.3 which runs now some months and is used by some editors - but could not determine a real ez-error. Searching the forums did in fact show some threads with users having the same issue i have, but now solution or even a source for those errors.

Cheers,
chris

Hannover, Germany
eZ-Certified http://auth.ez.no/certification/verify/395613

Erik Weinmaster

Friday 21 January 2011 1:08:01 pm

Christian,

To answer your first question, I found this issue by digging into the database itself. I noticed that some nodes didn't have the friendly url link even though there was a path_string. So, I made this patch because I found some nodes whos path_string was something like '/1/2/345654/543' and it needed to be '/1/2/345/654/543'. It appears that sometimes a slash '/' doesn't get copied over and you end up with the system thinking you have a different node_id. I really don't know if prolonged used or multiple upgrades is the cause of the problem. Also, your error that you submitted is an output when path_identification_string is not set. This is easy to fix by running the upgradeniceurls.php script.

As for your second question. I don't really know if this hits much of the url_alias. Like I said before, if the path_string isn't correct, then instead of getting a nice friendly url to click on '/folder/myfolder/' you'll get what this should be mapped to '/content/view/234/'. This is also a good point of why this is sort of a minor issue. Even if the path_string doesn't work (which I think helps provide the friendly url), you'll end up with the controller url of '/content/view/234/'. Both of which will take you to your node.

Hope I cleared things up,

erik

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 00:55:17
Script start
Timing: Jan 18 2025 00:55:17
Module start 'layout'
Timing: Jan 18 2025 00:55:17
Module start 'content'
Timing: Jan 18 2025 00:55:18
Module end 'content'
Timing: Jan 18 2025 00:55:18
Script end

Main resources:

Total runtime0.7891 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.0469152.6406
Module start 'layout' 0.00640.0028 740.687539.4844
Module start 'content' 0.00920.7784 780.1719510.1875
Module end 'content' 0.78760.0014 1,290.359412.4375
Script end 0.7890  1,302.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4581160.0002
Check MTime0.00150.1863160.0001
Mysql Total
Database connection0.00080.096110.0008
Mysqli_queries0.735193.1599570.0129
Looping result0.00050.0621550.0000
Template Total0.752995.420.3765
Template load0.00230.294820.0012
Template processing0.750695.122720.3753
Template load and register function0.00020.030710.0002
states
state_id_array0.00110.138310.0011
state_identifier_array0.00140.180020.0007
Override
Cache load0.00190.2418400.0000
Sytem overhead
Fetch class attribute can translate value0.00060.075320.0003
Fetch class attribute name0.00130.163830.0004
XML
Image XML parsing0.00030.032620.0001
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00130.1597100.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs