• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Post Content Find / Replace 2.0.1

No permission to download

Chris D

XenForo developer
Staff member
#1

invictus

Active member
#2
Thank you!

Does the 'Save Changes' checkbox execute it? So leaving this unchecked is a way to test regex without executing write to the database?
 

invictus

Active member
#3
Ran a query with 'Save Changes' unchecked and it looked good. Checked 'Save Changes' and ran it again, got this error:

Code:
An exception occurred: [Error] Call to undefined method XF\Service\Post\Editor::setIsAutomated() in src/addons/XFPR/Admin/Controller/PostReplace.php on line 54

XFPR\Admin\Controller\PostReplace->actionReplace() in src/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 88
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1831
XF\App->run() in src/XF.php at line 328
XF::runApp() in admin.php at line 13
See this in Server Log:

Code:
Server error log
Error: Call to undefined method XF\Service\Post\Editor::setIsAutomated() src/addons/XFPR/Admin/Controller/PostReplace.php:54
Generated by: admin Oct 19, 2017 at 3:42 AM

Stack trace
#0 src/XF/Mvc/Dispatcher.php(249): XFPR\Admin\Controller\PostReplace->actionReplace(Object(XF\Mvc\ParameterBag))
#1 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XFPR:PostReplac...', 'Replace', 'html', Object(XF\Mvc\ParameterBag), '', Object(XFPR\Admin\Controller\PostReplace), NULL)
#2 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#3 src/XF/App.php(1831): XF\Mvc\Dispatcher->run()
#4 src/XF.php(328): XF\App->run()
#5 admin.php(13): XF::runApp('XF\\Admin\\App')
#6 {main}

Request state
array(4) {
  ["url"] => string(37) "/forum/admin.php?post-replace/replace"
  ["referrer"] => string(67) "https://www.photoshopgurus.com/forum/admin.php?post-replace/replace"
  ["_GET"] => array(1) {
    ["post-replace/replace"] => string(0) ""
  }
  ["_POST"] => array(5) {
    ["quick_find"] => string(6) "[video"
    ["regex"] => string(53) "#\[video=youtube;([a-z0-9_-]{11})][^\[]+\[/video]#siu"
    ["replace"] => string(25) "[media=youtube]\1[/media]"
    ["commit"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
  }
}
 
Last edited:

Chris D

XenForo developer
Staff member
#6
Sorry, my bad. I'll actually release an update shortly but that will only restrict it from being installed on < Beta 7.

In the file src/addons/XFPR/Admin/Controller/PostReplace.php find:
PHP:
$editor->setIsAutomated();
And replace with:
PHP:
// $editor->setIsAutomated();
 

invictus

Active member
#8
Thanks @Chris D

I commented that line as indicated, rebuilt the addon, ran it again and I get this now:

Code:
LogicException: Cannot save with validation errors. Use validate() to ensure there are no errors. (First error: Please enter a message with no more than 5 pieces of media.) in src/XF/Service/ValidateAndSavableTrait.php at line 34
XF\Service\Post\Editor->save() in src/addons/XFPR/Admin/Controller/PostReplace.php at line 59
XFPR\Admin\Controller\PostReplace->actionReplace() in src/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 88
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1831
XF\App->run() in src/XF.php at line 328
XF::runApp() in admin.php at line 13
Server Error Log:

Code:
Server error log
LogicException: Cannot save with validation errors. Use validate() to ensure there are no errors. (First error: Please enter a message with no more than 5 pieces of media.) src/XF/Service/ValidateAndSavableTrait.php:34
Generated by: admin Oct 19, 2017 at 4:01 AM
Stack trace
#0 src/addons/XFPR/Admin/Controller/PostReplace.php(59): XF\Service\Post\Editor->save()
#1 src/XF/Mvc/Dispatcher.php(249): XFPR\Admin\Controller\PostReplace->actionReplace(Object(XF\Mvc\ParameterBag))
#2 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XFPR:PostReplac...', 'Replace', 'html', Object(XF\Mvc\ParameterBag), '', Object(XFPR\Admin\Controller\PostReplace), NULL)
#3 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#4 src/XF/App.php(1831): XF\Mvc\Dispatcher->run()
#5 src/XF.php(328): XF\App->run()
#6 admin.php(13): XF::runApp('XF\\Admin\\App')
#7 {main}
Request state
array(4) {
  ["url"] => string(37) "/forum/admin.php?post-replace/replace"
  ["referrer"] => string(67) "https://www.photoshopgurus.com/forum/admin.php?post-replace/replace"
  ["_GET"] => array(1) {
    ["post-replace/replace"] => string(0) ""
  }
  ["_POST"] => array(5) {
    ["quick_find"] => string(6) "[video"
    ["regex"] => string(53) "#\[video=youtube;([a-z0-9_-]{11})][^\[]+\[/video]#siu"
    ["replace"] => string(25) "[media=youtube]\1[/media]"
    ["commit"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
  }
 

Chris D

XenForo developer
Staff member
#9
This is where Beta 7 will help as it will ignore that error.

But basically you have your max Media per message option set to 5, but one of the posts being edited contains more than 5.

Probably worth just setting that to 0 (for no limit) for now and that should sort it.
 
Last edited:

invictus

Active member
#11
I updated to Beta 7 and uploaded the new version of this addon. I'm unable to run the addon updater, it says:

The following errors must be resolved before continuing:
  • Post Content Find / Replace requires XenForo 2.0.0 Beta 7+.
Doesn't seem to recognize I am running Beta 7.
 
Last edited: