@@ -40,6 +40,12 @@ protected function configure()
40
40
'The query language (e.g. sql, jcr_sql2) ' ,
41
41
'jcr-sql2 '
42
42
)
43
+ ->addOption (
44
+ 'persist-counter ' , 'c ' ,
45
+ InputOption::VALUE_OPTIONAL ,
46
+ 'Save the session every x requests ' ,
47
+ '100 '
48
+ )
43
49
->setDescription ('Command to manipulate the nodes in the workspace. ' )
44
50
->setHelp (<<<HERE
45
51
The <info>phpcr:nodes:update</info> can manipulate the properties of nodes
@@ -80,6 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
80
86
81
87
$ query = $ input ->getOption ('query ' );
82
88
$ queryLanguage = strtoupper ($ input ->getOption ('query-language ' ));
89
+ $ persistCounter = intval ($ input ->getOption ('persist-counter ' ));
83
90
$ setProp = $ input ->getOption ('set-prop ' );
84
91
$ removeProp = $ input ->getOption ('remove-prop ' );
85
92
$ addMixins = $ input ->getOption ('add-mixin ' );
@@ -111,6 +118,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
111
118
}
112
119
}
113
120
121
+ $ persistIn = $ persistCounter ;
122
+
114
123
foreach ($ result as $ i => $ row ) {
115
124
$ output ->writeln (sprintf (
116
125
"<info>Updating node:</info> [%d] %s. " ,
@@ -127,6 +136,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
127
136
'removeMixins ' => $ removeMixins ,
128
137
'applyClosures ' => $ applyClosures ,
129
138
));
139
+
140
+ $ persistIn --;
141
+ if (0 === $ persistIn ) {
142
+ $ output ->writeln ('<info>Saving nodes processed so far...</info> ' );
143
+ $ session ->save ();
144
+ $ persistIn = $ persistCounter ;
145
+ }
130
146
}
131
147
132
148
$ output ->writeln ('<info>Saving session...</info> ' );
0 commit comments