Forums / Developer / fromString for updating objects?

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

eZ debug

Timing: Jan 18 2025 00:08:55
Script start
Timing: Jan 18 2025 00:08:55
Module start 'content'
Timing: Jan 18 2025 00:08:56
Module end 'content'
Timing: Jan 18 2025 00:08:56
Script end

Main resources:

Total runtime0.8749 sec
Peak memory usage4,096.0000 KB
Database Queries192

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.1406180.8438
Module start 'content' 0.00660.7523 769.9844542.9609
Module end 'content' 0.75890.1159 1,312.9453332.7422
Script end 0.8748  1,645.6875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4139210.0002
Check MTime0.00140.1621210.0001
Mysql Total
Database connection0.00090.106910.0009
Mysqli_queries0.811792.78281920.0042
Looping result0.00170.19901900.0000
Template Total0.851297.320.4256
Template load0.00210.244620.0011
Template processing0.849197.050120.4245
Template load and register function0.00010.012610.0001
states
state_id_array0.00060.064010.0006
state_identifier_array0.00080.089520.0004
Override
Cache load0.00180.2008160.0001
Sytem overhead
Fetch class attribute can translate value0.00150.172830.0005
Fetch class attribute name0.00080.091540.0002
XML
Image XML parsing0.00120.142930.0004
class_abstraction
Instantiating content class attribute0.00000.000840.0000
General
dbfile0.00340.3930340.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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