bug, if more than ten content versions

After two hours of debugging I give up, hopefully somebody of the Coldbox geeks can fix it.

If you have more than 10 versions saved, the save fails with an error in: modules/contentbox/model/content/BaseContent.cfc

`

private function maxContentVersionChecks(){
if( !len( settingService.getSetting( “cb_versions_max_history” ) ) ){ return; }

// How many versions do we have?
var versionCounts = contentVersionService.newCriteria().isEq(“relatedContent.contentID”, getContentID() ).count();
// Have we passed the limit?
if( (versionCounts+1) GT settingService.getSetting( “cb_versions_max_history” ) ){
var oldestVersion = contentVersionService.newCriteria()
.isEq(“relatedContent.contentID”, getContentID() )
.withProjections(min=“version”, id=“true”)
.get();
// delete by primary key ID
contentVersionService.deleteByID( oldestVersion[2] );
}
}

`

Setting of oldestVersion fails

`
could not execute query at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197):197 at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493):1493 at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390):390 at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340):340 at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575):4575 at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400):1400 at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179):179 at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154):154 at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:283):283 at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208):208 at org.hibernate.loader.Loader.getResultSet(Loader.java:1869):1869 at org.hibernate.loader.Loader.doQuery(Loader.java:718):718 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270):270 at org.hibernate.loader.Loader.doList(Loader.java:2449):2449 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192):2192 at org.hibernate.loader.Loader.list(Loader.java:2187):2187 at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119):119 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1706):1706 at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347):347 at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:369):369 at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source):-1 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source):-1 at java.lang.reflect.Method.invoke(Unknown Source):-1 at railo.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:37):37 at railo.runtime.reflection.Reflector.callMethod(Reflector.java:698):698 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:732):732 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1507):1507 at system.orm.hibernate.criteriabuilder_cfc$cf._2(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\orm\hibernate\CriteriaBuilder.cfc:195):195 at system.orm.hibernate.criteriabuilder_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\orm\hibernate\CriteriaBuilder.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1507):1507 at model.content.basecontent_cfc$cf._1(C:\inetpub\wwwroot\akibase\strandperle\modules\contentbox\model\content\BaseContent.cfc:118):118 at model.content.basecontent_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\modules\contentbox\model\content\BaseContent.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:774):774 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1507):1507 at model.content.basecontent_cfc$cf._1(C:\inetpub\wwwroot\akibase\strandperle\modules\contentbox\model\content\BaseContent.cfc:98):98 at model.content.basecontent_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\modules\contentbox\model\content\BaseContent.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275 at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1800):1800 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:749):749 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1522):1522 at modules.contentbox_admin495.handlers.pages_cfc$cf._1(C:\inetpub\wwwroot\akibase\strandperle\modules\contentbox-admin\handlers\pages.cfc:200):200 at modules.contentbox_admin495.handlers.pages_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\modules\contentbox-admin\handlers\pages.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275 at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1796):1796 at railo.runtime.tag.Invoke.doComponent(Invoke.java:209):209 at railo.runtime.tag.Invoke.doEndTag(Invoke.java:182):182 at system.web.controller_cfc$cf._6(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\web\Controller.cfc:753):753 at system.web.controller_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\web\Controller.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:774):774 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1507):1507 at system.web.controller_cfc$cf._5(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\web\Controller.cfc:637):637 at system.web.controller_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\web\Controller.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275 at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1800):1800 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:749):749 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1522):1522 at coldbox.system.coldbox_cfc$cf._1(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\Coldbox.cfc:236):236 at coldbox.system.coldbox_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\coldbox\system\Coldbox.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1507):1507 at application_cfc$cf.udfCall(C:\inetpub\wwwroot\akibase\strandperle\Application.cfc:103):103 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103 at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371 at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284 at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607 at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781 at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:346):346 at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:107):107 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2256):2256 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2223):2223 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:310):310 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722):722 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225):225 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169):169 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168):168 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98):98 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407 at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565):565 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307):307 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source):-1 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1 at java.lang.Thread.run(Unknown Source):-1

`

It’s newest Railo with Mssql 2008

Out of curiosity does it fail on adobe?

What driver did you select for your datasource in Railo?

Thanks,

George Murphy

tried both.

yes, Adobe fails as well

The datasource on CF is MSSQL. Can´t tell you the railo datasource settings of Gunnar.

Hi Luis,

The problem was that more than one version had the same version id. The function maxContentVersionChecks in BaseContent.cfc tries to delete only the oldest version of the content with the version id as passing parameter. In our case more than one version were returned and the function get() expects only one dataset.
I also think, if the setting “cb_versions_max_history” will be set to a value less then the current count of versions, the function will still delete only one version, not all the versions that are too much to the new “cb_versions_max_history” value.
I’ve changed the get()-operation to a list()-operation, return the oldest versions with the offset passing parameter (set to the cb_versions_max_history value) and delete this versions.
I’ve done a pull request in Github.

Best
Matze

Matze, can you send me the code for this, so I can add it.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano