fromString for updating objects?

Author Message

Peter Keung

Monday 18 July 2011 12:56:14 pm

We've been using datatypes' fromString methods for years now, for imports and updates.

The "ezuser" datatype's fromString method does a check to make sure that the username and e-mail address don't already exist (see here for a bit of context: http://issues.ez.no/IssueView.php?Id=17836&activeItem=3). This makes it unsuitable to be used for updates to existing users. We use some simple workaround code to capture updates to "ezuser" attributes and update them directly -- not really a problem.  However, this brings up a general framework question:

Was the intention around fromString for it to be used on new object creation only?  If it was also intended to be used in updates, then perhaps ezuser's fromString method should be modified to put the onus on the script using that method to do its own checks on the username or e-mail address. This way, the actual update process is more standardized: you are forced to do all of the necessary preparation on the attributes before they are passed through.

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

Gaetano Giunta

Tuesday 19 July 2011 11:49:24 am

I fully agree that the fromString method, while extremely useful, is not good enough.

  1. It is not supported by 100% of the datatypes
  2. It does not involve all of the validation done when editing content via the browser

Point 2 is especially important, as there is currently no other method (afaik) that does it - datatype validation is sadly tied to variables being there in $_POST. This has the nasty effects that a lot of import scripts do create inconsistent data (inconsistent wrt. content class definition).

Let's hope that this will be fixed in the new content-management API currently in the works...

Principal Consultant International Business
Member of the Community Project Board

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 02:07:43
Script start
Timing: Jan 18 2025 02:07:43
Module start 'layout'
Timing: Jan 18 2025 02:07:43
Module start 'content'
Timing: Jan 18 2025 02:07:43
Module end 'content'
Timing: Jan 18 2025 02:07:43
Script end

Main resources:

Total runtime0.6635 sec
Peak memory usage4,096.0000 KB
Database Queries55

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.9141152.6250
Module start 'layout' 0.00550.0029 740.539139.4531
Module start 'content' 0.00840.6536 779.9922537.8828
Module end 'content' 0.66190.0015 1,317.875012.1563
Script end 0.6634  1,330.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.5265160.0002
Check MTime0.00140.2149160.0001
Mysql Total
Database connection0.00080.119810.0008
Mysqli_queries0.617793.1090550.0112
Looping result0.00050.0749530.0000
Template Total0.635295.720.3176
Template load0.00200.308320.0010
Template processing0.633195.428820.3166
Template load and register function0.00010.014610.0001
states
state_id_array0.00110.158610.0011
state_identifier_array0.00090.132520.0004
Override
Cache load0.00170.2618160.0001
Sytem overhead
Fetch class attribute can translate value0.00050.070220.0002
Fetch class attribute name0.00130.189240.0003
XML
Image XML parsing0.00100.147220.0005
class_abstraction
Instantiating content class attribute0.00000.001240.0000
General
dbfile0.00100.1536230.0000
String conversion0.00000.001540.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ol.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ol.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs