Skip to content

Commit 3e39cd2

Browse files
committed
Fix an issue causing notices in debug mode + some Repeater fixes
1 parent 3fdd325 commit 3e39cd2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

ProcessVersionControl.module

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ProcessVersionControl extends Process implements ConfigurableModule {
2525
'summary' => 'Provides the interface required by Version Control.',
2626
'href' => 'http://modules.processwire.com/modules/version-control/',
2727
'author' => 'Teppo Koivula',
28-
'version' => '1.3.0',
28+
'version' => '1.3.1',
2929
'singular' => true,
3030
'autoload' => false,
3131
'permission' => 'version-control',
@@ -217,19 +217,21 @@ class ProcessVersionControl extends Process implements ConfigurableModule {
217217
$pages_id = $this->input->get->pages_id ? (int) $this->input->get->pages_id : null;
218218
if (!$pages_id) throw new WireException("Missing required GET param pages_id");
219219
$page = $this->pages->get($pages_id);
220-
$page_ids = array($pages_id);
220+
$page_ids = array(':p0' => $pages_id);
221221

222222
// include repeater pages
223+
$p_num = 0;
223224
$repeater_fields = array();
224225
if ($this->modules->isInstalled('FieldtypeRepeater')) {
225226
foreach ($page->fields as $field) {
226227
if ($field->type instanceof FieldtypeRepeater) {
227228
$subfields = $this->templates->get($field->template_id)->versionControlFields;
228229
if (count($subfields)) {
229230
foreach ($page->$field as $repeater_page) {
230-
$page_ids[] = $repeater_page;
231+
++$p_num;
232+
$page_ids[':p' . $p_num] = $repeater_page->id;
231233
foreach ($subfields as $subfield) {
232-
$repeater_fields[] = $subfield . "_repeater" . $repeater_page;
234+
$repeater_fields[] = $subfield . "_repeater" . $repeater_page->id;
233235
}
234236
}
235237
}
@@ -244,11 +246,14 @@ class ProcessVersionControl extends Process implements ConfigurableModule {
244246
$stmt = $this->database->prepare("
245247
SELECT MIN(r.pages_id) pages_id, MIN(f.name) field_name, MIN(r.timestamp) timestamp, MIN(r.users_id) users_id, MIN(r.username) username, MIN(d.revisions_id) revisions_id, MIN(d.property) property, MIN(d.data) data
246248
FROM fields f, " . VersionControl::TABLE_REVISIONS . " r, " . VersionControl::TABLE_DATA . " d
247-
WHERE r.pages_id IN (" . rtrim(str_repeat('?, ', count($page_ids)), ', ') . ") AND d.revisions_id = r.id AND f.id = d.fields_id
249+
WHERE r.pages_id IN (" . implode(',', array_keys($page_ids)) . ") AND d.revisions_id = r.id AND f.id = d.fields_id
248250
GROUP BY r.id, f.id
249251
ORDER BY f.id, d.id DESC
250252
");
251-
$stmt->execute($page_ids);
253+
foreach ($page_ids as $p_num => $p_id) {
254+
$stmt->bindValue($p_num, $p_id, \PDO::PARAM_INT);
255+
}
256+
$stmt->execute();
252257

253258
// fetch enabled fields
254259
$enabled_fields = array();
@@ -334,6 +339,7 @@ class ProcessVersionControl extends Process implements ConfigurableModule {
334339
// get field name and revision ids
335340
$field_name = $this->sanitizer->fieldName($this->input->get->field);
336341
if (!$field_name) throw new WireException("Missing required GET param field");
342+
$field_name = strpos($field_name, '_repeater') ? preg_replace('/_repeater[0-9]+$/', '', $field_name) : $field_name;
337343
$revisions = $this->input->get->revisions ?: null;
338344
if (!$revisions) throw new WireException("Missing required GET param revisions");
339345

@@ -448,6 +454,7 @@ class ProcessVersionControl extends Process implements ConfigurableModule {
448454
if (!$revision_id) throw new WireException("Missing required GET param revision");
449455
$field_name = $this->sanitizer->fieldName($this->input->get->field);
450456
if (!$field_name) throw new WireException("Missing required GET param field");
457+
$field_name = strpos($field_name, '_repeater') ? preg_replace('/_repeater[0-9]+$/', '', $field_name) : $field_name;
451458

452459
// additional settings
453460
$settings = $this->input->get->settings;

VersionControl.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VersionControl extends WireData implements Module, ConfigurableModule {
2929
'summary' => 'Version control features for page content.',
3030
'href' => 'https://modules.processwire.com/modules/version-control/',
3131
'author' => 'Teppo Koivula',
32-
'version' => '1.3.1',
32+
'version' => '1.3.2',
3333
'singular' => true,
3434
'autoload' => true,
3535
'installs' => array(

0 commit comments

Comments
 (0)