SPFileVersionCollection and SPListItemVersionCollection versioning seems inconsistent to me. Inconsistency wouldn't be a problem to me, but sort order is.
SPListItemVersionCollection
I can understand versioning of ListItems as they are stored in descending order:
SPContext.Current.ListItem.Versions.Count -> 5
SPContext.Current.ListItem.Versions[0].VersionId -> 1026 (2.2 latest version)
SPContext.Current.ListItem.Versions[1].VersionId -> 1025 (2.1)
SPContext.Current.ListItem.Versions[2].VersionId -> 1024 (2.0)
... [4].VersionId -> (oldest version)
SPFileVersionCollection
However I can't understand how version numbers are saved for a document library item:
SPContext.Current.ListItem.File.Versions.Count -> 4
SPContext.Current.ListItem.File.Versions[0].ID -> 512 (1.0 oldest one)
SPContext.Current.ListItem.File.Versions[1].ID -> 513 (1.1)
SPContext.Current.ListItem.File.Versions[2].ID -> 1025 (2.1 latest version)
SPContext.Current.ListItem.File.Versions[3].ID -> 1024 (2.0 (EDIT: IsCurrentVersion = True))
They are nor in ascending order, nor descending, but something mixed.
Is there any reason for SharePoint team to decide to store SPFile versions like that? And do they expect that I write my own method to get latest version or is there a builtin one for that?
A note: Let me point out that SPListItem.File is not null for document library items.
Thought I would output some info about SPFileVersionCollection in console app and it turns out that:
last index will hold the current (not
drafted but published) version
(SPFileVersion.IsCurrentVersion
property is TRUE for this)
0 index holds the oldest version
(last index - 1) has the last drafted version (for example 2.7) and (last index - 2) holds 2.6 etc.
SPFile.Versions.Count = 0 if you just uploaded brand new document (minor version, before publishing).
If you continue uploading new document versions and have not yet published one, then they add to SPFileVersionCollection, however none has IsCurrentVersion property set to true until you publish one.
Ahh, i had a false assumption that a last document draft version should count as the latest one. Ofcourse, the last PUBLISHED version is the latest one!
Still, beware of inconsistency.
Related
I have nodejs(typescript) with https://www.npmjs.com/package/redis package and redis version is redis_version:4.0.14.
I am trying to get the top 100 scores with values from a sorted set. It runs ok for ascending order but when I set REV: true for descending it throws an syntax error exception. Descending order is what I need for the leaderboard. Is there something that I am doing wrong?
redisClient.zRangeWithScores('lb:global', 0, 99)
This gives => [{"value":"user:2","score":10}, {"value":"user:4","score":20}....{"value":"user:1","score":100}]
The above command works fine but the command below for descending order does not
redisClient.zRangeWithScores('lb:global', 0, 99, { REV: true })
This gives => [ErrorReply: ERR syntax error]
You're using Redis 4.x. Node Redis doesn't support that version—see the supported Redis versions in the README.
That said, sometimes it works because many of the commands haven't changed. GET, for example, is pretty basic and hasn't changed much. ZRANGE, however, has changed.
Your code would generate the following Redis command:
ZRANGE lb:global 0 99 REV WITHSCORES
According to the documentation for the ZRANGE command, REV was added in Redis 6.2:
Starting with Redis version 6.2.0: Added the REV, BYSCORE, BYLEX and
LIMIT options.
Your install of Redis 4.0 doesn't know what to do with REV and so you get a Syntax Error.
The correct solution would be to upgrade to a newer version of Redis. Of course, that's not always practical. So, I offer a workaround.
You can use .sendCommand to call the deprecated ZREVRANGE command directly. It just takes an array of strings with the bits and bobs of the command you want to send:
await redisClient.sendCommand(['ZREVRANGE', 'lb:global', '0', '99'])
Note that any numeric values will need to be turned to strings for this to work.
Hope this helps and I hope you are able to upgrade your Redis version. But if not, needs must when the devil drives.
I've got a Text Input field with 'Allowed Content' set to 'Decimal'. It won't let me set it to anything over a million on an entry, giving the error number_exceeds_limit.
I've thought about saving it as a string rather than use the decimal content type but I need to display them in order using orderby on the field and if it is a string it will treat 9 and being greater than 100 since 9 is greater than 1.
Is there a way to either increase or get around the million limit?
Expressionengine version 3.5.2 in case it's relevant.
You would need to edit the logic in cp/ee/EllisLab/Addons/text/ft.text.php (line 62 in 5.1.2) and also edit the column type in the DB structure (I just tried this locally setting the field length to 20,4 instead of 10,4.
It is probably worth raising an issue about this on the EE github as that limit seems restrictive to me (mySQL supports 65 digits). https://github.com/ExpressionEngine/ExpressionEngine/issues
I'm new to using Xdebug via the Vim plugin Vdebug.
I'm getting on OK, but I noticed that if I create an array with over 32 elements, the Watch window only shows elements 0-31 (i.e. the first 32). There does not seem to be a way to obtain the next 32, or to tell it to fetch all of them (or 1000 of them or whatever)?
Is this a bug/feature-lack in Vdebug? Is there anything I can do about it?
I'm debugging Drupal, which has very big, complex arrays (which sometimes contain recursive references #sigh), so at first I thought maybe it's iterating, getting in a loop and hitting max data limit. But I tried just looking at for ($i=0;$i<50;$i++) $a[] = $i; and this, too, only lists elements 0-31.
I have tried
let g:vdebug_features['max_depth'] = 1000
let g:vdebug_features['max_data'] = 1000000
but they have not made any difference.
Thanks,
After Vdebug is loaded, put this
let g:vdebug_features = { 'max_children': 128 }
Or whatever you'd like your max to be.
All credit to romaini for this answer as it was his comment that meant I found this problem listed as an issue on the vdebug github repo.
Using the lists webservice I retrieve the items from a list. In the XML returned I can see the attribute ows__IsCurrentVersion="1" which I assume is the same as the file object model (i.e. a boolean to say if it is current or not).
However I do not see a way to identify what revision it is? What should that attribute be?
By 'revision' do you mean version? If so, you are probably looking for one of these attributes:
ows_owshiddenversion is an Integer (ex: 8)
ows__UIVersion is an Integer (ex: 4096)
ows__UIVersionString is a String (ex: 8.0)
*edit*
Here is some more information after testing it using a Document Library. You should also check the other comments by Hugo and Janis, as they have some good information.
ows_owshiddenversion ows__UIVersion ows__UIVersionString
1 512 1.0
2 513 1.1
3 514 1.2
4 1024 2.0
5 1025 2.1
Most likely, what you are looking for is ows_owshiddenversion.
The columns in the list you are looking for are VersionID (usually 512, 1024, etc.) and VersionLabel (usually 1.0, 2.0, 3.0) and the attributes that Kit Menke pointed out will give you that information if you are using the Web Service.
You might want to have a look at the Versions web service if you need to do more work with the web services : http://server/_vti_bin/versions.asmx
Ill just add some info. You can use UIVersion (which is version id) or UIVersionString (which is user-friendly version label)
For example
label 0.1 -> id 1
label 1.0 -> id 512
label 1.1 -> id 513
label 2.0 -> 1024
label 2.2 -> 1026.
IsCurrentVersion will be true for latest MAJOR (published) version (2.0 or 3.0, but not 3.1). Minor version number is draft version.
Some insights about versioning i wrote in my own question & answer.
I recently started playing around with SubSonic 2.2 (only 2.2 because I didn't find any Oracle t4 templates at the time). That aside, I have been noticing that I can run a query on table a and field b will have a value of 1. If I went into Sql Tools or Oracle Developer and changed field b to a value of 2, SubSonic's LoadByKey functions still returns an object with field b having a value of 1.
In case that is hard to read.
var id = "primary key";
x.LoadByKey(id);
Console.Write(x.b); -> yields 1
I can go change this value in another program and rerun the code and it is always 1 regardless.
Any ideas?
The only thing I can think is that it's an app issue, or a driver-level issue. We don't implement any kind of caching.