Forums / Suggestions / Some considerations on refactoring the eZ Publish API

Some considerations on refactoring the eZ Publish API

Author Message

Gaetano Giunta

Friday 23 April 2010 1:55:32 pm

List of current eZ Publish APIs:

1. template language API
 . template operators
 . template functions
 . template fetch  functions
 . objects

- template variables are not the same between  node templates and module templates (persistent_variable,  view_parameters)
- no documentation of variables available in every  template
- some simple template operators miss (str_replace)
- some template operators are named differently from their php counterpart
- the variable scoping system is borderline blackmagic / it makes it  difficult to pass variables up the include() chain
+ well documented

2. module views
 . positional params
 . named params
 . single/multiple actions
 . POST vars

- extremely poorly documented
- the view template is hardcoded into the view
- redirects are  hardcoded into the view (views are not atomic)

3. php code
- misses a lot of "private" definitions on object members
- should be  documented in phpdoc style for current toolchains/ides
- misses some  architecture doc documenting the layering
- still a few global  variables and functions here and there (not 100% oop)

IDEAS:

+  before/besides adding YOMA (yet one more api), improve existing ones

+  principle of discoverability: document better existing ones
 . add  (optional) declaration of parameter types for views in module.php; it  allows automatic type coercion (safety!), introspection (wsdl!)
 . add definition of all used POST/GET vars for views
 . add links to  docs on ez.no site in the code; in the error messages; in the interface
 . an introspection view can be used in the backoffice to list all  installed modules, views, fetch functions, including code from  extensions
 . it should be doable to do the same with template  functions/operators
 . add a 'description' member in definition of  template operators, fetch functions (could be doable via an explicit  member in the definition struct or via phpdoc parsing)

+ principle of  least resistance: make APIs at the different levels identical or at  least as similar as possible
 . the same operation executed by a view  should be available via ws and via php
 . template operators and  fetch functions should be available via php (ok for objects even though  this is often overlooked, ok for fetch functions with some limitations,  not for operators?)
 . make the module object available to the view  templates

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Sunday 25 April 2010 11:22:28 pm

Some related issues:

http://issues.ez.no/IssueView.php?Id=16731&activeItem=1

http://issues.ez.no/IssueView.php?Id=16730&activeItem=2

http://issues.ez.no/IssueView.php?Id=16729&activeItem=3

http://issues.ez.no/IssueView.php?Id=16728&activeItem=4

http://issues.ez.no/IssueView.php?Id=16727&activeItem=5

http://issues.ez.no/IssueView.php?Id=16684&activeItem=8

http://issues.ez.no/IssueView.php?Id=16683&activeItem=10

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Sunday 25 April 2010 11:23:58 pm

Some introspection capabilities have been added to extension ggsysinfo in release 0.2: http://projects.ez.no/ggsysinfo

Screenshots:

http://projects.ez.no/ggsysinfo/gallery/admin_interface_screenshots/list_of_available_fetch_functions

http://projects.ez.no/ggsysinfo/gallery/admin_interface_screenshots/list_of_available_views

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Monday 03 May 2010 6:19:58 am

one more similar issue

http://issues.ez.no/IssueView.php?Id=16770

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Thursday 27 May 2010 2:34:18 am

One more thing that would help introspection is better tagging of php classes methods (I think this is called "annotation" ).

In short: an example of a currently much needed information is "who does permission checking ?"

Afaik:

  • index.php checks access perms for current user to module/view if the corresponding perm has no limitation
  • the view php code needs to do access checking on its own if the corresponding perm has some limitation
  • other bits of code do access checking on their own (eg. the template fetch functions do some, but not all are created equal, eg. checking perms on related object is not always done in a way that is expected)

See issue http://issues.ez.no/IssueView.php?Id=16862 for the feat.request.

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Tuesday 22 June 2010 1:44:56 am

Interesting blog post on the tpoic: http://blog.tabini.ca/2010/06/software-apis-and-all-the-kings-men/

Principal Consultant International Business
Member of the Community Project Board

eZ debug

Timing: Jan 15 2025 02:52:34
Script start
Timing: Jan 15 2025 02:52:34
Module start 'content'
Timing: Jan 15 2025 02:52:34
Module end 'content'
Timing: Jan 15 2025 02:52:34
Script end

Main resources:

Total runtime0.7477 sec
Peak memory usage6,144.0000 KB
Database Queries195

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 686.0703214.7734
Module start 'content' 0.00520.6282 900.84381,817.1328
Module end 'content' 0.63330.1143 2,717.9766640.9609
Script end 0.7477  3,358.9375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00690.9169210.0003
Check MTime0.00160.2090210.0001
Mysql Total
Database connection0.00060.081310.0006
Mysqli_queries0.651687.14841950.0033
Looping result0.00781.04431920.0000
Template Total0.724196.820.3620
Template load0.00420.561220.0021
Template processing0.719996.276220.3599
Template load and register function0.00130.171510.0013
states
state_id_array0.00090.115410.0009
state_identifier_array0.00070.087320.0003
Override
Cache load0.00390.5164390.0001
Sytem overhead
Fetch class attribute can translate value0.00230.310420.0012
Fetch class attribute name0.00170.233770.0002
XML
Image XML parsing0.00090.124820.0005
class_abstraction
Instantiating content class attribute0.00000.0037120.0000
General
dbfile0.00100.1340210.0000
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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
7content/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/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs