Comments (6)
I'd vote for skipping it if the number of args is only 1.
from glotpress.
Actually digging in to the code some more this should already be handled correctly, from thing.php:
function prepare( $args ) {
global $wpdb;
if ( 1 == count( $args ) ) {
return $args[0];
} else {
$query = array_shift( $args );
return $wpdb->prepare( $query, $args );
}
}
Where are you trying to delete the glossary/project from? I don't see any UI for it...
from glotpress.
Ok, I found the issue:
function delete_all( $where = null ) {
$query = "DELETE FROM $this->table";
$conditions_sql = $this->sql_from_conditions( $where );
if ( $conditions_sql ) $query .= " WHERE $conditions_sql";
return $this->query( $query, $this->id );
}
Notice the call to $this->query always adds in $this->id, which forces the args count to be 2 even if the query returned does not require it.
Backpress (I assume) like older versions of WordPress (pre 3.5?) didn't throw an error if you passed in a string without any placeholders to prepare() so it wasn't a problem in standalone.
The "off the top of my head" solution is to replace the above with:
function delete_all( $where = null ) {
$query = "DELETE FROM $this->table";
$conditions_sql = $this->sql_from_conditions( $where );
if ( $conditions_sql ) $query .= " WHERE $conditions_sql";
// If there are placeholders in the query, pass in the id otherwise don't because $wpdb->prepare will throw an error.
if ( preg_match( '/\%[sdf]/i', $query ) ) {
return $this->query( $query, $this->id );
} else {
return $this->query( $query );
}
}
but that's kind of ugly 😦
Though since it won't be called all that often it may be reasonable.
from glotpress.
I've poked at this some more and I think there's an easier solution than the above, which is just to remove $this->id from the query call. None of the delete methods use it as far as I can tell.
I'll create a PR for it.
from glotpress.
@toolstack Looks like you're right, seems to be a copy&paste issue in https://glotpress.trac.wordpress.org/changeset/500.
from glotpress.
Woohoo! I like it when I'm right 😄
from glotpress.
Related Issues (20)
- Warning/Fatal due to pentesting payloads
- Warning (PHP7) / Fatal (PHP8) triggered by user inputs in gp_array_get()
- GlotPress saves the wrong translation
- Allow importing translations from the new PHP format
- No warning is given when a fuzzy is approved that contains a missing placeholder like %1$s HOT 5
- AZB locale properties need to be updated HOT 7
- False positive match in Glossary term '&' HOT 4
- Version discussion and translation statistics in GlotPress HOT 2
- Improve discussion mails - Not send 1 per discussion string HOT 6
- Exporting as only "es" not "es_ES" HOT 1
- URLs without ending slash aren't fully recognized
- Breadcrumbs: All the items have links including the last one (current), only some have ending actions HOT 3
- Glossary: No matches for single words of part_of_speech with no suffix rules
- Glossary: Match by glossary terms already suffixed HOT 1
- We do not have a link to the project in the breadcrumbs when we create a new project
- Currently GlotPress gives unwanted error messages for missing uppercase at the start of the sentence.
- Cascading warnings from input on array functions HOT 3
- Add regex option to search
- Tables go out of the viewport in lower resolutions
- Glossary recognation issue with "-"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glotpress.